feat: add stdlib git/CI PHI scanner - #20
Merged
Merged
Conversation
Move the clinic scan_phi.py gate into openadapt_privacy.scan. scan_tree and self_test are the import surface; openadapt-privacy-scan is the CLI. The [scan] extra is empty. Importing the module does not load Presidio, spaCy, or Pillow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The clinic git PHI scanner now lives here as
openadapt_privacy.scan.clinic-node and clinic-workflows each had a copy of
scripts/scan_phi.py. Those copies were already identical.rg kirillis empty on both HEADs, and this change doesn't putkirill_back. Clinic wrappers importscan_tree(root) -> list[str](same hit lines as today) andself_test() -> int, which plants fixtures under/tmpand returns 1 if a rule stays silent.I almost left the package
__init__importingbaseandloadersat import time. That would have madeimport openadapt_privacy.scanpull Pillow, which is the thing clinic is trying not to drag in when it writespip install 'openadapt-privacy[scan]'. Existing re-exports are lazy now.from openadapt_privacy import scrub_dictstill works. Scan is not in__all__.[scan]is an empty extra. Clinic can writepip install 'openadapt-privacy[scan]'and mean the git gate. A second package for 200 lines of regex would have been the wrong split. The scanner is stdlib. Matching OHIP examples are concatenated at runtime so this tree doesn't itself fail the gate.CLI is
openadapt-privacy-scanandpython -m openadapt_privacy.scan. Default scans cwd. Pass--root PATHor--self-test. Forbidden dirs are stillrecordings,captures,screenshots,retinology,.private. Suffixes still include.rdp,.db, and the media set.gitleaks.tomlandphi-patterns.txtship next to the module.A git regex gate doesn't belong behind the Presidio caveat. That "synthetic, not clinical" note stays on the scrubber, where the evidence is still synthetic. This extra is a CI gate. If a rule goes blind,
self_testis supposed to go red; the tests monkeypatch a rule to prove it.Opened by an agent session, not the founder.