Skip to content

Commit 1c9545e

Browse files
committed
Address comment from code review:
Make `SyntacticHeuristics` an explicit import
1 parent 8d22fd2 commit 1c9545e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointCharacteristics.qll

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private import semmle.javascript.security.dataflow.DomBasedXssCustomizations
88
private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
99
private import semmle.javascript.security.dataflow.TaintedPathCustomizations
1010
private import CoreKnowledge as CoreKnowledge
11-
private import semmle.javascript.heuristics.SyntacticHeuristics
11+
private import semmle.javascript.heuristics.SyntacticHeuristics as SyntacticHeuristics
1212
private import semmle.javascript.filters.ClassifyFiles as ClassifyFiles
1313
private import StandardEndpointFilters as StandardEndpointFilters
1414

@@ -540,7 +540,9 @@ private class IsHashCharacteristic extends StandardEndpointFilterCharacteristic
540540
private class IsNumericCharacteristic extends StandardEndpointFilterCharacteristic {
541541
IsNumericCharacteristic() { this = "numeric" }
542542

543-
override predicate getEndpoints(DataFlow::Node n) { isReadFrom(n, ".*index.*") }
543+
override predicate getEndpoints(DataFlow::Node n) {
544+
SyntacticHeuristics::isReadFrom(n, ".*index.*")
545+
}
544546
}
545547

546548
private class InIrrelevantFileCharacteristic extends StandardEndpointFilterCharacteristic {
@@ -676,8 +678,8 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkNosqlCh
676678
// heuristic sinks as known sinks.
677679
not n = StandardEndpointFilters::getALikelyExternalLibraryCall().getAnArgument() and
678680
not (
679-
isAssignedToOrConcatenatedWith(n, "(?i)(nosql|query)") or
680-
isArgTo(n, "(?i)(query)")
681+
SyntacticHeuristics::isAssignedToOrConcatenatedWith(n, "(?i)(nosql|query)") or
682+
SyntacticHeuristics::isArgTo(n, "(?i)(query)")
681683
)
682684
}
683685
}
@@ -745,9 +747,9 @@ private class NotAnArgumentToLikelyExternalLibraryCallOrHeuristicSinkCharacteris
745747
// heuristic sinks as known sinks.
746748
not StandardEndpointFilters::flowsToArgumentOfLikelyExternalLibraryCall(n) and
747749
not (
748-
isAssignedToOrConcatenatedWith(n, "(?i)(sql|query)") or
749-
isArgTo(n, "(?i)(query)") or
750-
isConcatenatedWithString(n,
750+
SyntacticHeuristics::isAssignedToOrConcatenatedWith(n, "(?i)(sql|query)") or
751+
SyntacticHeuristics::isArgTo(n, "(?i)(query)") or
752+
SyntacticHeuristics::isConcatenatedWithString(n,
751753
"(?s).*(ALTER|COUNT|CREATE|DATABASE|DELETE|DISTINCT|DROP|FROM|GROUP|INSERT|INTO|LIMIT|ORDER|SELECT|TABLE|UPDATE|WHERE).*")
752754
)
753755
}
@@ -783,24 +785,24 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkTainted
783785
// heuristic sinks as known sinks.
784786
not StandardEndpointFilters::flowsToArgumentOfLikelyExternalLibraryCall(n) and
785787
not (
786-
isAssignedToOrConcatenatedWith(n, "(?i)(file|folder|dir|absolute)")
788+
SyntacticHeuristics::isAssignedToOrConcatenatedWith(n, "(?i)(file|folder|dir|absolute)")
787789
or
788-
isArgTo(n, "(?i)(get|read)file")
790+
SyntacticHeuristics::isArgTo(n, "(?i)(get|read)file")
789791
or
790792
exists(string pathPattern |
791793
// paths with at least two parts, and either a trailing or leading slash
792794
pathPattern = "(?i)([a-z0-9_.-]+/){2,}" or
793795
pathPattern = "(?i)(/[a-z0-9_.-]+){2,}"
794796
|
795-
isConcatenatedWithString(n, pathPattern)
797+
SyntacticHeuristics::isConcatenatedWithString(n, pathPattern)
796798
)
797799
or
798-
isConcatenatedWithStrings(".*/", n, "/.*")
800+
SyntacticHeuristics::isConcatenatedWithStrings(".*/", n, "/.*")
799801
or
800802
// In addition to the names from `HeuristicTaintedPathSink` in the
801803
// `isAssignedToOrConcatenatedWith` predicate call above, we also allow the noisier "path"
802804
// name.
803-
isAssignedToOrConcatenatedWith(n, "(?i)path")
805+
SyntacticHeuristics::isAssignedToOrConcatenatedWith(n, "(?i)path")
804806
)
805807
}
806808
}
@@ -844,13 +846,13 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkXssChar
844846
// heuristic sinks as known sinks.
845847
not StandardEndpointFilters::flowsToArgumentOfLikelyExternalLibraryCall(n) and
846848
not (
847-
isAssignedToOrConcatenatedWith(n, "(?i)(html|innerhtml)")
849+
SyntacticHeuristics::isAssignedToOrConcatenatedWith(n, "(?i)(html|innerhtml)")
848850
or
849-
isArgTo(n, "(?i)(html|render)")
851+
SyntacticHeuristics::isArgTo(n, "(?i)(html|render)")
850852
or
851853
n instanceof StringOps::HtmlConcatenationLeaf
852854
or
853-
isConcatenatedWithStrings("(?is).*<[a-z ]+.*", n, "(?s).*>.*")
855+
SyntacticHeuristics::isConcatenatedWithStrings("(?is).*<[a-z ]+.*", n, "(?s).*>.*")
854856
or
855857
// In addition to the heuristic sinks from `HeuristicDomBasedXssSink`, explicitly allow
856858
// property writes like `elem.innerHTML = <TAINT>` that may not be picked up as HTML

0 commit comments

Comments
 (0)