Skip to content

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

actions/ql/lib/codeql/actions/security/CommandInjectionQuery.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ private import codeql.actions.TaintTracking
33
private import codeql.actions.dataflow.ExternalFlow
44
import codeql.actions.dataflow.FlowSources
55
import codeql.actions.DataFlow
6+
import codeql.actions.security.ControlChecks
67

78
private class CommandInjectionSink extends DataFlow::Node {
89
CommandInjectionSink() { madSink(this, "command-injection") }
@@ -16,6 +17,22 @@ private module CommandInjectionConfig implements DataFlow::ConfigSig {
1617
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
1718

1819
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }
20+
21+
predicate observeDiffInformedIncrementalMode() { any() }
22+
23+
Location getASelectedSourceLocation(DataFlow::Node source) { none() }
24+
25+
Location getASelectedSinkLocation(DataFlow::Node sink) {
26+
result = sink.getLocation()
27+
or
28+
// where clause from CommandInjectionCritical.ql
29+
exists(Event event | result = event.getLocation() |
30+
inPrivilegedContext(sink.asExpr(), event) and
31+
not exists(ControlCheck check |
32+
check.protects(sink.asExpr(), event, ["command-injection", "code-injection"])
33+
)
34+
)
35+
}
1936
}
2037

2138
/** Tracks flow of unsafe user input that is used to construct and evaluate a system command. */

0 commit comments

Comments
 (0)