Repository navigation
Conversation
eeee2345
left a comment
There was a problem hiding this comment.
@dc-tw thanks, this covers the directory half of #575. I reproduced the false clean on main (a .cursor/mcp.json with a NODE_OPTIONS --require payload next to a SKILL.md comes back with 0 threats) and the PR fixes it. Typecheck is clean and the CLI suites pass, plus the advisory, tool-definition-scope and enforcement suites. Symlink loops terminate, .git and node_modules are skipped, an empty dir and an all-skipped dir both exit 1, and an oversized SKILL.md now exits 1 instead of reporting one clean skill as main does.
Two things before merge, both because this scans repositories we do not control:
- The walker reads entries that are not regular files inside the scanned tree. A committed
SKILL.mdormcp.jsonthat is a symlink to something outside the root, or to/dev/zero, a FIFO or/proc/self/environ, is followed and read, which can hang or exhaust the CI job or pull outside content into the report. SincereaddirSync(..., { withFileTypes: true })gives lstat semantics, checkingentry.isFile()first and counting symlinks and other non-regular entries as skipped (with a warning) would close it; a test with a symlink pointing outside the root would pin it. - Skipped files do not reach SARIF.
--jsonreportsfiles_skipped, but the SARIF that the Action and the Security tab consume has nothing, and the run exits 0, so an MCP config that was not parsed shows up as clean. OnetoolExecutionNotificationsentry per skipped file (level warning, with the reason) inruns[0].invocations[0]would make it visible.
For a follow-up rather than this PR: a tools/list document or an event log inside the directory is skipped without any message, and .vscode/mcp.json uses a servers key, so it is recognized by name but skipped as not a config. We'll note the scan_type: "directory" JSON shape in the changelog.
|
@dc-tw thanks. A follow-up to the earlier review: I ran the branch against a few more directory shapes and found things I should have caught in the first pass. I am sending them now, before your next push, so everything can go in one round. Besides the two earlier points, item 1 is the only one I would hold the merge on; 2 is mostly tests for behaviour you already implemented, and 3 is optional.
Not for this PR: when the scanned directory is outside the current working directory, toArtifactUri (src/converters/sarif.ts:77-85) reduces each path to its basename, so with several SKILL.md files every SARIF result points at "SKILL.md". That predates this change and the Action runs from the repository root, but directory mode makes it the common case, so it may be worth its own issue. |
Summary
readFileSyncSKILL.mdfiles and recognized MCP config files (.mcp.json,mcp.json,mcp-config.json, andclaude_desktop_config.json).gitandnode_modules, retain the existing per-file size limits, and report skipped config filesThis fixes the directory portion of #575. In particular, the Action's default
atr scan . --sarifcan now inspect both nested MCP configs and skills instead of choosing one input type for the whole directory or passing the directory toreadFileSync.It does not change
action.yml; the independent scan-exit handling is covered by #743. It also leaves all single-file MCP config, event-log, tools/list, and skill behavior unchanged.Refs #575
Validation
npm run typechecknpm run buildnpm run validate— 844/844 rulesnpm test -- --maxWorkers=4— 153 files passed, 2 skipped; 2,608 tests passed, 14 skippedgit diff --check