feat(scan): per-target excluded paths, left out of the whole scan #825

Merged
sharang merged 1 commits from feat/target-exclude-paths into main 2026-11-04 08:48:41 +00:00
Owner

The second half of dogfood item 1 (t66), after #820.

What

Each target can name directories and files to leave out of every scan stage: scan_config.exclude_paths. This comes on top of the test data the scan detects itself. What is left out produces no code findings, no SBOM components and no CVEs.

  • Rules. normalise_exclude_paths in compliance-core: paths are relative and /-separated, a directory includes everything under it (the same prefix rule as vendor code and test data), and there are no wildcards. It trims, drops ./ and a trailing /, dedupes, and refuses:

    • absolute paths;
    • .., . and .git;
    • wildcards;
    • more than 256 characters, or more than 50 entries.
  • API. PATCH /api/v1/targets/{id} with {"scan_config": {"exclude_paths": [...]}} replaces the stored list. Validation runs while the body is read, so an invalid path gets axum's 422 with a message naming the entry. Leaving the field out keeps the stored list.

  • Scan. The configured paths are pruned first; test data is then detected in what is left. prune now:

    • removes files as well as directories;
    • refuses any path that passes a symbolic link (src/link/x with src/link pointing outside the tree), since these paths come from users.

    The run gets a note (stage excluded_paths, SkipCode::ExcludedPaths) that also lists configured paths not found in the tree.

  • Findings stored in an excluded path close as ScanChangeKind::NowExcluded, with their own issue comment.

  • Dashboard. The target editor has a "Von der Prüfung ausgenommen" box (one path per line). It is checked with the same core function, with the reason shown in DE or EN, and Save stays disabled while a path is invalid.

  • Docs. guide/repositories (Leaving Paths out of the Scan) and guide/scanning.

Tests

  • Unit:
    • normalisation and refusals (exclude_paths.rs);
    • PATCH body parsing, the 422 reason, and the stored list kept when the field is left out (target_input.rs);
    • pruning a file and a directory, a missing path, and a path through a symlink (test_data.rs).
  • Integration (tests/resolve_findings.rs, Mongo): a stale finding under an excluded path closes as NowExcluded.
  • Built and tested by CI only.

🤖 Generated with Claude Code

The second half of dogfood item 1 (t66), after #820. ## What Each target can name directories and files to leave out of every scan stage: `scan_config.exclude_paths`. This comes on top of the test data the scan detects itself. What is left out produces no code findings, no SBOM components and no CVEs. - **Rules.** `normalise_exclude_paths` in compliance-core: paths are relative and `/`-separated, a directory includes everything under it (the same prefix rule as vendor code and test data), and there are no wildcards. It trims, drops `./` and a trailing `/`, dedupes, and refuses: - absolute paths; - `..`, `.` and `.git`; - wildcards; - more than 256 characters, or more than 50 entries. - **API.** `PATCH /api/v1/targets/{id}` with `{"scan_config": {"exclude_paths": [...]}}` replaces the stored list. Validation runs while the body is read, so an invalid path gets axum's 422 with a message naming the entry. Leaving the field out keeps the stored list. - **Scan.** The configured paths are pruned first; test data is then detected in what is left. `prune` now: - removes files as well as directories; - refuses any path that passes a symbolic link (`src/link/x` with `src/link` pointing outside the tree), since these paths come from users. The run gets a note (stage `excluded_paths`, `SkipCode::ExcludedPaths`) that also lists configured paths not found in the tree. - **Findings** stored in an excluded path close as `ScanChangeKind::NowExcluded`, with their own issue comment. - **Dashboard.** The target editor has a "Von der Prüfung ausgenommen" box (one path per line). It is checked with the same core function, with the reason shown in DE or EN, and Save stays disabled while a path is invalid. - **Docs.** `guide/repositories` (Leaving Paths out of the Scan) and `guide/scanning`. ## Tests - Unit: - normalisation and refusals (`exclude_paths.rs`); - PATCH body parsing, the 422 reason, and the stored list kept when the field is left out (`target_input.rs`); - pruning a file and a directory, a missing path, and a path through a symlink (`test_data.rs`). - Integration (`tests/resolve_findings.rs`, Mongo): a stale finding under an excluded path closes as `NowExcluded`. - Built and tested by CI only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-04 08:30:35 +00:00
feat(scan): per-target excluded paths, left out of the whole scan
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 3m39s
CI / Check (pull_request) Successful in 17m39s
f01ccdf893
A target's settings can now name directories and files to leave out of
every scan stage (scan_config.exclude_paths), on top of the test data
the scan detects itself (#820): no code findings, no SBOM components, no
CVEs.

- Paths are relative to the tree, /-separated, without wildcards; a
  directory is left out with everything in it. normalise_exclude_paths
  (compliance-core) trims, normalises and refuses absolute paths, ..,
  .git, wildcards, over-long paths and more than 50 entries. The API
  applies it while reading the PATCH body, so an invalid path is
  refused with 422 and a message naming it; the dashboard editor uses
  the same function and shows the reason in German or English.
- The scan prunes the configured paths first, then detects test data in
  what is left. prune now removes files as well as directories, and
  never a path that passes a symbolic link (src/link/x with src/link
  pointing elsewhere is left alone).
- The run notes what was left out (SkipCode::ExcludedPaths, stage
  excluded_paths), including configured paths not found in the tree.
- Findings an earlier scan stored there close as NowExcluded, with their
  own issue comment.
- Dashboard: "Von der Prüfung ausgenommen" in the target editor, one
  path per line. Docs: guide/repositories and guide/scanning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 8ede373353 into main 2026-11-04 08:48:41 +00:00
Sign in to join this conversation.