Skip to content

Commit 6e5c7f7

Browse files
committed
Actions: CommandInjection
1 parent 0f50b38 commit 6e5c7f7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 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") }
@@ -17,8 +18,20 @@ private module CommandInjectionConfig implements DataFlow::ConfigSig {
1718

1819
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }
1920

20-
predicate observeDiffInformedIncrementalMode() {
21-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 7 does not select a source or sink originating from the flow call on line 23 (/Users/d10c/src/semmle-code/ql/actions/ql/src/experimental/Security/CWE-078/CommandInjectionCritical.ql@30:60:30:64)
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+
)
2235
}
2336
}
2437

0 commit comments

Comments
 (0)