Skip to content

fix(ea1): bound wildcard-grant pattern to a single line and a standalone '*' - #438

Closed
rootkiller6788 wants to merge 1 commit into
NVIDIA:mainfrom
rootkiller6788:fix-ea1-wildcard-pattern-regex
Closed

fix(ea1): bound wildcard-grant pattern to a single line and a standalone '*'#438
rootkiller6788 wants to merge 1 commit into
NVIDIA:mainfrom
rootkiller6788:fix-ea1-wildcard-pattern-regex

Conversation

@rootkiller6788

Copy link
Copy Markdown

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 \s matches newlines regardless of re.MULTILINE, so the pattern could span a blank line and bridge two unrelated headings (For each tool:\n\n**Input Schema:** -> matched text tool:\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

  • Constrain the gap between the colon and the value to the same line ([ \t]* instead of \s*).
  • Require the matched * 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

  • Added tools: * and permissions: '*' to the existing EA1-positive parametrization in tests/unit/test_patterns_new.py.
  • Added TestExcessiveAgency::test_ea1_no_false_positive_on_markdown_bold_or_heading covering 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) and pytest tests/nodes/analyzers/test_static_patterns.py (151 passed); ruff check and ruff format --check clean.

…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>
@yashrajp22

Copy link
Copy Markdown
Collaborator

Closing as a duplicate: the identical production change already landed on main via #417 (fix(ea1): bound wildcard-tool-access match to a single line and a standalone asterisk, merged 2026-08-24), two days before this PR was opened — which is why this branch now shows merge conflicts.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants