fix(mcp): treat allowed-tools as a permission declaration for LP3
Fixes #15.
While reading the MCP least-privilege path I confirmed the reported false positive. LP3 flags standard-compliant skills, and the cause is a field-name mismatch between SkillSpector and the Agent Skills standard.
What this fixes
LP3 ("no declared permissions but code capabilities were detected") fired on skills that declare capabilities through allowed-tools, the field defined by the Agent Skills standard. Two things combined to cause it:
_parse_manifestonly extractedpermissionsand droppedallowed-tools, so the field never reached the analyzer.mcp_least_privilegeonly readpermissions, so a skill declaring e.g.allowed-tools: [Bash, Read]was treated as having no declaration at all.
_parse_manifest now parses and preserves allowed-tools (both the list form [Bash, Read] and the comma-separated string form Bash, Read), and LP3 treats a non-empty allowed-tools as a valid declaration. LP1/LP4 continue to use the explicit permissions list only, so this change stays scoped to the LP3 false positive in the issue.
Scanning a skill that declares allowed-tools: [Bash, Read] with shell/file-read code no longer reports LP3.
Testing
ruff check src/ tests/andruff format --check src/ tests/pass.pytest -m 'not integration'passes (605 passed, 11 skipped). The integration suite needs an LLM endpoint and is unaffected.- Added regression tests:
allowed-toolsparsing in build_context (list, comma-string, and malformed-value forms) and LP3 not firing whenallowed-toolsis declared. The existing "no declaration" test still asserts LP3 fires.
Thanks for the thorough review — the asymmetry you flagged is real and the suggested fix was the right call.
_TOOL_TO_CAPABILITY now maps Agent Skills tool names (Bash, Read, Write, WebFetch, etc.) to capability categories, and _map_allowed_tools_to_categories() converts the declared tool list into a category set. The LP1 guard was expanded to has_declaration = (permissions present) OR (allowed_tools non-empty), with both sources unioned into declared_categories before the coverage loop runs. LP4 also gets a (permissions or []) guard to prevent a TypeError when only allowed-tools is set.
Two regression tests added to TestLP3AllowedTools:
allowed-tools: [Read]+ shell code → LP3 suppressed, LP1 fires HIGH forshellallowed-tools: [Bash]+ shell-only code → no LP1
All 14 tests pass. Ready for re-review.