Repository navigation
fix(flow): capture readers rebuild minimized bodies or refuse (#2789) - #2819
Conversation
Since #2480 a capture keeps only declared fields: a save is written as body_minimized/form_minimized and a response as response_minimized. The undo proposal, record check synthesis and proof, API step proposal and the network-to-HAR bridge read only body/form/response_text, so in a default capture they saw an empty body. A shared reader (capture_bodies) rebuilds kept JSON and form fields and refuses an opaque body or a withheld field the reader needs, as #2785 did for readiness import (which now uses it). Each reader rebuilds what it can use or refuses with the recording flag that fixes it.
…uard Core modules reach the undo proposal and record check synthesis; the agent guard import pulled a forbidden chain into core (test_import_layers).
…ack, cover guard A raw capture also writes opaque descriptors (a multipart body with a file, a binary body over the cap, a response type it keeps as bytes). Those are no longer read as minimized away; readers that have the capture header trust it. The undo match that falls back to values now refuses a later write whose withheld values may be the selector's, and the read cover refuses a write the capture kept nothing of.
Independent adversarial review: REQUEST CHANGESFrom: Grok
The gap is Hosted flow unit, lint, and the critical job were still queued or running when I posted. I did not wait for them, and I did not run the Windows-only jobs. Please teach |
…ent set cover() and discover() built the written values from kept fields only, so a value the capture withheld counted as not sent and a read holding only the kept values could be promoted. Both now refuse when a write's body is unreadable or any field was withheld. cover() also refuses when no write sent a recorded parameter value, where the subset check passed vacuously (#2820).
Independent adversarial review: APPROVEFrom: Grok The blocker I raised at I checked this against a real Generality gate: pass. The delta is generic capture-reader refusal. CI on this head: gitleaks, smoke, validate-platform-manifest, launcher, the GTK no-skip check, and freerdp all passed. Flow unit, lint, critical, default-at-rest, and the Windows replay job were still running when I posted. I did not wait for them, and I did not run the Windows-only jobs locally. I did not push to this branch, and I will not merge it. |
Independent adversarial review: APPROVEFrom: Grok This head is a clean merge of the previously approved The only file touched by both sides is I re-ran the exact-head tests at Generality gate: pass. CI on this head: platform manifest, internal links and anchors, the GTK no-skip check, and freerdp all passed. The Windows replay job (the reason for this merge) was still in progress when I posted. gitleaks, dependency-review and the packages CI workflow had not finished (packages CI was still pending, with no jobs started yet). I did not wait for them, and I did not run the Windows-only jobs locally. I did not push to this branch, and I will not merge it. |
Independent adversarial review: APPROVEFrom: Grok This head is a clean merge of the previously approved All twelve PR-unique files are byte-identical to the previously approved head. The only files this merge brought in from I re-ran the exact-head tests at Generality gate: pass. CI on this head: platform manifest, internal links, gitleaks, dependency-review, the GTK no-skip check, and freerdp all passed. I did not push to this branch, and I will not merge it. |
Fixes #2789, fixes #2820.
Since #2480, a network capture keeps only declared fields. A save is written as
body_minimized/form_minimized, and a response asresponse_minimized. Five readers still looked only atbody,formorresponse_text, so in a default capture they saw an empty body. Each one now rebuilds what it can use from the kept fields, or refuses and names the withheld field and the recording flag that fixes it.Shared reader
openadapt_flow/capture_bodies.pyfollows the approach of #2785:[name, value]pairs. It rebuilds a minimized JSON body withcapture_privacy.restore_kept_json.BodyUnreadable.FieldsWithheld. Needed fields are compared as full paths, case-exact. Session tokens and secrets (is_withheld_name) count as withheld.request_hiddenandresponse_hiddenseparate "minimized away" from the opaque descriptors a raw capture also writes: a multipart body with a file, a body that isn't UTF-8 (including one over the size cap), and a response type it keeps as bytes, such astext/xml. Readers that have the recording trust the capture header (bodies: raw), so nothing is hidden in a raw capture.readiness/reference.pynow uses this reader instead of its own_kept_fields. Its codes and messages are unchanged, and the fix(flow): readiness import reads minimized network captures #2785 tests pass as they are.Readers
undo_proposal--identifier. When form fields are named differently from the selector (form_lnameforlname), the match falls back to values; a later write whose withheld values could hold the selector's values also refuses.record_check_synthesis_write_valuesreturns the kept sent values. A write it can't read is listed as not covered, with the real reason instead of "no read returns what this request sent". Withheld sent constants are noted. Minimized read responses are not used to build a check; a note says raw bodies are needed.record_check_proof.body_templateProofUnavailable(surfaced asScaffoldRefused) instead of quietly proving the fixture's default body. A rebuilt body loses key order and empty containers. That is acceptable here because the template is already a flat rendering (top-level keys, values as text) sent only to the caller's local proof fixture.read_discovery.coveranddiscover_write_unseen), since a withheld value would count as "not sent" and a read holding only the kept values could be promoted.coveralso refuses when no write sent a recorded parameter value, because "the read holds every written value" would then pass vacuously (#2820).compiler/api_proposaltx/network_bridgeValueErrorinstead of writing a HAR with empty bodies for lens induction.The
local_editandcompile.pyreaders look only at methods and times, so they were left unchanged.One departure from the four-case test list: for
api_proposalandnetwork_bridge, the "kept field is used" case is a refusal even when every field was kept. A rebuilt body loses key order and empty objects and lists, and the HMAC key is gone, so it can't be proven to match what was sent. That is fine for finding a request and not fine for one that gets sent again.Tests
tests/test_capture_readers_minimized.py(38 tests) builds every capture with the realBodyMinimizer/minimize_line, with the header a minimized recording writes. For each reader it covers a kept field, a withheld field, an opaque (cut) body and a raw capture. It also checks that the three raw-capture opaque shapes leave each reader as it is onmain.tests/test_read_discovery_cover.pyadds the #2820 regression test: a raw capture whose write sent no recorded parameter. The existing tests for these modules, and the import-layer tests, pass.Docs
docs/NETWORK_CAPTURE.mdnow says what each reader does with a minimized capture.docs/LIMITS.mdhas a short paragraph in the privacy section.