File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed
powershell/ql/lib/semmle/code/powershell Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ class CallOperator extends CmdCall {
83
83
class DotSourcingOperator extends CmdCall {
84
84
DotSourcingOperator ( ) { getRawAst ( this ) instanceof Raw:: DotSourcingOperator }
85
85
86
- Expr getPath ( ) { result = this .getCallee ( ) }
86
+ Expr getCommand ( ) { result = this .getCallee ( ) }
87
87
}
88
88
89
89
class JoinPath extends CmdCall {
Original file line number Diff line number Diff line change @@ -608,6 +608,21 @@ module ExprNodes {
608
608
ExprCfgNode getCommand ( ) { result = this .getCallee ( ) }
609
609
}
610
610
611
+ private class DotSourcingOperatorChildMapping extends CallExprChildMapping instanceof DotSourcingOperator
612
+ {
613
+ override predicate relevantChild ( Ast child ) { super .relevantChild ( child ) }
614
+ }
615
+
616
+ class DotSourcingOperatorCfgNode extends CallExprCfgNode {
617
+ override string getAPrimaryQlClass ( ) { result = "DotSourcingOperatorCfgNode" }
618
+
619
+ override DotSourcingOperatorChildMapping e ;
620
+
621
+ override DotSourcingOperator getExpr ( ) { result = e }
622
+
623
+ ExprCfgNode getCommand ( ) { result = this .getCallee ( ) }
624
+ }
625
+
611
626
private class ToStringCallChildmapping extends CallExprChildMapping instanceof ToStringCall {
612
627
override predicate relevantChild ( Ast child ) { super .relevantChild ( child ) }
613
628
}
Original file line number Diff line number Diff line change @@ -544,7 +544,14 @@ class CallNode extends ExprNode {
544
544
class CallOperatorNode extends CallNode {
545
545
override CfgNodes:: ExprNodes:: CallOperatorCfgNode call ;
546
546
547
- Node getCommand ( ) { result .asExpr ( ) = call .getCommand ( ) } // TODO: Alternatively, we could remap calls to & as command expressions.
547
+ Node getCommand ( ) { result .asExpr ( ) = call .getCommand ( ) }
548
+ }
549
+
550
+ /** A call to operator `.`, viewed as a node in a data flow graph. */
551
+ class DotSourcingOperatorNode extends CallNode {
552
+ override CfgNodes:: ExprNodes:: DotSourcingOperatorCfgNode call ;
553
+
554
+ Node getCommand ( ) { result .asExpr ( ) = call .getCommand ( ) }
548
555
}
549
556
550
557
/**
Original file line number Diff line number Diff line change @@ -46,8 +46,10 @@ module CommandInjection {
46
46
call .getAnArgument ( ) = this
47
47
)
48
48
or
49
- // Or the call command itself in case it's a use of operator &.
49
+ // Or the call command itself in case it's a use of " operator &" or "operator ." .
50
50
any ( DataFlow:: CallOperatorNode call ) .getCommand ( ) = this
51
+ or
52
+ any ( DataFlow:: DotSourcingOperatorNode call ) .getCommand ( ) = this
51
53
}
52
54
53
55
override string getSinkType ( ) { result = "call to Invoke-Expression" }
You can’t perform that action at this time.
0 commit comments