Skip to content

fix(captures): redact normalized HAR numeric values - #2872

Closed
lzhMeow wants to merge 2 commits into
morluto:mainfrom
lzhMeow:fix/har-normalized-number-redaction
Closed

lzhMeow wants to merge 2 commits into
morluto:mainfrom
lzhMeow:fix/har-normalized-number-redaction

Conversation

@lzhMeow

@lzhMeow lzhMeow commented Oct 13, 2026

Copy link
Copy Markdown

Summary

Fix HAR numeric redaction when JSON normalization introduces a caller-excluded literal. With _number: 1e3 and sensitive_values: ["1000"], inspection previously returned _number: 1000. It now returns null, omits that numeric sidecar, and records an explicit-sensitive-value redaction. Unmarked values and exact producer lexemes remain retained.

Problem and expected behavior

HAR checked declarations against the original number lexeme, but omitted the normalized spelling it actually published. Both 1e3 → 1000 and 0.0000001 → 1e-7 could reintroduce excluded text. Exclusion must apply before reported values or numeric sidecars are retained, in container metadata and extracted records.

Change and scope

CaptureRedaction.number owns safe conversion and checks for both spellings. HAR and qlog use this shared owner; qlog already checked normalized values, so the refactor preserves its behavior and removes duplicated interpretation. HAR schema admission still validates the unredacted projection. No downstream filter or directly related cleanup remains.

This is an ordinary fix within existing offline capture inspection; no advance maintainer scope decision applies. No separate issue is linked because the bug was found and reproduced during review. Related-PR searches found no equivalent fix; #2477 addresses binary byte counts.

Contract and boundary impact

  • Semantic owner: capture numeric projection before publishing values and sidecars.
  • CLI/MCP schemas, dependencies, generated metadata and installation behavior: unchanged.
  • Evidence: existing null values and redaction records express the corrected exclusion; unmarked lexemes and artifact provenance remain retained.
  • Authority: existing offline reads only; no new target execution, instrumentation, mutation, network acquisition or protection recovery.

Evidence and regression coverage

Source regressions cover container metadata and records, sidecar omission, exact redaction pointers and unmarked controls. Compiled CLI/stdio MCP regressions also verify matching Evidence identities and normalized results, plus unchanged input files.

On clean base 117bd23dd, both new end-to-end cases fail after successful CLI/MCP decoding: excluded values remain 1000 and 1e-7. Source regressions reproduce the same failures. On the fixed tree, all 107 related tests across six files pass, with no skips.

Validation performed

Windows x64, pinned Node 24.18.0, npm 11.16.0, locked dependencies installed with npm ci --cache .cache/npm --foreground-scripts; installation scripts completed normally. Fixed and baseline runtimes were freshly compiled with npm run build. End-to-end runs used the same Windows user permissions, toolchain, dependencies and native addon. Earlier sandbox access-denial attempts are not counted as passing verification.

The native addon comes from upstream CI run 38395741217, commit 1729e87d9f2d1e9db797864cdfe763a327e13049. All four native source blobs and the build script match this checkout; both package versions are 6.4.0. Archive SHA-256 matches GitHub's digest. The current artifact verifier confirms addon SHA-256, package version, Windows x64/PE32+, Node-API 8 and ABI 1. Generated artifacts and the local toolchain are ignored and uncommitted.

  • npm run test:focused -- src/browser/history/HarCapture.test.ts src/browser/history/QlogCapture.test.ts src/application/WebNetworkCaptureService.test.ts tests/boundary/browser/historicalWebCapture.test.ts tests/boundary/mcp/webNetworkCaptureMcp.test.ts tests/acceptance/tools/historicalCaptureResources.test.ts — 107 passed, including real HAR memory exhaustion and server usability afterward.
  • npm run build, npm run verify:windows-native:artifact — passed; builds report two ineffective dynamic-import warnings.
  • npm run typecheck, npm run knip, npm run verify:module-boundaries, npm run verify:architecture-guards, npm run verify:test-discovery — passed; all 1,071 test files discovered once.
  • Changed-file formatting/lint, normal pre-commit hooks and git diff --check — passed; lint retains two existing function-length warnings.
  • npm run check — fails formatting in unchanged tests/fixtures/javaClassFile.ts.
  • npm run check:fast — fails function-length lint in unchanged tests/boundary/providers/ghidra/ghidraLauncher.test.ts:431 and src/ghidra/GhidraFunctionValues.test.ts:46.

Both aggregate-check failures were independently reproduced with the same commands on clean base 117bd23dd under the pinned toolchain. They remain unresolved and are not reported as passing checks.

Compatibility, safety, and release

