Skip to content

fix(redaction): mask lowercase SIDs, and let the fixture scanner ask the masker - #562

Merged
adamgell merged 1 commit into
mainfrom
fix/547-redaction-sid-case-and-scanner
Aug 12, 2026
Merged

fix(redaction): mask lowercase SIDs, and let the fixture scanner ask the masker#562
adamgell merged 1 commit into
mainfrom
fix/547-redaction-sid-case-and-scanner

Conversation

@adamgell

@adamgell adamgell commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Closes #547.

Two defects from the issue, plus a third the first fix surfaced.

The owner grammar was case-sensitive for SIDs only

sid_re was the one pattern in redaction.rs without (?i) — the profile-path, inline-credential, account-field, device-name and tenant-id rules all have it. So s-1-5-21-... exported verbatim while the uppercase form masked. Windows emits uppercase, but third-party logs and JSON round-trips do not.

The fixture privacy scanner restated the shape instead of asking the grammar

It now calls a shared sid_occurrences. This matters more than the duplication suggests: it is the guard that fails the build when a fixture carries an unmasked SID, so any divergence from what the masker matches is a hole in the safety net — and a hole there is invisible by construction, because the check whose job is catching a leak is the one place a mismatch goes unnoticed.

The issue's diagnosis of this one was not quite right, so recording what the divergence actually was. The dash threshold is equivalent to the grammar's sub-authority count; S-1-5-21-1010 was found by both. Measured against the grammar:

input masker old scanner
S-1-5-21-1010 masks finds agree — the issue's example was not a hole
s-1-5-21-... missed missed both blind (defect 1)
S-1-5-21-1010- masks misses real hole: candidate had to end in a digit
userS-1-5-21-1010 no match finds scanner stricter; harmless

Re-ran the full corpus against the tightened scanner. Nothing newly fails, so no committed fixture was hiding a SID behind either hole — which was the check the issue asked for.

A third defect the first fix exposed

Making the rule case-insensitive made the lowercase form mask — to a different token. The token is hashed from the matched text, so two spellings of one SID produced two tokens. That defeats the correlation a stable token exists to provide: an analyst following one account across a bundle would see it as two identities. The hash is now taken from the uppercase form.

Verification

Mutation-checked rather than assumed:

  • dropping (?i) → 3 tests fail
  • hashing the text as written → 1 test fails

Parser suite, clippy -D warnings, wasm32, and the src-tauri suite all clean.

Note on scope

Three files, no formatting churn. cargo fmt --all reflows ~20 unrelated files in this repo because no CI job enforces formatting, so only the edited lines are here.

Next in the cluster: #549 (ESP export never calls its own projection) and #556 (DsRegCmd has no projection at all), both of which want the ADR-004 boundary ruling in #550 first.

Summary by CodeRabbit

  • Bug Fixes
    • Windows security identifiers (SIDs) are now recognized regardless of letter casing.
    • Equivalent SID spellings produce consistent redaction tokens.
    • SID detection is now consistent across redaction and privacy scanning.
  • Tests
    • Added coverage for lowercase SIDs, consistent token generation, and matching scanner behavior.

…the masker

Two defects from #547, plus a third the first fix surfaced.

The owner grammar's SID rule was the only pattern in the file without `(?i)`,
so `s-1-5-21-...` exported verbatim while the uppercase form masked. Windows
emits uppercase, but third-party logs and JSON round-trips do not, and nothing
in the code or the docs records the inconsistency as deliberate.

The fixture privacy scanner restated the SID shape a third time instead of
asking the grammar; it now calls a shared sid_occurrences. That matters more
than the duplication suggests. It is the guard that fails the build when a
fixture carries an unmasked SID, so a divergence from what the masker matches
is a hole in the safety net, and a hole there is invisible by construction.

The issue's diagnosis of that scanner was not quite right, so recording what
the divergence actually was. Its dash threshold is equivalent to the grammar's
sub-authority count, and S-1-5-21-1010 was found by both. Measured, the two
real holes were case, and the candidate having to end in a digit:
S-1-5-21-1010- passed the scan while the masker masked it.

