Rust: add class printouts to AstConsistency.ql

This commit is contained in:
Paolo Tranquilli
2024-11-21 11:42:00 +01:00
parent d8b453fc0d
commit 36d8a6d05f
2 changed files with 6 additions and 11 deletions

View File

@@ -14,11 +14,3 @@ private import codeql.dataflow.internal.DataFlowImplConsistency
private module Input implements InputSig<Location, RustDataFlow> { }
import MakeConsistency<Location, RustDataFlow, RustTaintTracking, Input>
/**
* This adds `AstNode` class names to the results of `uniqueNodeToString`, if any.
*/
query predicate uniqueNodeToStringClasses(Node n, string cls) {
uniqueNodeToString(n, _) and
cls = n.getCfgNode().getAstNode().getPrimaryQlClasses()
}

View File

@@ -10,8 +10,9 @@ private predicate multipleToStrings(Element e) { strictcount(e.toString()) > 1 }
/**
* Holds if `e` has more than one `toString()` result.
*/
query predicate multipleToStrings(Element e, string s) {
query predicate multipleToStrings(Element e, string cls, string s) {
multipleToStrings(e) and
cls = e.getPrimaryQlClasses() and
s = strictconcat(e.toString(), ", ")
}
@@ -39,9 +40,11 @@ private predicate multipleParents(Element child) { strictcount(getParent(child))
/**
* Holds if `child` has more than one AST parent.
*/
query predicate multipleParents(Element child, Element parent) {
query predicate multipleParents(Element child, string childClass, Element parent, string parentClass) {
multipleParents(child) and
parent = getParent(child)
childClass = child.getPrimaryQlClasses() and
parent = getParent(child) and
parentClass = parent.getPrimaryQlClasses()
}
/**