Skip to content

feat(reach): unified --exclude-paths, deprecate --reach-exclude-paths#227

Merged
Martin Torp (mtorp) merged 1 commit into
mainfrom
martin/reach-exclude-paths
Jun 3, 2026
Merged

feat(reach): unified --exclude-paths, deprecate --reach-exclude-paths#227
Martin Torp (mtorp) merged 1 commit into
mainfrom
martin/reach-exclude-paths

Conversation

@mtorp
Copy link
Copy Markdown
Contributor

@mtorp Martin Torp (mtorp) commented Jun 3, 2026

Adds the unified --exclude-paths flag for Node CLI parity. Follows #226 (the reachability flag/env/retry alignment, now merged to main); this PR targets main directly and contains only the --exclude-paths work.

Changes

  • New --exclude-paths (comma-separated globs) that filters both SCA manifest discovery and reachability analysis.
  • Matcher (Core static methods): anchored micromatch-style globs compiled to regex — no new dependency. Scan-root-relative POSIX paths, case-sensitive, * does not cross /, ** does; each pattern P expanded to [P, P/**]. Threaded into find_files via cli_config; strict no-op when the flag is unset, so existing scans are unchanged.
  • Reach side unions --exclude-paths with the now-deprecated --reach-exclude-paths and forwards verbatim to coana --exclude-dirs (correct because coana's target . == cwd == scan root).
  • Validation mirrors Node's assertValidExcludePaths: rejects negation (!), absolute paths, .. traversal, and degenerate match-everything (trailing slash stripped first, so **/ is rejected too). Accepts both comma-separated strings and --config-file lists (a config-file list is normalized and validated, not bypassed).
  • --reach-exclude-paths soft-deprecated: still works, marked [DEPRECATED] in --help, warns at runtime, unions into --exclude-dirs. (Flip to hidden in a later minor release.)

Parity

Matcher verified against the Node exclude-paths.mts source. Pinned the exact parity cases as tests, e.g.:

  • tests excludes tests/pkg/package.json but keeps src/tests/package.json (root-anchored)
  • package-lock.json matches root only, not packages/a/package-lock.json (no basename match)
  • src/*.json excludes src/a.json but keeps src/sub/a.json (* doesn't cross /)
  • **/node_modules matches at any depth (globstar)

Known edge (documented, not fixed)

With multiple --sub-path targets, find_files anchors patterns per-subpath, whereas Node anchors all to a single scan-root cwd. Cannot affect the reach flow (single-target). Noted in a code comment.

Testing

  • Full suite green: 323 passed, 2 skipped.
  • New test_exclude_paths.py: matcher semantics, Node parity cases, validation (incl. **/ rejection and --config-file list/string/validation paths), and find_files integration.

Rebased onto main after #226 merged; single commit, version 2.4.3.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.4.3.dev6

Docker image: socketdev/cli:pr-227

@mtorp Martin Torp (mtorp) force-pushed the martin/reach-exclude-paths branch from b513478 to e8f54ba Compare June 3, 2026 12:41
@mtorp Martin Torp (mtorp) force-pushed the martin/reach-flag-parity branch from f59f6f2 to eb17457 Compare June 3, 2026 13:04
@mtorp Martin Torp (mtorp) force-pushed the martin/reach-exclude-paths branch from e8f54ba to f67f91a Compare June 3, 2026 13:07
@mtorp Martin Torp (mtorp) force-pushed the martin/reach-flag-parity branch from eb17457 to e4d642d Compare June 3, 2026 13:24
@mtorp Martin Torp (mtorp) force-pushed the martin/reach-exclude-paths branch from f67f91a to a279f97 Compare June 3, 2026 13:25
@mtorp Martin Torp (mtorp) changed the base branch from martin/reach-flag-parity to main June 3, 2026 14:10
@mtorp Martin Torp (mtorp) force-pushed the martin/reach-exclude-paths branch from a279f97 to a46a3e6 Compare June 3, 2026 14:10
…aths

Add a single --exclude-paths flag (Node CLI parity) that filters BOTH SCA manifest
discovery and reachability analysis:

- New Core matcher: anchored micromatch-style globs compiled to regex (no new deps).
  Scan-root-relative POSIX paths, '*' does not cross '/', '**' does, each pattern P
  expanded to [P, P/**]. Threaded into find_files via cli_config; no-op when unset.
- Reach side unions --exclude-paths with the now-deprecated --reach-exclude-paths and
  forwards to coana --exclude-dirs.
- Validation mirrors Node's assertValidExcludePaths (rejects negation, absolute paths,
  '..' traversal, degenerate match-everything; trailing slash stripped so '**/' is rejected).
  Accepts comma-strings and config-file lists.
- --reach-exclude-paths soft-deprecated: still works, [DEPRECATED] in help, warns at runtime.

Docs: document --exclude-paths under 'Path and File' (it affects every scan, not just
reach), mark --reach-exclude-paths deprecated, and refresh the reachability flag table
(--reach-analysis-timeout/-memory-limit primary names, --reach-debug,
--reach-disable-external-tool-checks, defaults delegated to coana).

Adds a CHANGELOG 2.4.3 entry and tests incl. the Node parity cases, validation, and config-file paths.
@mtorp Martin Torp (mtorp) merged commit 80741b7 into main Jun 3, 2026
23 of 24 checks passed
Martin Torp (mtorp) added a commit that referenced this pull request Jun 3, 2026
Layered on top of the v2.4.3 --exclude-paths work (#227). Fixes the
reachability-reference items #227 left:

- Document the uv + Enterprise-plan prerequisites the CLI enforces before
  running reachability (exit 3), and that per-ecosystem build toolchains are
  the analysis engine's runtime check, not a CLI pre-check.
- Correct --reach-min-severity values to info/low/moderate/high/critical.
- Document --reach-enable-analysis-splitting, --reach-detailed-analysis-log-file,
  --reach-lazy-mode, --reach-use-only-pregenerated-sboms.
- Clarify --only-facts-file submits only the facts file when creating the full
  scan (no pre-existing scan required).
- Note --reach creates a tier-1 full-application scan (scan_type=socket_tier1).

Docs-only; the 2.4.3->2.4.4 bump + uv.lock are mandated by the sync-version hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants