From a3eecc33a890f4ce2ea98af800fc90774086f730 Mon Sep 17 00:00:00 2001 From: Josh Brown Date: Fri, 22 Mar 2024 14:47:14 -0700 Subject: [PATCH] Filter our sources in test folders --- .../src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql b/cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql index 107be7bddfd..3c11d6d0d1e 100644 --- a/cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql +++ b/cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql @@ -116,10 +116,15 @@ module ImproperArrayIndexValidationConfig implements DataFlow::ConfigSig { module ImproperArrayIndexValidation = TaintTracking::Global; +predicate isInTestFile(ImproperArrayIndexValidation::PathNode node){ + node.getNode().asExpr().getFile().getRelativePath().regexpMatch("/tests?/") +} + from ImproperArrayIndexValidation::PathNode source, ImproperArrayIndexValidation::PathNode sink, string sourceType where + not isInTestFile(source) and ImproperArrayIndexValidation::flowPath(source, sink) and isFlowSource(source.getNode(), sourceType) select sink.getNode(), source, sink,