Skip to content

Commit ee05ec0

Browse files
committed
remove sanitnzer and add a where condition instead
use a simpler where condition(the former sanitizer) for overcoming performance problems
1 parent 61a11c6 commit ee05ec0

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/HardcodedCredentialsCustomizations.qll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ module HardcodedCredentials {
3232
ConstantStringSource() { not astNode.getStringValue() = "" }
3333
}
3434

35-
class NonProductionFiles extends Sanitizer {
36-
NonProductionFiles() {
37-
this.getFile()
38-
.getLocation()
39-
.hasLocationInfo(any(string s |
40-
s.regexpMatch(["/.*test[.].*", "/.*demo[.].*", "/.*example[.].*", "/.*sample[.].*"])
41-
), _, _, _, _)
42-
}
43-
}
44-
4535
/**
4636
* A subclass of `Sink` that includes every `CredentialsNode`
4737
* as a credentials sink.

javascript/ql/src/Security/CWE-798/HardcodedCredentials.ql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ predicate looksLikeATemplate(string s) { s.regexpMatch(".*((\\{\\{.*\\}\\})|(<.*
2323
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, string value
2424
where
2525
cfg.hasFlowPath(source, sink) and
26+
not sink.getNode()
27+
.getFile()
28+
.getAbsolutePath()
29+
.toLowerCase()
30+
.matches(["%stest%s", "%sdemo%s", "%sexample%s", "%ssample%s"]) and
2631
// use source value in message if it's available
2732
if source.getNode().asExpr() instanceof ConstantString
2833
then

0 commit comments

Comments
 (0)