Skip to content

fix(fix): add --exclude-paths so socket fix can skip unreadable directories#1339

Open
Martin Torp (mtorp) wants to merge 4 commits into
v1.xfrom
martin/socket-fix-eacess-and-exclude-paths-debu
Open

fix(fix): add --exclude-paths so socket fix can skip unreadable directories#1339
Martin Torp (mtorp) wants to merge 4 commits into
v1.xfrom
martin/socket-fix-eacess-and-exclude-paths-debu

Conversation

@mtorp
Copy link
Copy Markdown
Contributor

@mtorp Martin Torp (mtorp) commented May 28, 2026

Summary

socket fix crashes when its manifest-discovery walk hits an unreadable directory (e.g. a postgres pgdata owned by another uid inside a backend repo):

✖ Unexpected error: EACCES: permission denied, scandir '/home/mark/.../data/postgres/pgdata'

The existing --exclude flag is only consulted for workspace filtering at fix-application time inside coana — it never reaches the manifest-discovery walk, so users have no way to skip the problem directory.

Change

Add --exclude-paths to socket fix, mirroring socket scan create's validation and pattern handling. The value is applied in both stages of the pipeline:

  • Manifest discovery: expanded via excludePathToScanIgnores and passed to getPackageFilesForScan as additionalIgnores, so the offending paths never enter the upload tar.
  • Fix application: merged onto the existing --exclude array forwarded to coana, so any workspace that did slip through is still skipped during fix application.

Validated via assertValidExcludePaths (rejects negation, absolute paths, .., degenerate sentinels) before any network call.

The pre-existing --exclude flag keeps its previous narrower (fix-application only) semantic for back-compat, but is hidden from --help in favor of --exclude-paths.

Release: 1.1.109.

Test plan

  • New unit tests in handle-fix-limit.test.mts cover both wirings: populated/empty excludePathsadditionalIgnores, and merged forwarding to coana's --exclude (legacy entries first, then --exclude-paths entries).
  • --help snapshot updated in cmd-fix.integration.test.mts--exclude removed, --exclude-paths added.
  • pnpm check:tsc clean; vitest run src/commands/fix/handle-fix-limit.test.mts — 12/12 pass.
  • Manually built dist/ and confirmed the new flag is documented, the hidden --exclude still parses, and --exclude-paths '\!negation' is rejected with a clear error.

socket fix walks the project tree to collect manifest files before
uploading them to the API. That walk runs through fast-glob which throws
on the first unreadable subdirectory:

  EACCES: permission denied, scandir '/home/user/proj/data/postgres/pgdata'

A postgres data dir owned by another uid, an unreadable Docker volume
mount, or any other directory the running user can't enter would
crash 'socket fix' before coana is even invoked. The existing --exclude
flag is forwarded to coana for workspace-level filtering but never
threaded into the manifest discovery walk, so users had no way to skip
problem directories.

Mirror the --exclude-paths shape already used by 'socket scan create'
(same validation, same anchored micromatch semantics, same ignore
expansion) and pass it to getPackageFilesForScan as additionalIgnores.
Make --exclude-paths the canonical path-exclusion flag on socket fix:
its value is now also forwarded to coana's --exclude alongside the
existing --exclude entries, so a matched path is skipped consistently
across manifest upload and fix application.

Hide the legacy --exclude flag in --help. Its narrower fix-application
only semantic is preserved unchanged so existing scripts that rely on
'detect vulnerabilities everywhere, only write fixes outside the
excluded workspace' continue to work — but new users land on
--exclude-paths.
@mtorp Martin Torp (mtorp) marked this pull request as ready for review May 28, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants