Initialalize the autodict-ql
Initialalize the autodict-ql
add codeql scripts
ADD
utils/autodict_ql/litool.ql
+import cpp
+
+class HexOrOctLiteral extends Literal{
+ HexOrOctLiteral(){
+ (this instanceof HexLiteral) or (this instanceof OctalLiteral)
+ }
+}
+
+from HexOrOctLiteral lit
+select lit.getValueText()
\ No newline at end of file

ADD
utils/autodict_ql/memcmp-str.ql
+import cpp
+
+/// function : memcmp trace
+
+from FunctionCall fucall, Expr size
+where
+ fucall.getTarget().hasName("memcmp")
+select fucall.getArgument(_).getValueText()
\ No newline at end of file

ADD
utils/autodict_ql/strcmp-str.ql
+import cpp
+
+/// function : strcmp
+
+from FunctionCall fucall, Expr size
+where
+ fucall.getTarget().hasName("strcmp")
+select fucall.getArgument(_).getValueText()
\ No newline at end of file

ADD
utils/autodict_ql/strncmp-str.ql
+import cpp
+
+/// function : strncmp
+
+from FunctionCall fucall, Expr size
+where
+ fucall.getTarget().hasName("strncmp")
+select fucall.getArgument(_).getValueText()
\ No newline at end of file

ADD
utils/autodict_ql/strtool.ql
+import cpp
+import semmle.code.cpp.dataflow.DataFlow
+class StringLiteralNode extends DataFlow::Node {
+ StringLiteralNode() { this.asExpr() instanceof StringLiteral }
+}
+class MemcmpArgNode extends DataFlow::Node {
+ MemcmpArgNode() {
+ exists(FunctionCall fc |
+ fc.getTarget().getName().regexpMatch(".*(str|mem|strn|b)*(cmp|str)*") and
+ fc.getArgument(0) = this.asExpr()
+ )
+ or
+ exists(FunctionCall fc |
+ fc.getTarget().getName().regexpMatch(".*(str|mem|strn|b)*(cmp|str)*") and
+ fc.getArgument(1) = this.asExpr()
+ )
+ }
+}
+
+from StringLiteralNode src, MemcmpArgNode arg
+where
+ DataFlow::localFlow(src, arg)
+
+select src.asExpr().(StringLiteral).toString()
\ No newline at end of file

Initialalize the autodict-ql

Initialalize the autodict-ql
add codeql scripts