Skip to content

feat(pii): add evidence-bound PII waivers and skip Proton profile paths - #307

Merged
rng1995 merged 22 commits into
mainfrom
naren/port-pii-waivers-proton
Nov 5, 2026
Merged

rng1995 merged 22 commits into
mainfrom
naren/port-pii-waivers-proton

Conversation

@rng1995

@rng1995 rng1995 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two changes to the Tier 1 PII check, both about handling false positives without weakening the scan. They are in one commit; review fixes follow it as separate commits.

Proton profile paths are no longer personal paths.

  • A personal_paths match is skipped only when all of these hold:
    • It is exactly /users/steamuser/ (ASCII, any case).
    • It directly follows pfx/drive_c or pfx\drive_c, with pfx starting a path component.
    • No .. segment (plain or percent-encoded) appears anywhere later on the line. Windows folder names often contain spaces and quotes (My Games, Assassin's Creed), so the end of the path cannot be found reliably. A line with a .. segment after the profile stays reported.
    • A .. counts as a segment when a path separator (plain or percent-encoded), whitespace, a quote, a shell &, a path-list : or another delimiter bounds it on both sides. So steamuser/" + "../alice/", Path(...) / ".." / "alice", os.path.join(..., "..", "alice"), cd ../alice, cd ..&& cd alice and bin:..:/usr/bin all stay reported. & and : bound only a ..; they are not accepted before pfx. Dots inside a folder name, such as Saves..old or v1.., do not count.
  • The filter runs before _scan_lines_for_pattern picks the first match on a line. A native path such as /Users/alice/ on the same line is still reported. Before this change, the steamuser match hid it.
  • These are still reported: other user names, steamuser outside a pfx/drive_c prefix (~/.wine/drive_c/..., /Users/steamuser/, notpfx/...), lookalike characters, and C:\Users\steamuser.

--pii-waivers PATH accepts one reviewed PII value at a time.

  • The option is available on validate, tier1 / tier1 validate, and pii-scan / tier1 pii-scan. Catalog validate forwards it to each per-skill child as an absolute path without resolving symlinks, so a symlinked waiver file keeps the link's directory as the base of its entries in every child.

  • The new module validators/pii_waivers.py loads a strict version-1 YAML file through the bounded YAML loader, so chained merge expansion is rejected before it is expanded. Each waiver has exactly these fields: id, category, file, line, evidence_sha256, reason, owner, created, expires.

  • The loader rejects:

    • unknown or missing fields;
    • duplicate ids or YAML keys;
    • unknown check names;
    • credential checks (database_credentials, hardcoded_secrets, jwt_tokens, github_tokens, aws_identifiers, webhook_urls, private_keys). The message says to remove or rotate the credential;
    • absolute, .., backslash or non-normalized paths, and paths containing a control character such as NUL;
    • malformed digests or dates;
    • reasons shorter than 8 characters;
    • a created date more than one day after the UTC date, or an expires date before created or more than 366 days after it. The one-day allowance lets a reviewer east of UTC enter their local date; the 366-day cap brings every waiver up for review at least yearly.
  • file is relative to the directory that holds the waiver file (the link's directory when the waiver file is a symlink), so a waiver can only name a path under that directory.

  • Applying a waiver and judging it locate the file the same way, following symlinked directories. A waiver written as .claude/skills/foo/SKILL.md, where .claude/skills/foo links to skills/foo, applies to a scan of either path, as does skills/foo/SKILL.md.

  • One waiver file serves single-skill, folder and catalog runs. Each run judges only the waivers whose file lies in a skill or folder it scanned:

    • A run on one skill, and each child of a catalog run (serial or --workers), reports only that skill's waivers. Its siblings' waivers are not reported as stale.
    • A folder run that stops early on a CRITICAL finding does not judge the waivers of the skills it skipped.
  • A grouped PII finding whose value the report shows in full now has evidence_sha256 in its metadata: SHA-256 of category, a NUL byte, and the case-folded matched value. The waiver file stores this digest, never the value.

    • Findings whose value the report masks carry no digest. These are the credential findings that feat(ci): add reusable Tier 1 scans and GitHub onboarding #238 masks, and any other finding whose value contains a credential (for example an address that is also a quoted password). A digest of a masked password would let anyone holding the report test guesses for it offline.
    • The digest is added after redaction. Otherwise a short secret that happens to occur in the hex digest of another value would be masked inside it.
  • Waivers are matched per candidate, before the first-match-per-line choice. A waiver applies only while the check, file, line, digest and review window all match. A waived value never hides another value on the same line.

  • A waiver is consulted only for a value the scan would report. The home_paths identity check and the credit_cards Luhn check now run in the same filter pass as the IP version-literal and Proton filters. So:

    • a waiver for a value that is no longer reported shows as stale, not applied;
    • an unrelated /home/<user>/ path no longer hides a personal home path later on the same line.
  • After the scan (and after any LLM verification), each judged waiver's outcome is reported once, under the new PII_WAIVER category:

    Check Severity Blocking
    applied-pii-waiver INFO no
    stale-pii-waiver LOW no
    expired-pii-waiver MEDIUM no; the underlying finding is reported again
    invalid-pii-waiver-file HIGH yes; no waiver from the file is applied
  • PII_WAIVER findings use the same path base as the PII findings in the same report: contact.md for a single-skill run, [skill] SKILL.md in a folder run. SARIF locations therefore agree. The waiver's own file value is kept in metadata.waiver_file.

  • PII_WAIVER findings do not repeat the waiver's digest. The scan may now mask the waived value (for example, it became, or sits beside, a credential), and waiver_id and waiver_file already identify the entry.

  • On the CLI, a malformed file is a usage error (exit 2) that names the problem. This follows the --quality-config pattern. Through the Python API (SecurityValidator(pii_waiver_path=...)), it fails closed with the HIGH finding instead. Messages and file paths in reports name only the waiver file's basename.

  • Waivers are never discovered automatically inside the scanned skill; the operator passes the file with --pii-waivers. If an operator keeps it inside the scanned tree, it is PII-scanned like any other file, owners and reasons included, because it ships with the skill. The docs recommend keeping it outside. Digests, dates and paths in the file raise no findings.

  • Docs: a new "PII waivers" section in docs/tier1-validation.mdx (UTC dates, per-run scope, path base, which findings carry a digest, credential checks not waivable), a Proton note in the pii accordion, the exit-code-2 row, and the three option tables in docs/cli-reference.mdx. CHANGELOG entries under Unreleased / Added and Fixed. A comment in pii_patterns.yaml points to the Proton exemption. tests/golden/cli_surface.json is regenerated for the new option.

Why

  • Skills for Steam/Proton game tooling document save and config locations such as ~/.local/share/Steam/steamapps/compatdata/<appid>/pfx/drive_c/users/steamuser/AppData/.... These appear in Markdown, shell scripts and Python. The /Users/[^/\s]+/ pattern matched /users/steamuser/ case-insensitively, so each such skill got a blocking HIGH personal_paths finding for a name that identifies no one. The only workarounds were rewriting the paths or --llm-verify.
  • More generally, a public user who has reviewed one PII false positive had only one way to accept it: a PII.<check> severity override in a policy file. That relaxes every finding of the check, everywhere, with no expiry. A waiver covers one value at one place for a bounded time, and it stops applying visibly when the evidence changes.

Kept from public

  • Value grouping and occurrence lists. Public groups PII findings by (check, case-folded value) and lists the occurrences. Waivers plug into that model: the digest is case-folded so one digest identifies a group, and waived candidates are removed before grouping. The per-occurrence finding model was not brought back.
  • Credential redaction from feat(ci): add reusable Tier 1 scans and GitHub onboarding #238. matched_value, messages and source lines stay masked for credential categories. Masked values get no digest, and credential checks cannot be waived, so a report never holds an offline-testable stand-in for a masked secret.
  • First-match-per-line semantics and existing filters. These keep their meaning: the IP version-literal filter, the identity-based home_paths check, the Luhn check, author-email exemption and comment-line skipping. The Proton and waiver filters, and now the home_paths and Luhn checks, run as per-candidate filters before the first match is chosen.
  • PR fix: flag Windows PII usernames that start with s #95's Windows path regex (C:\\Users\\[^\\\s]+) is unchanged.
  • Usage-error validation of config files. --pii-waivers reuses the --quality-config approach: a validating click.Path type, catalog-child forwarding, and the YAML loader that rejects duplicate keys with line and column errors.
  • Scan every file. Public PII-scans every scannable file in the tree. A waiver file inside the tree is not exempted.
  • Explicit opt-in only. A waiver file is never auto-discovered from the evaluated content, so a skill cannot waive its own findings.
  • Not included: a separate candidate/classification pipeline, a JSON pii_pipeline telemetry block, detector-version pinning of waivers, and a replay corpus.
    • Public has no maintained detector version to pin. The expiry date already forces periodic review.
    • The replay corpus's distinctive negative cases (numeric and GUID shapes) belong to separate false-positive fixes. Its positive cases are already covered in test_security.py.

Notes for reviewers of open PRs

Tests

  • tests/validators/test_pii_waivers.py (new, 66 tests):
    • The finding reports the digest. A short database password that occurs in that digest's hex does not mask it, so the digest is added after redaction.
    • An exact waiver passes the scan, and the JSON report holds neither the value nor its digest. The waiver finding uses the scan's path base and keeps waiver_file.
    • The waiver goes stale when the line moves, the value changes, the file or category differs, or the waived file was deleted.
    • A waiver for a file outside the scanned target is neither applied nor judged.
    • A waived value does not hide a second value on the same line.
    • An expired waiver is reported and not applied. A waiver applies on its expires day (the UTC date is pinned).
    • created one day ahead of UTC is accepted; two days ahead, computed when the test runs, is rejected.
    • 25 invalid-file cases fail closed with a HIGH finding, and the host path does not leak. They include a NUL and a newline in file, and windows longer than 366 days. A 366-day window is accepted, and a file with chained YAML merges is rejected without expanding them.
    • A waiver whose file the OS cannot locate (an embedded NUL) is skipped, not a crash.
    • A waiver applies through a symlinked skill directory: named through the link, without it, and from a waiver file beside the link.
    • Waiver findings (applied, stale, expired) carry no digest when the waived value is masked elsewhere or has become a credential.
    • Folder runs:
      • A waiver for one skill does not cover the other, and is reported as [one] SKILL.md.
      • A run on one skill of a three-skill folder reports only that skill's waiver. A folder run reports all three.
      • A folder run stopped by a CRITICAL finding does not judge the skipped skill's waiver.
    • SARIF artifactLocation is the same for PII and PII_WAIVER results.
    • A waiver file inside the scanned tree is scanned: its owner address is reported, and its digests raise nothing.
    • A waiver for an unrelated home directory, or for a number that fails Luhn, is stale, not applied.
    • Masked values carry no digest: a database credential, and an email address that is also a quoted password.
    • Each of the 7 credential checks is rejected by the loader, even with a digest computed from the source, and the credential is still reported.
    • The waiver digest follows _reported_value.
  • tests/validators/test_security.py (28 new tests):
    • 8 Proton cases, written as .md, .sh, .py and .txt files: code spans, prose, quoted shell arguments, shell assignment, Python literal, backslash prefix, mixed case, dots inside folder names.
    • 19 controls that stay reported: native path on the same line, native macOS steamuser, notpfx, Wine prefix, other user, .. and %2e%2e%2f traversal, .. after a segment with a space (My Games) or an apostrophe, .. in string concatenation, a pathlib / chain, os.path.join, a later cd ../alice, cd ..&& cd alice (spaced and unspaced), cd ..&cd alice, a :-separated path list with a .. entry, lookalike ſ, Windows C:\Users\steamuser.
    • A personal home path after an unrelated one on the same line is reported.
  • tests/test_commands.py: for pii-scan, tier1 pii-scan, tier1 and validate:
    • The waiver applies (exit 0).
    • Without it, the run fails.
    • A malformed file exits 2 with the problem named.
    • The existing "forward every validate option" test covers catalog forwarding.
    • A three-skill catalog validate run with one shared waiver file, serial and with --workers 2, each with a plain and a symlinked waiver file: each child report holds only its own applied-pii-waiver, and catalog-summary.json has severity_totals.low == 0.
  • Without this change (on main): 10 of the 28 new test_security.py tests fail (the 8 Proton cases, the same-line native path that the steamuser match hid, and the home path behind an unrelated one; the other controls already pass), all 16 new test_commands.py tests fail, and test_pii_waivers.py cannot import its module.
  • Results:
    • At the current head (with main merged at 847bdb41): tests/validators, tests/cli, tests/golden, tests/reporting, tests/utils, tests/ci/test_secret_redaction.py, test_commands.py, test_cli.py, test_quality_config.py, test_checks_routing.py, test_oss_boundary.py, test_oss_source_hygiene.py, test_progress_output.py, test_evaluation_service.py, test_oss_packaging.py: 5471 passed, 6 skipped.
    • ruff check passes on all changed Python files. ruff format --check passes on pii_waivers.py, test_pii_waivers.py, cli.py, tier1/commands.py and tier_workflows.py. security.py, test_commands.py and test_security.py already fail it on main in unrelated places. The formatter makes the same number of changes to them before and after this change, so the new lines are formatted.
    • scripts/check_oss_boundary.py passes.
    • Gitleaks over the original PR commit: no leaks found. It was not re-run locally on the review-fix commits; the CI Gitleaks job scans them.

🤖 Generated with Claude Code

The PII scan reported Proton (Steam Play) prefix paths such as
compatdata/<appid>/pfx/drive_c/users/steamuser/ as personal macOS paths
and failed the run, although steamuser is the Windows profile name Proton
uses for every player. Personal-path matches that are exactly
pfx/drive_c/users/steamuser/, with pfx starting a path component and no
".." segment later on the line, are now skipped.

More generally, the only way to accept a reviewed PII value was a PII.*
severity override, which relaxes every finding of that check, everywhere,
with no expiry. --pii-waivers PATH on validate, tier1 and pii-scan applies
a version-1 waiver file. Each waiver names the PII check, the file
(relative to the waiver file's directory), the line, the evidence_sha256
digest that PII findings now carry, a reason, an owner and a
created/expires window, and stops applying when any of them no longer
matches. Reports list each waiver for a scanned skill as applied (INFO),
stale (LOW) or expired (MEDIUM), at the path base of the PII findings, so
one file serves single-skill, folder and catalog runs. The CLI rejects a
malformed file with exit code 2; through the API it applies no waivers
and fails the PII scan with a HIGH invalid-pii-waiver-file finding.
Waivers are never discovered automatically inside the scanned skill.

To keep the credential masking in reports intact, findings carry a digest
only for values they show unmasked, and credential checks cannot be
waived: a digest of a masked password would let anyone holding the report
test guesses for it offline.

The Proton, home-path and Luhn filters and the waiver check now drop
candidates before the first match on a line is chosen. A waiver is
therefore consulted only for a value the scan would report, and a value
that is not reported no longer hides a personal path or home path later
on the same line.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 9 findings (0 P1, 2 P2, 7 P3); 8 posted inline.

Findings outside the diff or about the description:

  • PR_DESCRIPTION: P3: Under Tests > Results, the second bullet says the 2155-test run was done "After rebasing onto the v0.7.0 release commit". That commit no longer applies here. The branch is based on a61e1f3f, which reverts the v0.7.0 release commit (#302). There is no v0.7.0 tag, CHANGELOG.md has no 0.7.0 section, and this PR's entries sit under ## Unreleased above ## 0.6.0. A reader may think the PR targets a v0.7.0 release, or that the numbers come from a different base than the one under review. I re-ran the same test set at the current head on base a61e1f3f and got 2154 passed. The PR still holds up; only the description is out of date.

Suggested fix: Drop the v0.7.0 reference. Report the result for the base the branch is actually on (a61e1f3f, or current main after an update), using the count from that run.

Comment thread src/skillevaluator/cli.py Resolved
Comment thread tests/validators/test_pii_waivers.py Resolved
Comment thread tests/validators/test_pii_waivers.py Resolved
rng1995 and others added 9 commits November 2, 2026 11:15
No conflicts.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Parallel catalog children received the waiver path after resolve(), which
follows a symlinked waiver file to its target. The loader resolves file
entries against the directory the link sits in, so each child looked under
the target's directory and silently skipped every waiver. Forward the
absolute path instead; children run in the parent's working directory.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Proton steamuser exemption only treated a .. after a path separator as
traversal, so lines that build a path with "+ \"../x\"", / ".." /,
os.path.join(..., "..", ...) or "cd ../x" were suppressed. Count a .. as a
segment whenever a separator, whitespace, a quote or another delimiter
bounds it on both sides.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A waiver file entry with an embedded NUL loaded, then crashed the scan when
its path was resolved: pii-scan exited 1 with a traceback and the Python
API raised instead of reporting an invalid waiver file. Reject control
characters in `file` and treat a path the OS refuses as unlocatable.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
matcher() compared the scanned file's resolved path, as a string, with the
waiver's literal `file`, while findings() located the waiver's file through
symlinks before judging it. A waiver written as .claude/skills/foo/SKILL.md
for a symlinked skill directory was therefore judged stale next to the very
finding it matched. Compare located paths in both places, and resolve each
waiver's path once per scan.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Applied, stale and expired waiver findings copied the waiver's
evidence_sha256 into their metadata even when the scan now masks that
value, for example because it became, or sits beside, a credential. The
report then held the offline-testable digest the masked PII finding leaves
out. waiver_id and waiver_file identify the entry; the waiver file keeps
the digest.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A short credential elsewhere in the skill can occur inside the hex digest
of an unrelated value. The digest is added after metadata redaction so it
stays usable in a waiver; no test failed when the two steps were swapped.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The matcher applies a waiver through `expires` and findings() reports it as
expired only after that day, but no test used the expiry day itself, so the
two comparisons could drift apart unnoticed. The test pins the UTC date.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The created-in-future case used a date computed at collection time. A run
that crosses 00:00 UTC between collection and the test left it only one day
ahead, which the loader accepts, so the case failed. Compute the date from
the loader's clock inside the test.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the loader, the matcher, the new Proton pattern and the CLI change. The symlink handling, the control-character check in file, the digest handling in waiver findings and the Proton .. guard all look right, and the waiver and Proton tests pass. Nothing blocks; two non-blocking points on YAML loading and the expiry window are inline.

rng1995 and others added 6 commits November 3, 2026 09:31
Conflicts: src/skillevaluator/tier_workflows.py, src/skillevaluator/validators/security.py.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…days

Load waiver files with load_bounded_yaml so chained merge expansion is
rejected up front instead of stalling argument parsing, keeping the
line/column message for plain syntax errors. Reject an expires date more
than 366 days after created so a waiver cannot be permanent. Tests build
their waiver dates relative to today so the cap cannot drift into a failure.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
The earlier merge of main placed the Proton profile and unrelated home
path entries under the Security subsection that main added at the end of
Unreleased. Move both into the existing Fixed subsection, blank-line
separated, and leave Security with main's entries only.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
`cd pfx/drive_c/users/steamuser/ && cd ..&& cd alice` and the unspaced
`&&cd ..&&cd alice` form were still suppressed, because `&` did not bound
a `..` segment. Accept shell `&` and path-list `:` as `..` boundaries
without adding them to the characters that may precede `pfx`, and pin
four more stay-reported cases.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nto naren/port-pii-waivers-proton

No conflicts.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ntry

ruff format folds the new window-too-long case onto one line, and the
waiver entry under Unreleased Added is rewrapped to the file's line width
after the 366-day window wording was added.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up on the current head. Waiver files now load through load_bounded_yaml. The chained-merge file I used before is rejected at once instead of stalling, also with a duplicate key added, and the fallback keeps the line and column for plain syntax errors. expires more than 366 days after created is rejected. The & and : boundaries for a Proton .. segment look right. Nothing further from me.

rng1995 and others added 5 commits November 5, 2026 22:35
Keep this branch's PII waiver plumbing (--pii-waivers, pii_waiver_path,
Proton profile skip) alongside main's SkillSpector baseline plumbing
(skillspector_baseline) in run_validation, run_tier1_workflow, and
SecurityValidator. The PII line scan filters matches with main's
_is_card_number_candidate before applying waivers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Pick up the Tier 2 contained directory alias fix (#282); no conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Pick up the PII timestamp, matrix, and vector false-positive fix (#304);
no conflicts. Its numeric filters run before the waiver filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Resolve the src/skillevaluator/cli.py and docs/cli-reference.mdx
conflicts: keep this PR's new --pii-waivers option and add main's reworded
--profile help (#334, default profile with external as a compatibility
alias) after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 enabled auto-merge (squash) November 5, 2026 20:40
@rng1995
rng1995 merged commit 27645cd into main Nov 5, 2026
22 checks passed
@rng1995
rng1995 deleted the naren/port-pii-waivers-proton branch November 5, 2026 21:23
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.

3 participants