Filter out sources from test directories

This commit is contained in:
Josh Brown
2024-03-25 11:10:13 -07:00
parent a3eecc33a8
commit 720285f724

View File

@@ -66,7 +66,10 @@ predicate predictableInstruction(Instruction instr) {
}
module ImproperArrayIndexValidationConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { isFlowSource(source, _) }
predicate isSource(DataFlow::Node source) {
isFlowSource(source, _) and
not source.asExpr().getFile().getRelativePath().regexpMatch("/tests?/")
}
predicate isBarrier(DataFlow::Node node) {
hasUpperBound(node.asExpr())
@@ -116,15 +119,11 @@ module ImproperArrayIndexValidationConfig implements DataFlow::ConfigSig {
module ImproperArrayIndexValidation = TaintTracking::Global<ImproperArrayIndexValidationConfig>;
predicate isInTestFile(ImproperArrayIndexValidation::PathNode node){
node.getNode().asExpr().getFile().getRelativePath().regexpMatch("/tests?/")
}
from
ImproperArrayIndexValidation::PathNode source, ImproperArrayIndexValidation::PathNode sink,
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,