Skip to content

Commit 48b655f

Browse files
author
Esben Sparre Andreasen
committed
JS: split CommandInjection.qll
1 parent ccc171c commit 48b655f

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/CommandInjection.qll

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
/**
2-
* Provides a taint tracking configuration for reasoning about command-injection
3-
* vulnerabilities (CWE-078).
2+
* Provides a taint tracking configuration for reasoning about
3+
* command-injection vulnerabilities (CWE-078).
4+
*
5+
* Note, for performance reasons: only import this file if
6+
* `CommandInjection::Configuration` is needed, otherwise
7+
* `CommandInjectionCustomizations` should be imported instead.
48
*/
59

610
import javascript
7-
import semmle.javascript.security.dataflow.RemoteFlowSources
811

912
module CommandInjection {
10-
/**
11-
* A data flow source for command-injection vulnerabilities.
12-
*/
13-
abstract class Source extends DataFlow::Node { }
14-
15-
/**
16-
* A data flow sink for command-injection vulnerabilities.
17-
*/
18-
abstract class Sink extends DataFlow::Node { }
19-
20-
/**
21-
* A sanitizer for command-injection vulnerabilities.
22-
*/
23-
abstract class Sanitizer extends DataFlow::Node { }
13+
import CommandInjectionCustomizations::CommandInjection
2414

2515
/**
2616
* A taint-tracking configuration for reasoning about command-injection vulnerabilities.
@@ -45,18 +35,6 @@ module CommandInjection {
4535
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
4636
}
4737

48-
/** A source of remote user input, considered as a flow source for command injection. */
49-
class RemoteFlowSourceAsSource extends Source {
50-
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
51-
}
52-
53-
/**
54-
* A command argument to a function that initiates an operating system command.
55-
*/
56-
class SystemCommandExecutionSink extends Sink, DataFlow::ValueNode {
57-
SystemCommandExecutionSink() { this = any(SystemCommandExecution sys).getACommandArgument() }
58-
}
59-
6038
/**
6139
* Auxiliary data flow configuration for tracking string literals that look like they
6240
* may refer to an operating system shell, and array literals that may end up being
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Provides default sources, sinks and sanitisers for reasoning about
3+
* command-injection vulnerabilities, as well as extension points for
4+
* adding your own.
5+
*/
6+
7+
import javascript
8+
import semmle.javascript.security.dataflow.RemoteFlowSources
9+
10+
module CommandInjection {
11+
/**
12+
* A data flow source for command-injection vulnerabilities.
13+
*/
14+
abstract class Source extends DataFlow::Node { }
15+
16+
/**
17+
* A data flow sink for command-injection vulnerabilities.
18+
*/
19+
abstract class Sink extends DataFlow::Node { }
20+
21+
/**
22+
* A sanitizer for command-injection vulnerabilities.
23+
*/
24+
abstract class Sanitizer extends DataFlow::Node { }
25+
26+
/** A source of remote user input, considered as a flow source for command injection. */
27+
class RemoteFlowSourceAsSource extends Source {
28+
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
29+
}
30+
31+
/**
32+
* A command argument to a function that initiates an operating system command.
33+
*/
34+
class SystemCommandExecutionSink extends Sink, DataFlow::ValueNode {
35+
SystemCommandExecutionSink() { this = any(SystemCommandExecution sys).getACommandArgument() }
36+
}
37+
38+
}

0 commit comments

Comments
 (0)