From 80939b08790e0de870e8a5014b95f4fdfe5ae961 Mon Sep 17 00:00:00 2001 From: yoff Date: Thu, 3 Sep 2026 13:20:16 +0200 Subject: [PATCH] Python: prefilter directly controlled SSA uses Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 03758eab-d713-4ffb-87bd-64ceb863dd3b --- .../ModificationOfParameterWithDefaultCustomizations.qll | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/ql/src/semmle/python/functions/ModificationOfParameterWithDefaultCustomizations.qll b/python/ql/src/semmle/python/functions/ModificationOfParameterWithDefaultCustomizations.qll index 3513a24ec04f..5ef49f5b6af0 100644 --- a/python/ql/src/semmle/python/functions/ModificationOfParameterWithDefaultCustomizations.qll +++ b/python/ql/src/semmle/python/functions/ModificationOfParameterWithDefaultCustomizations.qll @@ -143,6 +143,12 @@ module ModificationOfParameterWithDefault { } } + private predicate directlyControlledUse( + DataFlow::GuardNode guard, Cfg::NameNode use, boolean branch + ) { + guard != use and guard.controlsBlock(use.getBasicBlock(), branch) + } + /** Holds if `barrier` is a use guarded by a direct truthiness check on `branch`. */ private predicate directGuardedUse(DataFlow::ExprNode barrier, boolean branch) { exists( @@ -150,10 +156,9 @@ module ModificationOfParameterWithDefault { Cfg::NameNode use | checked = guard and + directlyControlledUse(guard, use, branch) and SsaImpl::AdjacentUses::useOfDef(def, checked) and SsaImpl::AdjacentUses::useOfDef(def, use) and - checked != use and - guard.controlsBlock(use.getBasicBlock(), branch) and barrier.asCfgNode() = use ) }