fix(analyzer): stop EA1 from matching multiline gaps and markdown bold spans - #414
fix(analyzer): stop EA1 from matching multiline gaps and markdown bold spans#414AmirF194 wants to merge 1 commit into
Conversation
…d spans Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]\n\nApproved. The horizontal-whitespace boundary and wildcard lookahead close the EA1 false positives without hiding real wildcard declarations, and the regression coverage is adequate. This overlaps PR #417, so maintainers should merge only the preferred implementation. Current required checks pass.
|
[SkillSpector Maintainer] Closing this PR as superseded by #417, which is now merged. The production change here is technically correct and identical to the merged regex fix: replacing newline-matching whitespace after the EA1 key with horizontal whitespace and requiring the wildcard asterisk to be standalone. We selected #417 because its focused regression suite additionally covers the single-newline boundary, the unquoted This PR was opened first and independently identified both root causes. Thank you @AmirF194 for the accurate diagnosis, sound implementation, and validation work. |
Fixes #405.
Root cause
EA1_PATTERNS[0]instatic_patterns_excessive_agency.pyis(?:tools?|permissions?)\s*:\s*\[?\s*['"]?\*['"]?\s*\]?. Python's\smatchesnewlines regardless of
re.MULTILINE, so the gap the pattern allows between thecolon and the wildcard value is unbounded across blank lines and paragraphs, and
the pattern has no check that the matched
*is a standalone token rather than thefirst
*of a**bold**span. Two shapes both produce a false-positive EA1finding on prose that grants no tool access: a blank-line gap (
tool:\n\n**Input Schema:**) and a markdown bold heading (**API Coverage vs. Workflow Tools:**).Fix
Replace the pattern with
(?:tools?|permissions?)\s*:[ \t]*\[?[ \t]*['"]?\*(?!\*|\w)['"]?[ \t]*\]?:restricts the gap to spaces/tabs (no longer crosses a blank line) and adds a
negative lookahead so the matched
*cannot be followed by another*or a wordcharacter, so it can no longer be the first character of a bold span or an
identifier. The three real wildcard-grant shapes (
tools: "*",tools: [*],permissions: '*') still match.Verification
tests/nodes/analyzers/test_static_patterns.py: the twofalse-positive shapes from the issue no longer produce an EA1 finding, and the
three real wildcard shapes still produce EA1 at MEDIUM severity.
make lintandmake format-checkclean.python:3.12-slimcontainer: 2800 passed (2795existing + 5 new), 14 skipped, 4 xfailed, matching the repo's
test-unitgate.Under
--cov(thetest-cirecipe), two unrelated tests intest_security_end_to_end.pyfail; reproduced the same two failures 3/3 runsagainst unmodified
mainunder the same--covflag, so this is a pre-existingflake independent of this change, not a regression it introduces.
docker-smoke(image build plustests/docker/smoke.sh) passes.