@@ -2,47 +2,41 @@ import semmle.javascript.dataflow.TaintTracking
22
33import ghsl.CommandLine
44
5- class RandomTaintsSourceConfiguration extends TaintTracking :: Configuration {
6- RandomTaintsSourceConfiguration ( ) { this = "RandomTaintsSourceConfiguration" }
5+ module RandomTaintsSourceConfig implements DataFlow :: ConfigSig {
6+ predicate isSource ( DataFlow :: Node source ) { isSecureRandom ( source ) }
77
8- override predicate isSource ( DataFlow:: Node source ) {
9- isSecureRandom ( source )
10- }
11-
12- override predicate isSink ( DataFlow:: Node sink ) {
13- not isSecureRandom ( sink )
14- }
8+ predicate isSink ( DataFlow:: Node sink ) { not isSecureRandom ( sink ) }
159}
1610
17- class InsecureIVConfiguration extends TaintTracking:: Configuration {
18- InsecureIVConfiguration ( ) { this = "InsecureIVConfiguration" }
11+ module RandomTaintsSourceFlow = TaintTracking:: Global< RandomTaintsSourceConfig > ;
1912
20- override predicate isSource ( DataFlow:: Node source ) {
21- exists ( Literal literal | literal .flow ( ) = source )
22- or
23- source instanceof DataFlow:: ArrayLiteralNode
24- or
25- source instanceof RemoteFlowSource
26- or
27- source instanceof FileSystemReadAccess
28- or
29- source instanceof DatabaseAccess
30- or
31- source instanceof CommandLineArgument
32- or
33- // an external function that is not a known source of randomness
34- (
35- source instanceof ExternalCallWithOutput
36- and not source instanceof CreateIVArgument
37- and not source instanceof SecureRandomSource
38- )
39- }
13+ module InsecureIVConfig implements DataFlow:: ConfigSig {
14+ predicate isSource ( DataFlow:: Node source ) {
15+ exists ( Literal literal | literal .flow ( ) = source )
16+ or
17+ source instanceof DataFlow:: ArrayLiteralNode
18+ or
19+ source instanceof RemoteFlowSource
20+ or
21+ source instanceof FileSystemReadAccess
22+ or
23+ source instanceof DatabaseAccess
24+ or
25+ source instanceof CommandLineArgument
26+ or
27+ // an external function that is not a known source of randomness
28+ (
29+ source instanceof ExternalCallWithOutput
30+ and not source instanceof CreateIVArgument
31+ and not source instanceof SecureRandomSource
32+ )
33+ }
4034
41- override predicate isSink ( DataFlow:: Node sink ) {
42- sink instanceof CreateIVArgument
43- }
35+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof CreateIVArgument }
4436}
4537
38+ module InsecureIVFlow = TaintTracking:: Global< InsecureIVConfig > ;
39+
4640class ExternalCallWithOutput extends DataFlow:: Node {
4741 CallExpr call ;
4842
0 commit comments