|
| 1 | +--- |
| 2 | +title: Ratcheting Mode |
| 3 | +description: Use ratcheting to adopt CVE Lite CLI as a hard CI gate on codebases with existing vulnerability debt. |
| 4 | +--- |
| 5 | + |
| 6 | +# Ratcheting Mode |
| 7 | + |
| 8 | +When adopting CVE Lite CLI as a hard CI gate on a codebase that already has vulnerabilities, `--fail-on` will block every PR until all pre-existing issues are resolved. That is rarely realistic on a production codebase. |
| 9 | + |
| 10 | +Ratcheting lets you accept the current state and only fail on findings introduced above that baseline. Existing vulnerabilities are tracked but do not block - they get cleaned up gradually. Once you fix one, the baseline drops and can never go back up. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Setup |
| 15 | + |
| 16 | +Run once locally to snapshot the current findings: |
| 17 | + |
| 18 | +```bash |
| 19 | +cve-lite . --ratchet |
| 20 | +``` |
| 21 | + |
| 22 | +This creates `.cve-lite/baseline.json` in your project root and exits 0. Commit the file so your whole team and CI share the same baseline. |
| 23 | + |
| 24 | +```bash |
| 25 | +git add .cve-lite/baseline.json |
| 26 | +git commit -m "chore: establish vulnerability baseline" |
| 27 | +``` |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## How it works in CI |
| 32 | + |
| 33 | +No flag changes needed. Once the baseline file exists, every scan automatically suppresses known findings: |
| 34 | + |
| 35 | +```bash |
| 36 | +cve-lite . --fail-on high |
| 37 | +``` |
| 38 | + |
| 39 | +Pre-existing findings are hidden. Only new findings - things introduced above the baseline - trigger failure. Your existing CI commands work exactly as before. |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Output |
| 44 | + |
| 45 | +When all findings are suppressed: |
| 46 | + |
| 47 | +``` |
| 48 | +✓ Scan complete. No known vulnerabilities found. |
| 49 | +
|
| 50 | +No new findings above baseline - 7 existing findings suppressed |
| 51 | +``` |
| 52 | + |
| 53 | +When new findings appear: |
| 54 | + |
| 55 | +``` |
| 56 | +3 new findings above baseline - 7 existing findings suppressed |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Updating the baseline |
| 62 | + |
| 63 | +After fixing some vulnerabilities, reset the baseline by running `--ratchet` again: |
| 64 | + |
| 65 | +```bash |
| 66 | +cve-lite . --ratchet |
| 67 | +git add .cve-lite/baseline.json |
| 68 | +git commit -m "chore: update vulnerability baseline" |
| 69 | +``` |
| 70 | + |
| 71 | +Because the baseline is committed to git, every update is tracked and reversible. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Ignoring the baseline |
| 76 | + |
| 77 | +To run a full scan without suppression, delete or rename `.cve-lite/baseline.json`. No flag needed. The file's presence is what activates ratcheting. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## How matching works |
| 82 | + |
| 83 | +A finding is suppressed if every advisory ID on that `name@version` combination was present when the baseline was saved. If a package gains a new advisory ID not in the baseline, that finding surfaces as new - even if the package version itself was already baselined. |
| 84 | + |
| 85 | +This means: |
| 86 | +- Same package, same version, same advisory - suppressed |
| 87 | +- Same package, same version, new advisory - surfaces as new |
| 88 | +- New package not in baseline at all - surfaces as new |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## See also |
| 93 | + |
| 94 | +- [Workflow Integration](workflow-integration) - pre-commit hooks and GitHub Actions setup |
| 95 | +- [How Remediation Works](how-remediation-works) - how fix commands are generated |
| 96 | +- [CLI Reference](cli-reference) - full flag documentation |
0 commit comments