@@ -22,7 +22,7 @@ private module TestConfig implements DataFlow::ConfigSig {
22
22
c .getName ( ) = "Read-Host" and
23
23
source .asExpr ( ) .getExpr ( ) = c ) }
24
24
25
- predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
25
+ predicate isSink ( DataFlow:: Node sink ) { any ( ) } // sink instanceof Sink }
26
26
predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
27
27
}
28
28
@@ -98,37 +98,33 @@ class AddScriptInvokeSink extends Sink {
98
98
99
99
abstract class Sanitizer extends DataFlow:: Node { }
100
100
101
- // class TypedParameterSanitizer extends Sanitizer{
102
- // TypedParameterSanitizer() {
103
- // exists(Function f, CmdCall c, Parameter p, Argument a |
104
- // p = f.getAParameter() and
105
- // a = c.getAnArgument() and
106
- // p.getName().toLowerCase() = a.getName() and
107
- // p.getStaticType() != "Object" and
108
- // c.getName() = f.getName() and
109
-
110
- // this.asExpr().getExpr() = a
111
- // )
101
+ // class TypedParameterSanitizer extends Sanitizer {
102
+ // TypedParameterSanitizer() {
103
+ // exists(Function f, Parameter p |
104
+ // p = f.getAParameter() and
105
+ // p.getStaticType() != "Object" and
106
+ // this.asParameter() = p
107
+ // )
112
108
// }
113
109
// }
114
110
115
- class SingleQuoteSanitizer extends Sanitizer {
116
- SingleQuoteSanitizer ( ) {
117
- exists ( Expr e , VarReadAccess v |
118
- e = this .asExpr ( ) .getExpr ( ) .getParent ( ) and
119
- e .toString ( ) .matches ( "%'$" + v .getVariable ( ) .getName ( ) + "'%" )
120
- )
121
- }
122
- }
111
+ // class SingleQuoteSanitizer extends Sanitizer {
112
+ // SingleQuoteSanitizer() {
113
+ // exists(Expr e, VarReadAccess v |
114
+ // e = this.asExpr().getExpr().getParent() and
115
+ // e.toString().matches("%'$" + v.getVariable().getName() + "'%")
116
+ // )
117
+ // }
118
+ // }
123
119
124
120
module TestFlow = TaintTracking:: Global< TestConfig > ;
125
121
import TestFlow:: PathGraph
126
122
127
- // from TestFlow::PathNode source, TestFlow::PathNode sink
128
- // where
129
- // TestFlow::flowPath(source, sink) and
130
- // sink.getNode().asExpr().getExpr().getLocation().getFile().getBaseName() = "sanitizers.ps1"
131
- // select sink.getNode(), source, sink, "Flow from user input to Invoke-Expression"
123
+ from TestFlow:: PathNode source , TestFlow:: PathNode sink
124
+ where
125
+ TestFlow:: flowPath ( source , sink ) and
126
+ sink .getNode ( ) .asExpr ( ) .getExpr ( ) .getLocation ( ) .getFile ( ) .getBaseName ( ) = "sanitizers.ps1"
127
+ select sink .getNode ( ) , source , sink , "Flow from user input to Invoke-Expression"
132
128
133
129
// from Function f, CmdCall c
134
130
// where f.getLocation().getFile().getBaseName() = "sanitizers.ps1"
@@ -155,15 +151,18 @@ import TestFlow::PathGraph
155
151
// and e.getLocation().getStartLine() = 14
156
152
// select e, e.getAChild(), e.getParent(), e.toString()
157
153
154
+ // from PipelineParameter p
155
+ // where p.getLocation().getFile().getBaseName() = "userinput.ps1"
156
+ // select p, p.getName(), p.getAChild()
157
+
158
+ // from Attribute a
159
+ // select a, a.getParent(), a.getParent().getAQlClass(), a.getANamedArgument()
158
160
159
- from Parameter p
160
- where p .getLocation ( ) .getFile ( ) .getBaseName ( ) = "userinput.ps1"
161
- // p.getAnAttribute().toString() = "ValueFromPipeline" and
162
161
163
- select p , p .getName ( )
164
162
165
163
// from Expr e
166
- // where e.getLocation().getFile().getBaseName() = "userinput.ps1"
164
+ // where e.getLocation().getFile().getBaseName() = "sanitizers.ps1"
165
+ // and e.getLocation().getStartLine() = 31
167
166
// select e, e.getAQlClass()
168
167
169
168
// from InvokeMemberExpr ie
0 commit comments