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 {
2222 * A data flow sink for SQL-injection vulnerabilities.
2323 */
2424 abstract class Sink extends DataFlow:: Node {
25+ /** Gets a description of this sink. */
2526 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 ( ) }
2633 }
2734
2835 /**
@@ -45,10 +52,19 @@ module SqlInjection {
4552 not call .hasNamedArgument ( "query" ) and
4653 not call .hasNamedArgument ( "inputfile" ) and
4754 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 ( ) )
4859 )
4960 }
5061
5162 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+ }
5268 }
5369
5470 class ConnectionStringWriteSink extends Sink {
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ private module Config implements DataFlow::ConfigSig {
1818 predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
1919
2020 predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
21+
22+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet cs ) {
23+ node .( Sink ) .allowImplicitRead ( cs )
24+ }
2125}
2226
2327/**
You can’t perform that action at this time.
0 commit comments