Skip to content

Commit 9f28519

Browse files
committed
feat(go): Query updates to param modules
1 parent 4775f50 commit 9f28519

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

go/src/security/CWE-078/CommandInjection.ql

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,31 @@
1313

1414
import go
1515
import semmle.go.security.CommandInjection
16-
import DataFlow::PathGraph
1716
import semmle.go.security.FlowSources
1817

19-
//Override CommandInjection::Configuration to use the in-use sources
20-
class InUseCommandInjectionConfiguration extends CommandInjection::Configuration {
21-
override predicate isSource(DataFlow::Node node) {
18+
module FlowConfig implements DataFlow::ConfigSig {
19+
predicate isSource(DataFlow::Node node) {
2220
exists(UntrustedFlowSource source, Function function, DataFlow::CallNode callNode |
2321
source.asExpr() = node.asExpr() and
24-
2522
source.(DataFlow::ExprNode).asExpr().getEnclosingFunction() = function.getFuncDecl() and
2623
(
2724
// function is called directly
2825
callNode.getACallee() = function.getFuncDecl()
29-
26+
or
3027
// function is passed to another function to be called
31-
or callNode.getCall().getAnArgument().(Ident).refersTo(function) //NEW with 2.13.2: or c.getASyntacticArgument().asExpr().(Ident).refersTo(f)
32-
)
28+
callNode.getCall().getAnArgument().(Ident).refersTo(function) //NEW with 2.13.2: or c.getASyntacticArgument().asExpr().(Ident).refersTo(f)
29+
)
3330
)
3431
}
32+
33+
predicate isSink(DataFlow::Node sink) {
34+
exists(CommandInjection::Sink s | sink = s | not s.doubleDashIsSanitizing())
35+
}
3536
}
3637

37-
from InUseCommandInjectionConfiguration cfg, CommandInjection::DoubleDashSanitizingConfiguration cfg2, DataFlow::PathNode source, DataFlow::PathNode sink
38-
where (cfg.hasFlowPath(source, sink) or cfg2.hasFlowPath(source, sink))
39-
select sink.getNode(), source, sink, "This command depends on a $@.", source.getNode(), "user-provided value"
38+
module Flow = TaintTracking::Global<FlowConfig>;
39+
40+
from Flow::PathNode source, Flow::PathNode sink
41+
where Flow::flowPath(source, sink)
42+
select sink.getNode(), source, sink, "This command depends on a $@.", source.getNode(),
43+
"user-provided value"

0 commit comments

Comments
 (0)