Skip to content

Commit 627ee85

Browse files
committed
PS: Port changes from github#20132 to PowerShell.
1 parent c6ab941 commit 627ee85

File tree

1 file changed

+14
-5
lines changed
  • powershell/ql/lib/semmle/code/powershell/dataflow/internal

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ private module Cached {
185185
cached // nothing is actually cached
186186
module BarrierGuard<guardChecksSig/3 guardChecks> {
187187
private predicate guardChecksAdjTypes(
188-
DataFlowIntegrationInput::Guard g, DataFlowIntegrationInput::Expr e, boolean branch
188+
DataFlowIntegrationInput::Guard g, DataFlowIntegrationInput::Expr e,
189+
DataFlowIntegrationInput::GuardValue branch
189190
) {
190191
guardChecks(g, e.asExprCfgNode(), branch)
191192
}
@@ -283,6 +284,8 @@ class ParameterExt extends TParameterExt {
283284
}
284285

285286
private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInputSig {
287+
private import codeql.util.Boolean
288+
286289
private newtype TExpr =
287290
TExprCfgNode(Cfg::CfgNodes::ExprCfgNode e) or
288291
TFinalEnvVarRead(Scope scope, EnvVariable v) {
@@ -330,21 +333,27 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
330333
any(ParameterExt p).isInitializedBy(def) or def.(Ssa::WriteDefinition).assigns(_)
331334
}
332335

336+
class GuardValue = Boolean;
337+
333338
class Guard extends Cfg::CfgNodes::AstCfgNode {
334339
/**
335340
* Holds if the control flow branching from `bb1` is dependent on this guard,
336341
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
337342
* guard to `branch`.
338343
*/
339-
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
340-
this.hasBranchEdge(bb1, bb2, branch)
344+
predicate valueControlsBranchEdge(
345+
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue branch
346+
) {
347+
this.hasValueBranchEdge(bb1, bb2, branch)
341348
}
342349

343350
/**
344351
* Holds if the evaluation of this guard to `branch` corresponds to the edge
345352
* from `bb1` to `bb2`.
346353
*/
347-
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
354+
predicate hasValueBranchEdge(
355+
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue branch
356+
) {
348357
exists(Cfg::SuccessorTypes::ConditionalSuccessor s |
349358
this.getBasicBlock() = bb1 and
350359
bb2 = bb1.getASuccessor(s) and
@@ -354,7 +363,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
354363
}
355364

356365
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
357-
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
366+
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, GuardValue branch) {
358367
none()
359368
}
360369
}

0 commit comments

Comments
 (0)