No schema changes, migration, dependency updates or release metadata changes. Real Windows CLI/MCP capture-worker behavior is verified with synthetic offline HAR files. Real browser, Hopper, Ghidra and mitmproxy producer execution, Linux/macOS runs and a full-suite pass are not claimed.

Before merge

  • Bug reproduced on the base and corrected through public CLI/MCP workflows.
  • Existing contribution scope and authority boundaries preserved.
  • Focused outcome, Conventional Commit title and regression coverage.
  • Final diff checked for unrelated changes and generated artifacts.
  • Aggregate static checks and current-head CI pass; baseline failures are recorded above.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T07:05:59.215999Z 889c43a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed change appears safe to merge and preserves qlog numeric redaction.

Summary

The diff moves qlog numeric redaction and conversion into the shared CaptureRedaction.number helper.

  • Qlog sends each number through the shared capture redactor.

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@morluto
morluto force-pushed the fix/har-normalized-number-redaction branch 2 times, most recently from f65484b to 6de0821 Compare October 13, 2026 18:27
@morluto
morluto force-pushed the fix/har-normalized-number-redaction branch from 6de0821 to 1cf3d0a Compare October 13, 2026 18:52
@morluto morluto added area: runtime Process capture and runtime observation bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Own service-worker CDP registrations and retry failed teardown. Admit redaction and network metadata against remaining capture capacity, retain explicit omission reasons, and preserve source URL, redirect ancestry, caller-selected content, and historical capture values. Forward CLI cancellation through provider cleanup.

Reviewed fixes: #2263, #2637, #2767, #2845, #2859, #2863, #2872, #2874, #2876, #2879, #2955, #2957, #2961, #3033.

Validation: 25 current event/network source tests passed; earlier focused browser lanes passed 201 source tests and 176 boundary tests with two skips, plus 35 Python tests. Real browser/Windows lanes were not rerun. Playwright allocation before admission remains unbounded by these retention limits.
@CassieFox23

CassieFox23 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Edit: Main caught up with most of this PR. I retested what is left here.

Heads up: main already has this change in f690571. The code is in src/browser/history/HarCapture.ts. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

# Conflicts:
#	tests/boundary/browser/historicalWebCapture.test.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Merged latest main into this branch to resolve the tests/boundary/browser/historicalWebCapture.test.ts conflict. No rebase or force-push was used. The conflict was main adding a Playwright IPv6 CLI/MCP test next to this PR's changes in the same file. Both are kept, and this PR's other test additions merged cleanly. Validation: HarCapture and CaptureRedaction tests (76 passed), the historicalWebCapture boundary test, and typecheck and lint via the pre-push hook.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: After main caught up, one change is left here. It makes QlogCapture use the helper that main already has for number redaction. I ran it on main 95c8f57 and it behaves the same as main, on Node 22, 24 and 26.

Edit on my earlier comment: the leftover change is now tested, details below.

The PR changes one file, src/browser/history/QlogCapture.ts. It drops the inline number check and calls redactor.number() instead. That helper is in CaptureRedaction.ts, which is the same file on main and on this PR. Main's inline code and the helper run the same two checks in the same order. I put the PR's version of the file on main and ran a small test with a qlog event and two sensitive values, 424242 and 1000. The packet number 424242 and the value written as 1e3 both came out as null, with the reason explicit-sensitive-value. A plain 7 was kept. A very large integer was nulled, and its exact text was kept in numeric_literals. Main without the change gave the same output, byte for byte. Main's 24 qlog tests and my test all pass on both versions, on all three Node versions. The PR adds no test of its own.

Thanks, lzhMeow, for the fix.

Not run

  • The PR head as is, because it is far behind main. I dropped its file onto main instead.
  • A real aioquic qlog or a live capture.
  • Windows and macOS.
Commands
git archive main | tar -x -C /tmp/ev-2872/main
npm ci --ignore-scripts && npm run prepare && npm run build:cached && npm run test:prepare   # exit 0
npm run test:focused -- src/browser/history/QlogCapture.test.ts src/browser/history/QlogRedactionProbe.test.ts   # exit 0, 25 passed, Node 22, 24, 26
cp <PR head>/src/browser/history/QlogCapture.ts src/browser/history/QlogCapture.ts
npm run build:cached   # exit 0
npm run test:focused -- src/browser/history/QlogCapture.test.ts src/browser/history/QlogRedactionProbe.test.ts   # exit 0, 25 passed, Node 22, 24, 26; probe output identical
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Main: 95c8f57. PR head: 889c43a.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Closing as superseded on main. The HAR numeric-redaction fix and regression coverage landed in f6905719, and the remaining qlog shared-owner refactor landed in a496131e. The current one-file PR patch is already present on main; normalized-sensitive-value and source-literal regressions remain retained. This closeout used source/diff verification and did not rerun platform tests. Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants