@@ -8,7 +8,7 @@ private import semmle.javascript.security.dataflow.DomBasedXssCustomizations
8
8
private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
9
9
private import semmle.javascript.security.dataflow.TaintedPathCustomizations
10
10
private import CoreKnowledge as CoreKnowledge
11
- private import semmle.javascript.heuristics.SyntacticHeuristics
11
+ private import semmle.javascript.heuristics.SyntacticHeuristics as SyntacticHeuristics
12
12
private import semmle.javascript.filters.ClassifyFiles as ClassifyFiles
13
13
private import StandardEndpointFilters as StandardEndpointFilters
14
14
@@ -540,7 +540,9 @@ private class IsHashCharacteristic extends StandardEndpointFilterCharacteristic
540
540
private class IsNumericCharacteristic extends StandardEndpointFilterCharacteristic {
541
541
IsNumericCharacteristic ( ) { this = "numeric" }
542
542
543
- override predicate getEndpoints ( DataFlow:: Node n ) { isReadFrom ( n , ".*index.*" ) }
543
+ override predicate getEndpoints ( DataFlow:: Node n ) {
544
+ SyntacticHeuristics:: isReadFrom ( n , ".*index.*" )
545
+ }
544
546
}
545
547
546
548
private class InIrrelevantFileCharacteristic extends StandardEndpointFilterCharacteristic {
@@ -676,8 +678,8 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkNosqlCh
676
678
// heuristic sinks as known sinks.
677
679
not n = StandardEndpointFilters:: getALikelyExternalLibraryCall ( ) .getAnArgument ( ) and
678
680
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)" )
681
683
)
682
684
}
683
685
}
@@ -745,9 +747,9 @@ private class NotAnArgumentToLikelyExternalLibraryCallOrHeuristicSinkCharacteris
745
747
// heuristic sinks as known sinks.
746
748
not StandardEndpointFilters:: flowsToArgumentOfLikelyExternalLibraryCall ( n ) and
747
749
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 ,
751
753
"(?s).*(ALTER|COUNT|CREATE|DATABASE|DELETE|DISTINCT|DROP|FROM|GROUP|INSERT|INTO|LIMIT|ORDER|SELECT|TABLE|UPDATE|WHERE).*" )
752
754
)
753
755
}
@@ -783,24 +785,24 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkTainted
783
785
// heuristic sinks as known sinks.
784
786
not StandardEndpointFilters:: flowsToArgumentOfLikelyExternalLibraryCall ( n ) and
785
787
not (
786
- isAssignedToOrConcatenatedWith ( n , "(?i)(file|folder|dir|absolute)" )
788
+ SyntacticHeuristics :: isAssignedToOrConcatenatedWith ( n , "(?i)(file|folder|dir|absolute)" )
787
789
or
788
- isArgTo ( n , "(?i)(get|read)file" )
790
+ SyntacticHeuristics :: isArgTo ( n , "(?i)(get|read)file" )
789
791
or
790
792
exists ( string pathPattern |
791
793
// paths with at least two parts, and either a trailing or leading slash
792
794
pathPattern = "(?i)([a-z0-9_.-]+/){2,}" or
793
795
pathPattern = "(?i)(/[a-z0-9_.-]+){2,}"
794
796
|
795
- isConcatenatedWithString ( n , pathPattern )
797
+ SyntacticHeuristics :: isConcatenatedWithString ( n , pathPattern )
796
798
)
797
799
or
798
- isConcatenatedWithStrings ( ".*/" , n , "/.*" )
800
+ SyntacticHeuristics :: isConcatenatedWithStrings ( ".*/" , n , "/.*" )
799
801
or
800
802
// In addition to the names from `HeuristicTaintedPathSink` in the
801
803
// `isAssignedToOrConcatenatedWith` predicate call above, we also allow the noisier "path"
802
804
// name.
803
- isAssignedToOrConcatenatedWith ( n , "(?i)path" )
805
+ SyntacticHeuristics :: isAssignedToOrConcatenatedWith ( n , "(?i)path" )
804
806
)
805
807
}
806
808
}
@@ -844,13 +846,13 @@ private class NotDirectArgumentToLikelyExternalLibraryCallOrHeuristicSinkXssChar
844
846
// heuristic sinks as known sinks.
845
847
not StandardEndpointFilters:: flowsToArgumentOfLikelyExternalLibraryCall ( n ) and
846
848
not (
847
- isAssignedToOrConcatenatedWith ( n , "(?i)(html|innerhtml)" )
849
+ SyntacticHeuristics :: isAssignedToOrConcatenatedWith ( n , "(?i)(html|innerhtml)" )
848
850
or
849
- isArgTo ( n , "(?i)(html|render)" )
851
+ SyntacticHeuristics :: isArgTo ( n , "(?i)(html|render)" )
850
852
or
851
853
n instanceof StringOps:: HtmlConcatenationLeaf
852
854
or
853
- isConcatenatedWithStrings ( "(?is).*<[a-z ]+.*" , n , "(?s).*>.*" )
855
+ SyntacticHeuristics :: isConcatenatedWithStrings ( "(?is).*<[a-z ]+.*" , n , "(?s).*>.*" )
854
856
or
855
857
// In addition to the heuristic sinks from `HeuristicDomBasedXssSink`, explicitly allow
856
858
// property writes like `elem.innerHTML = <TAINT>` that may not be picked up as HTML
0 commit comments