fix(ea1): bound wildcard-grant pattern to a single line and a standalone '*' - #438
Closed
rootkiller6788 wants to merge 1 commit into
Closed
fix(ea1): bound wildcard-grant pattern to a single line and a standalone '*'#438rootkiller6788 wants to merge 1 commit into
rootkiller6788 wants to merge 1 commit into
Conversation
…one '*' The EA1 wildcard-tool-access regex used \s* between the colon and the expected value. Python's \s matches newlines even under re.MULTILINE, so the pattern bridged blank lines (e.g. "For each tool:\n\n**Input Schema:**") and treated the first '*' of markdown bold as a wildcard grant, producing EA1/MEDIUM false positives on otherwise benign skills. Constrain the gap to [ \t]* (same line) and require the matched '*' not to be followed by another '*' or a word character, so tools: "*", [*] and '*' still match while bold text and word-adjacent '*' do not. Fixes NVIDIA#405 Signed-off-by: rootkiller6788 <c8688rickowens@outlook.com>
Collaborator
|
Closing as a duplicate: the identical production change already landed on Comparison against #417:
Thanks for the contribution and the clear write-up regardless — the explanatory comment above the regex was a nice touch, and the underlying analysis matches what was merged. Remaining gaps in this pattern (footnote-legend false positive, YAML block-list / JSON quoted-key wildcard grants) are being tracked in follow-up issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #405. The EA1 wildcard-tool-access pattern
r"(?:tools?|permissions?)\s*:\s*\[?\s*['\"]?\*['\"]?\s*\]?"used
\s*between the colon and the expected*value. Python's\smatches newlines regardless ofre.MULTILINE, so the pattern could span a blank line and bridge two unrelated headings (For each tool:\n\n**Input Schema:**-> matched texttool:\n\n*), and it treated the first*of a markdown bold span (**API Coverage vs. Workflow Tools:**->Tools:*) as a wildcard grant. Both surfaced as EA1/MEDIUM false positives on benign skills.Fix
[ \t]*instead of\s*).*to be a standalone token: add(?!\*|\w)so markdown bold (**) and word-adjacent*(e.g. a YAML anchor like*ref) no longer match.r"(?:tools?|permissions?)\s*:[ \t]*\[?[ \t]*['\"]?\*(?!\*|\w)['\"]?[ \t]*\]?"Genuine single-line wildcard grants still match:
tools: "*",tools: [*],permissions: '*',tool:*.Tests
tools: *andpermissions: '*'to the existing EA1-positive parametrization intests/unit/test_patterns_new.py.TestExcessiveAgency::test_ea1_no_false_positive_on_markdown_bold_or_headingcovering the cross-heading bridge, bold-markdown collision, and a bolded list of specific named tools.Verified:
pytest tests/unit/test_patterns_new.py(368 passed) andpytest tests/nodes/analyzers/test_static_patterns.py(151 passed);ruff checkandruff format --checkclean.