@@ -11,25 +11,41 @@ import javascript
1111import CommandInjectionCustomizations:: CommandInjection
1212import IndirectCommandArgument
1313
14+ /**
15+ * Holds if `sink` is a data flow sink for command-injection vulnerabilities, and
16+ * the alert should be placed at the node `highlight`.
17+ */
18+ predicate isSinkWithHighlight ( DataFlow:: Node sink , DataFlow:: Node highlight ) {
19+ sink instanceof Sink and highlight = sink
20+ or
21+ isIndirectCommandArgument ( sink , highlight )
22+ }
23+
1424/**
1525 * A taint-tracking configuration for reasoning about command-injection vulnerabilities.
1626 */
17- class Configuration extends TaintTracking:: Configuration {
18- Configuration ( ) { this = "CommandInjection" }
27+ module CommandInjectionConfig implements DataFlow:: ConfigSig {
28+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
29+
30+ predicate isSink ( DataFlow:: Node sink ) { isSinkWithHighlight ( sink , _) }
31+
32+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
33+ }
34+
35+ /**
36+ * Taint-tracking for reasoning about command-injection vulnerabilities.
37+ */
38+ module CommandInjectionFlow = TaintTracking:: Global< CommandInjectionConfig > ;
1939
20- override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
40+ /**
41+ * DEPRECATED. Use the `CommandInjectionFlow` module instead.
42+ */
43+ deprecated class Configuration extends TaintTracking:: Configuration {
44+ Configuration ( ) { this = "CommandInjection" }
2145
22- /**
23- * Holds if `sink` is a data flow sink for command-injection vulnerabilities, and
24- * the alert should be placed at the node `highlight`.
25- */
26- predicate isSinkWithHighlight ( DataFlow:: Node sink , DataFlow:: Node highlight ) {
27- sink instanceof Sink and highlight = sink
28- or
29- isIndirectCommandArgument ( sink , highlight )
30- }
46+ override predicate isSource ( DataFlow:: Node source ) { CommandInjectionConfig:: isSource ( source ) }
3147
32- override predicate isSink ( DataFlow:: Node sink ) { this . isSinkWithHighlight ( sink , _ ) }
48+ override predicate isSink ( DataFlow:: Node sink ) { CommandInjectionConfig :: isSink ( sink ) }
3349
34- override predicate isSanitizer ( DataFlow:: Node node ) { node instanceof Sanitizer }
50+ override predicate isSanitizer ( DataFlow:: Node node ) { CommandInjectionConfig :: isBarrier ( node ) }
3551}
0 commit comments