Skip to content

chore: remove dead code and finish the incomplete fixes - #89

Draft
pixincreate wants to merge 1 commit into
fix/scan-mode-consistencyfrom
chore/cleanup
Draft

chore: remove dead code and finish the incomplete fixes#89
pixincreate wants to merge 1 commit into
fix/scan-mode-consistencyfrom
chore/cleanup

Conversation

@pixincreate

Copy link
Copy Markdown
Owner

Stacked on #88.

Summary

Dead code, duplicated work, and two fixes from earlier PRs that only covered part of their surface.

Changes

  • Dead public API removed: Shell::as_str, OutputFormat::as_str, ExitMode::as_str and KeywatchConfig::load had zero call sites in src/ or tests/.
  • Baseline::load ran twice per --update-baseline — once to filter, once to update — reparsing the same JSON.
  • is_baseline_file did a realpath(2) on every scanned file now that baseline discovery is the default. It compares file names first, so only real candidates pay for the syscall.
  • The broken-pipe fix was incomplete: it covered only the scan summary, so key-watch hook install pre-commit | head and key-watch init bash | head still panicked. The writer moved to utils and every command uses it.
  • Baselines could only grow. update_with_findings appends, and findings are filtered against the baseline before the update, so entries for deleted files and rotated credentials suppressed forever — meaning the update-baseline workflow could only ever produce additive diffs. New --prune-baseline rebuilds from what the scan actually found.

Tests

187 pass. New: --prune-baseline drops an entry for a deleted file while a plain --update-baseline keeps it.

Shell::as_str, OutputFormat::as_str, ExitMode::as_str and
KeywatchConfig::load had no call sites anywhere in src/ or tests/.

--update-baseline loaded and parsed the same baseline file twice per
run, once to filter and once to update.

is_baseline_file ran realpath(2) on every scanned file now that baseline
discovery is the default; it compares file names first, so only
candidates that could possibly be the baseline pay for the syscall.

The broken-pipe fix only covered the scan summary, so 'hook install |
head' and 'init | head' still panicked. The writer moved to utils and is
used by every command.

update_with_findings only ever appends, so entries for deleted files and
rotated credentials suppressed findings forever, and the update-baseline
workflow could only produce additive diffs. --prune-baseline rebuilds
from what the scan actually found.
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.

1 participant