fix(scanner): distinguish Python inference methods from dynamic eval - #2805
fix(scanner): distinguish Python inference methods from dynamic eval#2805reshuibuduo wants to merge 2 commits into
Conversation
|
PR author is not in the allowed authors list. |
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
PR Summary by QodoDistinguish Python inference
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe scanner now uses Python AST analysis to distinguish dynamic ChangesPython eval detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Python scanning now avoids flagging no-argument inference methods while retaining detection of dynamic eval patterns and existing non-Python behavior. No concrete merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant Scanner
participant PythonParser as ast.parse
participant AST as Python AST
participant TextCheck as EVAL_RE
Scanner->>PythonParser: Parse Python content
PythonParser-->>Scanner: Return AST
Scanner->>AST: Inspect bindings and eval calls
PythonParser-->>Scanner: Raise parser error
Scanner->>TextCheck: Apply conservative text detection
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can keep summaries lean with Finding overflow, which tucks the rest behind 'View more' |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Summary
Fix
DANGEROUS_DYNAMIC_EXECUTIONfalse positives for Python no-argument inference methods without changing JavaScript/TypeScript detection or the rule's high severity.Reproduction
The existing
\beval\s*\(search reports all of these as dynamic code execution:PyTorch documents
Module.eval()as switching a module into evaluation mode. It takes no code argument. Python's builtineval(source, ...)has different semantics.This was reproduced with published
plugin-scanner==3.0.94and upstream maincf617e7b7a4c2d26344dc083e1745f802f4b3be4. The first regression run against unchanged main produced 20 failures / 70 passes, covering both the reported false positives and previously missed builtin aliases/parenthesized calls.Changes and security boundary
builtins.eval/__builtins__.evalconservative, including imported aliases and references used by partial application..eval(...)receivers flagged whenever positional, keyword,*args, or**kwargsarguments are supplied.new Function, severity, scoring, exclusions, repository-policy trust, dependencies and Cisco integration unchanged.This is a bounded heuristic, not Python type inference or a guarantee that every arbitrary method implementation is safe. Comments and ordinary Python string literals no longer masquerade as calls.
Validation
tests/test_code_quality.py.git diff --check: passed.HARDCODED_SECRETfindings across 15 synthetic test fixtures reported under two ecosystems. The command correctly exits 1. This is a local experiment using the patched source, not an official Action run.Commands:
Full-suite attempt on Windows stops during collection because
tests/guard_daemon_acceptance_fixtures.pyimports the Unix-onlyresourcemodule. Fullruff check src testsreports 10 existing issues in unchanged tests; full formatting check reports 42 unchanged files. These unrelated files were left alone. The Linux full matrix remains for upstream CI. The current upstream Actions runs areaction_requiredand await maintainer approval.Downstream context: TMCRA Codex release PR. Its release remains a draft pending the official scanner gate; separate synthetic test-credential findings are outside this fix. This PR does not claim that the complete marketplace scan is passing.
Summary by CodeRabbit
Bug Fixes
evaldetection to distinguish dynamic code execution from safe no-argument methods such asModule.eval()..eval(...)calls with arguments.Documentation
evaldetection behavior and its heuristic limitations in the README.