File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
ql/lib/codeql/ruby/security Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides default sources, sinks and sanitizers for reasoning about
3
+ * command-injection vulnerabilities, as well as extension points for
4
+ * adding your own.
5
+ */
6
+
7
+ private import codeql.ruby.DataFlow
8
+ private import codeql.ruby.dataflow.RemoteFlowSources
9
+ private import codeql.ruby.Concepts
10
+ private import codeql.ruby.Frameworks
11
+
12
+ module CommandInjection {
13
+ /**
14
+ * A data flow source for command-injection vulnerabilities.
15
+ */
16
+ abstract class Source extends DataFlow:: Node {
17
+ /** Gets a string that describes the type of this remote flow source. */
18
+ abstract string getSourceType ( ) ;
19
+ }
20
+
21
+ /**
22
+ * A data flow sink for command-injection vulnerabilities.
23
+ */
24
+ abstract class Sink extends DataFlow:: Node { }
25
+
26
+ /**
27
+ * A sanitizer for command-injection vulnerabilities.
28
+ */
29
+ abstract class Sanitizer extends DataFlow:: Node { }
30
+
31
+ /** A source of remote user input, considered as a flow source for command injection. */
32
+ class RemoteFlowSourceAsSource extends Source {
33
+ RemoteFlowSourceAsSource ( ) { this instanceof RemoteFlowSource }
34
+
35
+ override string getSourceType ( ) { result = "a user-provided value" }
36
+ }
37
+
38
+ /**
39
+ * A command argument to a function that initiates an operating system command.
40
+ */
41
+ class SystemCommandExecutionSink extends Sink , DataFlow:: Node {
42
+ SystemCommandExecutionSink ( ) { this instanceof SystemCommandExecution }
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ /**
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.
8
+ */
9
+
10
+ import ruby
11
+ // import IndirectCommandArgument
12
+ import codeql.ruby.TaintTracking
13
+ import CommandInjectionCustomizations:: CommandInjection
14
+ import codeql.ruby.DataFlow
15
+
16
+ /**
17
+ * A taint-tracking configuration for reasoning about command-injection vulnerabilities.
18
+ */
19
+ class Configuration extends TaintTracking:: Configuration {
20
+ Configuration ( ) { this = "CommandInjection" }
21
+
22
+ override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
23
+
24
+ override predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
25
+
26
+ override predicate isSanitizer ( DataFlow:: Node node ) { node instanceof Sanitizer }
27
+ }
You can’t perform that action at this time.
0 commit comments