remove FPs in js/build-artifact-leak where the "leaked" properties are constrained to a safe subset

This commit is contained in:
Erik Krogh Kristensen
2020-11-18 10:35:02 +01:00
parent 06733eadea
commit 64828713d6
2 changed files with 72 additions and 0 deletions

View File

@@ -205,6 +205,7 @@ module CleartextLogging {
|
not exists(write.getPropertyName()) and
not exists(read.getPropertyName()) and
not isFilteredPropertyName(read.getPropertyNameExpr().flow().getALocalSource()) and
src = read.getBase() and
trg = write.getBase().getALocalSource()
)
@@ -217,4 +218,24 @@ module CleartextLogging {
trg.asExpr() = f.getArgumentsVariable().getAnAccess()
)
}
/**
* Holds if `name` is filtered by e.g. a regular-expression test or a filter call.
*/
private predicate isFilteredPropertyName(DataFlow::Node name) {
exists(DataFlow::MethodCallNode reduceCall |
reduceCall.getABoundCallbackParameter(0, 1).flowsTo(name) and
reduceCall.getMethodName() = "reduce"
|
reduceCall.getReceiver+().(DataFlow::MethodCallNode).getMethodName() = "filter"
)
or
exists(StringOps::RegExpTest test |
test.getStringOperand().getALocalSource() = name.getALocalSource()
)
or
exists(MembershipCandidate test |
test.getAMemberNode().getALocalSource() = name.getALocalSource()
)
}
}