From 9781ee8d662fabc7577297767007cc5fd6ba81d8 Mon Sep 17 00:00:00 2001 From: Copilot Date: Tue, 5 May 2026 15:26:20 +0000 Subject: [PATCH] Python: adapt to new shared CFG signature Main added two new requirements to AstSig: - A 'Parameter' class with a 'getDefaultValue()' method, plus a 'callableGetParameter(Callable, int)' predicate. - A 'CallableContext' class in InputSig1, replacing the previous 'CallableBodyPartContext'. Add stub implementations: 'Parameter' is empty (none()) and 'callableGetParameter' returns nothing, mirroring Java's TODO. Rename 'CallableBodyPartContext = Void' to 'CallableContext = Void' in the Python Input module. NewCfg evaluation-order tests still pass at the 22/24 baseline; all 11 shared-CFG consistency queries still report 0 violations on CPython. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../python/controlflow/internal/AstNodeImpl.qll | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll index 86fdf45e0ba..fab2d1cd2e5 100644 --- a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll +++ b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll @@ -165,6 +165,20 @@ module Ast implements AstSig { /** Gets the body of callable `c`. */ AstNode callableGetBody(Callable c) { result = TBlockStmt(c.asScope(), "body") } + /** + * A parameter of a callable. + * + * TODO: Implement in order to include parameters in the CFG. + */ + class Parameter extends AstNode { + Parameter() { none() } + + Expr getDefaultValue() { none() } + } + + /** Gets the `index`th parameter of callable `c`. */ + Parameter callableGetParameter(Callable c, int index) { none() } + /** A statement. */ class Stmt extends AstNode { Stmt() { this instanceof TStmt or this instanceof TBlockStmt } @@ -1119,7 +1133,7 @@ private module Input implements InputSig1, InputSig2 { string toString() { result = "label" } } - class CallableBodyPartContext = Void; + class CallableContext = Void; predicate inConditionalContext(Ast::AstNode n, ConditionKind kind) { kind.isBoolean() and