Skip to content

feat(cli): --disable-rule flag in scan and ci commands#716

Merged
shivasurya merged 2 commits into
mainfrom
shiva/disable-rule-flag
May 23, 2026
Merged

feat(cli): --disable-rule flag in scan and ci commands#716
shivasurya merged 2 commits into
mainfrom
shiva/disable-rule-flag

Conversation

@shivasurya
Copy link
Copy Markdown
Owner

Summary

Adds a repeatable --disable-rule <id> flag to both pathfinder scan and pathfinder ci that drops the named rules from the loader before execution. Mirrors the --exclude flag added in PR #690 in shape, validation, and wiring.

Unblocks the rule-registry feature (spec: cpf-dashboard@b748501). cpf-executor will populate the flag from per-org / per-repo overrides resolved server-side.

Validation

validateDisableRules rejects rule IDs outside [A-Za-z0-9_-]{1,64}. Strict on purpose: cpf-executor will pass these as argv elements built from a D1 lookup, and the charset stops shell metacharacters or path-traversal patterns from sneaking through even if the API layer regresses.

Empty and duplicate entries are silently dropped (matches the --exclude convention).

Test plan

  • Table-driven validator unit test (11 cases): empty, single, multiple, dedup, trim, drop-empty, too-long, invalid chars, path-like, newline, null byte.
  • go build ./..., go test ./... (31 packages): clean.
  • Smoke: pathfinder scan -p sast-engine/test/fixtures/vulnerable_project --rules sast-engine/test/fixtures/rules/simple.py produces a TEST-001 finding. Adding --disable-rule TEST-001 reduces the rule set to zero and pathfinder correctly emits no rules loaded (proves the filter actually ran before the rule-count gate).

Pure validator for the upcoming --disable-rule flag. Mirrors the
validateExcludePatterns pattern: trims whitespace, drops empties, dedups,
rejects anything outside [A-Za-z0-9_-]{1,64}. The strict charset stops
downstream callers (cpf-executor populating argv from a D1 lookup) from
smuggling shell metacharacters or path-traversal patterns.
Repeatable CLI flag that drops matching rule IDs from the rule loader
before execution. Validated via validateDisableRules (strict charset,
dedup, length cap). Mirrors --exclude in shape, validation, and wiring.

Smoke: scan + --disable-rule SAST-CMD-001 against a positive fixture
returns no findings for that rule, others still fire.
@shivasurya shivasurya added enhancement New feature or request go Pull requests that update go code labels May 23, 2026
@shivasurya shivasurya self-assigned this May 23, 2026
@safedep
Copy link
Copy Markdown

safedep Bot commented May 23, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@code-pathfinder
Copy link
Copy Markdown

Pathfinder Report

No security findings on the changed files. This pull request is clean.

View report on the dashboard


Powered by Code Pathfinder.

@shivasurya shivasurya merged commit 460d0d3 into main May 23, 2026
5 checks passed
@shivasurya shivasurya deleted the shiva/disable-rule-flag branch May 23, 2026 16:40
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 42.85714% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (7a21c89) to head (9aeec45).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sast-engine/cmd/ci.go 15.78% 14 Missing and 2 partials ⚠️
sast-engine/cmd/scan.go 15.78% 15 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #716      +/-   ##
==========================================
- Coverage   85.56%   85.48%   -0.09%     
==========================================
  Files         191      192       +1     
  Lines       27467    27523      +56     
==========================================
+ Hits        23503    23527      +24     
- Misses       3075     3104      +29     
- Partials      889      892       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant