From 3acbd832979b4e48cbdea8bfb71e10399b92c90e Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Thu, 3 Apr 2025 18:37:30 +0100 Subject: [PATCH] PS: Drive-by fix: The variable access in a foreach loop implicitly writes to the variable. --- .../code/powershell/ast/internal/Synthesis.qll | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll b/powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll index 0b7b6afb2cb..2fee3dd99d6 100644 --- a/powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll +++ b/powershell/ql/lib/semmle/code/powershell/ast/internal/Synthesis.qll @@ -904,3 +904,15 @@ private module PipelineAccess { } } } + +private module ImplicitAssignmentInForEach { + private class ForEachAssignment extends Synthesis { + override predicate implicitAssignment(Raw::Ast dest, string name) { + exists(Raw::ForEachStmt forEach, Raw::VarAccess va | + va = forEach.getVarAccess() and + va = dest and + va.getUserPath() = name + ) + } + } +}