Re-ran the full corpus against the tightened scanner. Nothing newly fails, so
no committed fixture was hiding a SID behind either hole.

Making the rule case-insensitive then exposed a third defect. The token is
hashed from the matched text, so the two spellings of one SID produced two
different tokens, defeating the correlation a stable token exists to provide:
an analyst following one account across a bundle would see it as two. The hash
is taken from the uppercase form.

Mutation-checked: dropping (?i) fails three tests, hashing the text as written
fails one.

Closes #547.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 11, 2026 20:26
@github-actions github-actions Bot added bug Something isn't working enhancement New feature or request labels Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b2b82d1-bdb8-49bc-a95e-a0947120f3de

📥 Commits

Reviewing files that changed from the base of the PR and between 42d154d and ac56ca2.

📒 Files selected for processing (3)
  • crates/cmtraceopen-parser/src/intune/apps/windows/common/mod.rs
  • crates/cmtraceopen-parser/src/intune/apps/windows/common/redaction.rs
  • crates/cmtraceopen-parser/tests/support/mod.rs

📝 Walkthrough

Walkthrough

The shared Windows SID matcher now handles case-insensitive identifiers and normalizes matched text before hashing. A public occurrence helper is re-exported and used by the fixture privacy scanner. Tests verify masking and scanning consistency.

Changes

SID detection and privacy scanning

Layer / File(s) Summary
Shared SID matcher and masking behavior
crates/cmtraceopen-parser/src/intune/apps/windows/common/redaction.rs, crates/cmtraceopen-parser/src/intune/apps/windows/common/mod.rs
SID matching is case-insensitive. Matched text is uppercased before hashing. The public sid_occurrences helper is re-exported. Tests cover lowercase SIDs, shared tokens, and matching boundaries.
Fixture scanner integration
crates/cmtraceopen-parser/tests/support/mod.rs
The fixture privacy scanner uses sid_occurrences and preserves its (offset, String) output shape.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: intune, parser, test, windows, apps

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits and accurately describes the SID redaction and fixture scanner changes.
Linked Issues check ✅ Passed The changes satisfy issue #547 by adding case-insensitive SID masking, canonical token hashing, and shared SID detection for fixture scanning.
Out of Scope Changes check ✅ Passed The changes remain within issue #547 and support SID redaction consistency and fixture privacy scanning.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/547-redaction-sid-case-and-scanner

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added apps App management related intune Microsoft Intune related parser Log parser related test Testing related windows Windows platform related labels Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes SID redaction consistency in the shared Intune Windows redaction grammar, and tightens the test fixture privacy scanner by reusing the same SID matcher as the masker.

Changes:

  • Make the SID regex case-insensitive so lowercase s-1-... SIDs are masked.
  • Ensure SID stable tokens are derived from a canonical (uppercase) representation so different casings correlate to the same token.
  • Update the fixture privacy scanner to delegate SID detection to the shared grammar (sid_occurrences) instead of re-implementing SID shape logic.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/cmtraceopen-parser/tests/support/mod.rs Fixture privacy scan now uses the shared SID matcher to avoid drift from the masker.
crates/cmtraceopen-parser/src/intune/apps/windows/common/redaction.rs SID masking is now case-insensitive; adds sid_occurrences; canonicalizes SID hashing and adds tests.
crates/cmtraceopen-parser/src/intune/apps/windows/common/mod.rs Re-exports sid_occurrences for reuse.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +364 to +368
// Hashed from the uppercase form. A SID is case-insensitive, so the
// two spellings name one identity and must reach one token; hashing
// the text as written would hand an analyst two tokens for the same
// account and break the correlation these tokens exist to provide.
stable_token("sid", &caps[0].to_ascii_uppercase())
@adamgell
adamgell merged commit 60b7b7f into main Aug 12, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps App management related bug Something isn't working enhancement New feature or request intune Microsoft Intune related parser Log parser related test Testing related windows Windows platform related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redaction: SID masking is case-sensitive in the owner grammar, and the fixture privacy scanner has the same short-SID blind spot

2 participants