Skip to content

Commit 5a715c7

Browse files
committed
PS: Flow through string interpolation.
1 parent d5d3712 commit 5a715c7

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

powershell/ql/lib/semmle/code/powershell/controlflow/CfgNodes.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,22 @@ module ExprNodes {
565565

566566
final ExprCfgNode getAnOperand() { e.hasCfgChild(this.getExpr().getAnOperand(), this, result) }
567567
}
568+
569+
class ExpandableStringChildMappinig extends ExprChildMapping, ExpandableStringExpr {
570+
override predicate relevantChild(Ast n) { n = this.getAnExpr() }
571+
}
572+
573+
class ExpandableStringCfgNode extends ExprCfgNode {
574+
override string getAPrimaryQlClass() { result = "ExpandableStringCfgNode" }
575+
576+
override ExpandableStringChildMappinig e;
577+
578+
override ExpandableStringExpr getExpr() { result = e }
579+
580+
ExprCfgNode getExpr(int i) { e.hasCfgChild(e.getExpr(i), this, result) }
581+
582+
ExprCfgNode getAnExpr() { result = this.getExpr(_) }
583+
}
568584
}
569585

570586
module StmtNodes {

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPublic.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ class CallNode extends AstNode {
469469

470470
/** A call to operator `&`, viwed as a node in a data flow graph. */
471471
class CallOperatorNode extends CallNode {
472-
CallOperatorNode() { this.getCallNode() instanceof CfgNodes::StmtNodes::CallOperatorCfgNode }
472+
override CfgNodes::StmtNodes::CallOperatorCfgNode call;
473+
474+
Node getCommand() { result.asExpr() = call.getCommand() }
473475
}
474476

475477
/** A use of a type name, viewed as a node in a data flow graph. */

powershell/ql/lib/semmle/code/powershell/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ private module Cached {
3434
cached
3535
predicate defaultAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo, string model) {
3636
(
37+
// Flow from an operand to an operation
3738
exists(CfgNodes::ExprNodes::OperationCfgNode op |
3839
op = nodeTo.asExpr() and
3940
op.getAnOperand() = nodeFrom.asExpr()
4041
)
4142
or
43+
// Flow through string interpolation
44+
exists(CfgNodes::ExprNodes::ExpandableStringCfgNode es |
45+
nodeFrom.asExpr() = es.getAnExpr() and
46+
nodeTo.asExpr() = es
47+
)
48+
or
4249
// Although flow through collections is modeled precisely using stores/reads, we still
4350
// allow flow out of a _tainted_ collection. This is needed in order to support taint-
4451
// tracking configurations where the source is a collection.

0 commit comments

Comments
 (0)