File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
powershell/ql/lib/semmle/code/powershell/security Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,14 @@ module SqlInjection {
22
22
* A data flow sink for SQL-injection vulnerabilities.
23
23
*/
24
24
abstract class Sink extends DataFlow:: Node {
25
+ /** Gets a description of this sink. */
25
26
abstract string getSinkType ( ) ;
27
+
28
+ /**
29
+ * Holds if this sink should allow for an implicit read of `cs` when
30
+ * reached.
31
+ */
32
+ predicate allowImplicitRead ( DataFlow:: ContentSet cs ) { none ( ) }
26
33
}
27
34
28
35
/**
@@ -45,10 +52,19 @@ module SqlInjection {
45
52
not call .hasNamedArgument ( "query" ) and
46
53
not call .hasNamedArgument ( "inputfile" ) and
47
54
this = call .getArgument ( 0 )
55
+ or
56
+ // TODO: Here we really should pick a splat argument, but we don't yet extract whether an
57
+ // argument is a splat argument.
58
+ this = unique( | | call .getAnArgument ( ) )
48
59
)
49
60
}
50
61
51
62
override string getSinkType ( ) { result = "call to Invoke-Sqlcmd" }
63
+
64
+ override predicate allowImplicitRead ( DataFlow:: ContentSet cs ) {
65
+ cs .getAStoreContent ( ) .( DataFlow:: Content:: KnownKeyContent ) .getIndex ( ) .asString ( ) .toLowerCase ( ) =
66
+ [ "query" , "inputfile" ]
67
+ }
52
68
}
53
69
54
70
class ConnectionStringWriteSink extends Sink {
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ private module Config implements DataFlow::ConfigSig {
18
18
predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
19
19
20
20
predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
21
+
22
+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet cs ) {
23
+ node .( Sink ) .allowImplicitRead ( cs )
24
+ }
21
25
}
22
26
23
27
/**
You can’t perform that action at this time.
0 commit comments