Skip to content

Commit 720285f

Browse files
committed
Filter out sources from test directories
1 parent a3eecc3 commit 720285f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ predicate predictableInstruction(Instruction instr) {
6666
}
6767

6868
module ImproperArrayIndexValidationConfig implements DataFlow::ConfigSig {
69-
predicate isSource(DataFlow::Node source) { isFlowSource(source, _) }
69+
predicate isSource(DataFlow::Node source) {
70+
isFlowSource(source, _) and
71+
not source.asExpr().getFile().getRelativePath().regexpMatch("/tests?/")
72+
}
7073

7174
predicate isBarrier(DataFlow::Node node) {
7275
hasUpperBound(node.asExpr())
@@ -116,15 +119,11 @@ module ImproperArrayIndexValidationConfig implements DataFlow::ConfigSig {
116119

117120
module ImproperArrayIndexValidation = TaintTracking::Global<ImproperArrayIndexValidationConfig>;
118121

119-
predicate isInTestFile(ImproperArrayIndexValidation::PathNode node){
120-
node.getNode().asExpr().getFile().getRelativePath().regexpMatch("/tests?/")
121-
}
122-
123122
from
124-
ImproperArrayIndexValidation::PathNode source, ImproperArrayIndexValidation::PathNode sink,
123+
ImproperArrayIndexValidation::PathNode source,
124+
ImproperArrayIndexValidation::PathNode sink,
125125
string sourceType
126126
where
127-
not isInTestFile(source) and
128127
ImproperArrayIndexValidation::flowPath(source, sink) and
129128
isFlowSource(source.getNode(), sourceType)
130129
select sink.getNode(), source, sink,

0 commit comments

Comments
 (0)