|
13 | 13 |
|
14 | 14 | import go |
15 | 15 | import semmle.go.security.CommandInjection |
16 | | -import DataFlow::PathGraph |
17 | 16 | import semmle.go.security.FlowSources |
18 | 17 |
|
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) { |
22 | 20 | exists(UntrustedFlowSource source, Function function, DataFlow::CallNode callNode | |
23 | 21 | source.asExpr() = node.asExpr() and |
24 | | - |
25 | 22 | source.(DataFlow::ExprNode).asExpr().getEnclosingFunction() = function.getFuncDecl() and |
26 | 23 | ( |
27 | 24 | // function is called directly |
28 | 25 | callNode.getACallee() = function.getFuncDecl() |
29 | | - |
| 26 | + or |
30 | 27 | // 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 | + ) |
33 | 30 | ) |
34 | 31 | } |
| 32 | + |
| 33 | + predicate isSink(DataFlow::Node sink) { |
| 34 | + exists(CommandInjection::Sink s | sink = s | not s.doubleDashIsSanitizing()) |
| 35 | + } |
35 | 36 | } |
36 | 37 |
|
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