13
13
14
14
import go
15
15
import semmle.go.security.CommandInjection
16
- import DataFlow:: PathGraph
17
- import semmle.go.security.FlowSources
16
+ import semmle.go.security.CommandInjectionCustomizations:: CommandInjection
18
17
19
18
//Override CommandInjection::Configuration to use the in-use sources
20
- class InUseCommandInjectionConfiguration extends CommandInjection :: Configuration {
21
- override predicate isSource ( DataFlow :: Node node ) {
19
+ class InUseAsSource extends Source instanceof UntrustedFlowSource {
20
+ InUseAsSource ( ) {
22
21
exists ( UntrustedFlowSource source , Function function , DataFlow:: CallNode callNode |
23
- source .asExpr ( ) = node .asExpr ( ) and
22
+ source .asExpr ( ) = this .asExpr ( ) and
24
23
source .( DataFlow:: ExprNode ) .asExpr ( ) .getEnclosingFunction ( ) = function .getFuncDecl ( ) and
25
24
(
26
25
// function is called directly
@@ -33,9 +32,16 @@ class InUseCommandInjectionConfiguration extends CommandInjection::Configuration
33
32
}
34
33
}
35
34
36
- from
37
- InUseCommandInjectionConfiguration cfg , CommandInjection:: DoubleDashSanitizingConfiguration cfg2 ,
38
- DataFlow:: PathNode source , DataFlow:: PathNode sink
39
- where ( cfg .hasFlowPath ( source , sink ) or cfg2 .hasFlowPath ( source , sink ) )
35
+ module Flow =
36
+ DataFlow:: MergePathGraph< CommandInjection:: Flow:: PathNode ,
37
+ CommandInjection:: DoubleDashSanitizingFlow:: PathNode , CommandInjection:: Flow:: PathGraph ,
38
+ CommandInjection:: DoubleDashSanitizingFlow:: PathGraph > ;
39
+
40
+ import Flow:: PathGraph
41
+
42
+ from Flow:: PathNode source , Flow:: PathNode sink
43
+ where
44
+ CommandInjection:: Flow:: flowPath ( source .asPathNode1 ( ) , sink .asPathNode1 ( ) ) or
45
+ CommandInjection:: DoubleDashSanitizingFlow:: flowPath ( source .asPathNode2 ( ) , sink .asPathNode2 ( ) )
40
46
select sink .getNode ( ) , source , sink , "This command depends on a $@." , source .getNode ( ) ,
41
47
"user-provided value"
0 commit comments