Skip to content

feat(ci): sensitive data pre-commit check with Accounts.xlsx detection - #137

Merged
ndomako10 merged 10 commits into
masterfrom
feat/87-sensitive-data-precommit
Mar 22, 2026
Merged

feat(ci): sensitive data pre-commit check with Accounts.xlsx detection#137
ndomako10 merged 10 commits into
masterfrom
feat/87-sensitive-data-precommit

Conversation

@ndomako10

@ndomako10 ndomako10 commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a sensitive data check to the pre-commit hook that scans staged files for personal or financial data before it reaches the remote. Motivated by ADR-009 being committed with real institution names and account numbers.

Closes #87

Changes

  • Scripts/hooks/Invoke-SensitiveDataCheck.ps1 — two pure, unit-testable functions: Invoke-SensitiveDataCheck (pattern scan with # nocheck suppression and per-pattern allowlists) and Get-AccountsLast4 (reads Last4 values from Accounts.xlsx via ZIP/XML, no COM)
  • Scripts/hooks/Invoke-PreCommitCheck.ps1 — loads static patterns from Config\SensitivePatterns.json (falls back to template), builds dynamic Last4 patterns from Accounts.xlsx at hook runtime, runs sensitive check on every staged file alongside ASCII and lint
  • Config/Templates/SensitivePatterns.template.json — three default patterns (account numbers in payment context, credential assignments, email addresses) plus a keyword-search placeholder entry for institution names and personal identifiers
  • Scripts/Initialize-SyncReceipts.ps1 — copies template to Config\SensitivePatterns.json on first run, consistent with other config files
  • Docs/ADRs/ADR-012-sensitive-data-pre-commit-hook.md — documents the four key design decisions
  • CHANGELOG.md, CONTRIBUTING.md, README.md, CLAUDE.md updated

Checklist

  • Invoke-Pester Tests/ -Output Detailed passes with no failures (177/177)
  • PSScriptAnalyzer reports no Error or Warning violations on changed .ps1 files
  • No non-ASCII characters in changed .ps1 files
  • Commit messages follow Conventional Commits format
  • CHANGELOG.md updated
  • Documentation updated (README, CONTRIBUTING, CLAUDE.md, ADR-012)

ndomako added 5 commits March 22, 2026 03:09
…pre-commit hook

Adds Invoke-SensitiveDataCheck.ps1 with two pure, unit-testable functions:
- Invoke-SensitiveDataCheck: scans staged file content against configurable
  patterns; suppresses matches on lines ending with '# nocheck' or containing
  an allowlist entry; filters by file extension
- Get-AccountsLast4: reads Last4 identifiers from Accounts.xlsx via ZIP/XML
  (no COM) so real account numbers are available as dynamic patterns at hook
  runtime

Invoke-PreCommitCheck.ps1 is updated to load SensitivePatterns.json (falling
back to the template), build dynamic Last4 patterns from Accounts.xlsx, and
run the sensitive data check on every staged file alongside ASCII and lint.

closes #87
Adds the committed template with three default patterns (account numbers in
payment method context, credential assignments, and email addresses). Users
copy this to Config\SensitivePatterns.json to customise patterns and allowlists
without modifying the template.

Config\SensitivePatterns.json is gitignored alongside the other personal
config files.

refs #87
Updates the hook table to include the sensitive data scan, and adds a new
'Sensitive Data Patterns' section explaining the three default checks,
the Accounts.xlsx Last4 detection, how to customise patterns via
Config\SensitivePatterns.json, and how to suppress false positives with
allowlist entries or '# nocheck'.

refs #87
@github-actions github-actions Bot added documentation Improvements or additions to documentation test Test additions or changes setup Setup and hook installer changes config Config, .vscode, launcher changes labels Mar 22, 2026
ndomako added 5 commits March 22, 2026 10:14
Provides a placeholder pattern entry that users duplicate and customise
to flag institution names, personal identifiers, or any project-specific
term with a simple word-boundary regex.

fileTypes excludes .json by default so the template does not self-match
when staged; users can add .json in their local SensitivePatterns.json.

refs #87
… setup

Initialize-SyncReceipts.ps1 now copies SensitivePatterns.template.json to
Config\SensitivePatterns.json on first run (skipped if already present),
consistent with the pattern used for Accounts.xlsx, Categories.json, and
Methods.json.

Updates CONTRIBUTING.md to reflect that the file is created by setup rather
than copied manually.

refs #87
Documents the non-obvious design decisions: separate pure script for
testability, ZIP/XML over COM for Accounts.xlsx reading, dynamic Last4
patterns, and '# nocheck' suppression token.

Also updates CLAUDE.md and README.md architecture diagrams to include
SensitivePatterns.json, SensitivePatterns.template.json, and
Invoke-SensitiveDataCheck.ps1, and corrects the pre-commit description.

Redacts example account numbers in README.md filename examples to 'xxxx'
so the pre-commit hook does not flag documentation.

refs #87
Replaces 'xxxx' placeholders with realistic fake numbers (3621, 7890)
so examples illustrate the full filename format. Checking and Savings
examples share the same number to show one account across methods.

Adds 3621 and 7890 to the account-number-in-context allowlist in the
template so the README does not self-trigger the pre-commit hook.
The dynamic Accounts.xlsx check still catches these numbers if they
happen to match a real Last4.

refs #87
@ndomako10
ndomako10 merged commit ee092a6 into master Mar 22, 2026
3 checks passed
@ndomako10
ndomako10 deleted the feat/87-sensitive-data-precommit branch March 22, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Config, .vscode, launcher changes documentation Improvements or additions to documentation setup Setup and hook installer changes test Test additions or changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pre-commit hook to detect personal or sensitive data in staged files

2 participants