Skip to content

Commit 3acbd83

Browse files
committed
PS: Drive-by fix: The variable access in a foreach loop implicitly writes to the variable.
1 parent 4d04b11 commit 3acbd83

File tree

1 file changed

+12
-0
lines changed
  • powershell/ql/lib/semmle/code/powershell/ast/internal

1 file changed

+12
-0
lines changed

powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,3 +904,15 @@ private module PipelineAccess {
904904
}
905905
}
906906
}
907+
908+
private module ImplicitAssignmentInForEach {
909+
private class ForEachAssignment extends Synthesis {
910+
override predicate implicitAssignment(Raw::Ast dest, string name) {
911+
exists(Raw::ForEachStmt forEach, Raw::VarAccess va |
912+
va = forEach.getVarAccess() and
913+
va = dest and
914+
va.getUserPath() = name
915+
)
916+
}
917+
}
918+
}

0 commit comments

Comments
 (0)