Dashboard › institutional-transition-lab › Session 14hBrffUE2J4
14hBrffUE2J4DHosyPerform a fresh, read-only security audit of only ZIP decompression and member-stream validation for issue #4 in /home/byk/Code/institutional-transition-lab. This is the second smaller disjoint replacement for a ZIP reviewer that returned empty twice. Never edit files and never inspect governance bodies, codings, outcomes, reports, dates, detector output, or source-adjudication scopes.
Scope only: decompression limits enforced on actual bytes read; short/partial reads; CRC/corrupt/truncated stream behavior; compression bombs; per-member and aggregate expanded-byte accounting; declared compressed/uncompressed size mismatches at read time; exact bytes for the unique required documents.json and v1.2-adjudication-package.json compared with verified durable payload bytes; cleanup/error behavior. Treat archive path/name/mode/encryption/entry-count metadata, _read_regular_file, JSON, pins/hashes, and CLI outputs as out of scope.
Primary files are only ZIP stream/content helpers/constants in src/institution_lab/governance_adjudication.py and narrowly related tests in tests/test_governance_adjudication.py. Review current unchanged working copy. Run narrow read-only tests/probes. Return substantive evidence, never empty. Findings first, severity ordered, exact current file:line references, PASS/CONCERN/MUST-FIX/BLOCKED labels. Every defect needs a deterministic regression. If clean, state PASS with tests/probes and residual risks. End exactly MERGE or DO-NOT-MERGE.
I’ll trace only ZIP member-stream handling and its focused tests, then run narrow synthetic corruption/limit probes without touching repository files. I’ll verify the working copy remains unchanged and report exact line evidence.
No files found
M pyproject.toml M uv.lock ?? .lore.md ?? AGENTS.md ?? cases/review/oss-governance-adjudication-v1.inputs.json ?? cases/review/oss-governance-adjudication-v1/ ?? schema/governance-adjudication-v1.schema.json ?? src/institution_lab/governance_adjudication.py ?? tests/test_governance_adjudication.py c686c4878409e68b958dd61850a59e9234416d817fc2fa3246fc728d51ebe0a5 src/institution_lab/governance_adjudication.py abf64b5e78a616d53b703dee5291ce7bf23fa9156fe59263a702e01cb8667bc5 tests/test_governance_adjudication.py
Found 10 matches
/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py:
Line 10: import zipfile
Line 106: payload = source.read(max_bytes + 1)
Line 180: with zipfile.ZipFile(io.BytesIO(artifact)) as archive:
Line 188: if sum(info.file_size for info in infos) > MAX_ARCHIVE_EXPANDED_BYTES:
Line 191: "documents.json": documents,
Line 192: "v1.2-adjudication-package.json": coding_package,
Line 199: if info.file_size > MAX_ARCHIVE_MEMBER_BYTES:
Line 202: member_bytes = source.read(MAX_ARCHIVE_MEMBER_BYTES + 1)
Line 207: except zipfile.BadZipFile as error:
Line 208: raise ValueError("artifact is not a valid ZIP archive") from error
Found 32 matches
/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py:
Line 8: import zipfile
Line 50: "documents": tmp_path / "documents.json",
Line 52: "artifact": tmp_path / "artifact.zip",
Line 65: with zipfile.ZipFile(paths["artifact"], "w") as archive:
Line 66: archive.writestr("documents.json", paths["documents"].read_bytes())
Line 68: "v1.2-adjudication-package.json",
Line 195: "source_text_truncated": False,
Line 197: "patch_selection_truncated": False,
Line 210: "source_text_truncated": False,
Line 212: "patch_selection_truncated": False,
Line 379: ("evidence_bounds", {"source_text_truncated": True}),
Line 426: documents["documents"][0]["evidence_bounds"]["source_text_truncated"] = True
Line 687: artifact = tmp_path / "artifact.zip"
Line 688: documents = tmp_path / "documents.json"
Line 703: with zipfile.ZipFile(artifact, "w") as archive:
Line 704: ...
Found 12 matches /home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py: Line 67: MAX_ARCHIVE_MEMBERS = 128 Line 68: MAX_ARCHIVE_MEMBER_BYTES = 16 * 1024 * 1024 Line 69: MAX_ARCHIVE_EXPANDED_BYTES = 64 * 1024 * 1024 Line 160: artifact: bytes, Line 169: "artifact_sha256": _bytes_sha256(artifact), Line 182: if len(infos) > MAX_ARCHIVE_MEMBERS: Line 188: if sum(info.file_size for info in infos) > MAX_ARCHIVE_EXPANDED_BYTES: Line 199: if info.file_size > MAX_ARCHIVE_MEMBER_BYTES: Line 202: member_bytes = source.read(MAX_ARCHIVE_MEMBER_BYTES + 1) Line 203: if len(member_bytes) > MAX_ARCHIVE_MEMBER_BYTES: Line 233: artifact=_read_regular_file(artifact, max_bytes=MAX_ARTIFACT_BYTES), Line 918: artifact=_read_regular_file(args.artifact, max_bytes=MAX_ARTIFACT_BYTES),
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
55: }
56: CLAIM_FIELDS = {
57: "record_class",
58: "event_kind",
59: "title",
60: "announced_on",
61: "effective_on",
62: "affected_scope",
63: "body_patch_relation",
64: }
65: MAX_INPUT_BYTES = 16 * 1024 * 1024
66: MAX_ARTIFACT_BYTES = 32 * 1024 * 1024
67: MAX_ARCHIVE_MEMBERS = 128
68: MAX_ARCHIVE_MEMBER_BYTES = 16 * 1024 * 1024
69: MAX_ARCHIVE_EXPANDED_BYTES = 64 * 1024 * 1024
70:
71:
72: @dataclass(frozen=True)
73: class VerifiedInputBundle:
74: pins: dict[str, Any]
(Showing lines 55-74 of 946. Use offset=75 to continue.)
</content>
<path>/home/byk/Code/institutional-transition-lab/src/institution_lab/governance_adjudication.py</path>
<type>file</type>
<content>
150: if type(manifest.get("artifact_id")) is not int or manifest["artifact_id"] < 1:
151: raise ValueError("input manifest artifact_id is invalid")
152: for field, value in FROZEN_INPUT_PINS.items():
153: if manifest.get(field) != value:
154: raise ValueError(f"input manifest does not identify frozen issue #4 input: {field}")
155:
156:
157: def _verify_input_payloads(
158: manifest: Any,
159: *,
160: artifact: bytes,
161: documents: bytes,
162: coding_package: bytes,
163: protocol: bytes,
164: coding_schema: bytes,
165: adjudication_schema: bytes,
166: ) -> VerifiedInputBundle:
167: _validate_manifest_identity(manifest)
168: computed = {
169: "artifact_sha256": _bytes_sha256(artifact),
170: "documents_file_sha256": _bytes_sha256(documents),
171: "coding_package_file_sha256": _bytes_sha256(coding_package),
172: ...
Found 3 matches /home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py: Line 729: def test_input_manifest_rejects_files_not_from_pinned_artifact( Line 883: def test_input_manifest_rejects_duplicate_artifact_members( Line 908: def test_input_manifest_rejects_excessive_artifact_member_count(
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
35:
36: ROOT = Path(__file__).parents[1]
37: MAX_TEST_ARCHIVE_MEMBERS = 256
38:
39:
40: def _write_pinned_cli_inputs(
41: tmp_path: Path,
42: monkeypatch: pytest.MonkeyPatch,
43: ) -> tuple[dict[str, object], dict[str, Path]]:
44: documents_value = {"documents": []}
45: coding_package_value = {"records": [], "summary": {}}
46: adjudication_schema_value = {"type": "object"}
47: paths = {
48: "adjudication": tmp_path / "adjudication.json",
49: "input_manifest": tmp_path / "inputs.json",
50: "documents": tmp_path / "documents.json",
51: "coding_package": tmp_path / "coding-package.json",
52: "artifact": tmp_path / "artifact.zip",
53: "protocol": tmp_path / "protocol.md",
54: "coding_schema": tmp_path / "coding-schema.json",
55: "adjudication_schema": tmp_path / "adjudication-schema.json",
56: "summary_json": tmp_path / "summary.json",
57: ...
<path>/home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py</path>
<type>file</type>
<content>
678:
679: assert f"input pin mismatch: {field}" in errors
680: assert summary["canonicalization_gate"] == "closed"
681:
682:
683: def test_input_manifest_rejects_changed_file_bytes(
684: tmp_path: Path,
685: monkeypatch: pytest.MonkeyPatch,
686: ) -> None:
687: artifact = tmp_path / "artifact.zip"
688: documents = tmp_path / "documents.json"
689: coding_package = tmp_path / "coding-package.json"
690: protocol = tmp_path / "protocol.md"
691: coding_schema = tmp_path / "coding-schema.json"
692: adjudication_schema = tmp_path / "adjudication-schema.json"
693: paths = {
694: "artifact": artifact,
695: "documents": documents,
696: "coding_package": coding_package,
697: "protocol": protocol,
698: "coding_schema": coding_schema,
699: "adjudication_schema": adjudication_schema,
700: }
701: for path in paths.values():
702: ...
Found 1 matches /home/byk/Code/institutional-transition-lab/tests/test_governance_adjudication.py: Line 772: with pytest.raises(ValueError, match="artifact member mismatch: documents.json"):
. [100%] 1 passed in 0.09s
exact_payload: ACCEPTED overreported_expanded_size: ACCEPTED underreported_expansion_over_member_limit: ACCEPTED actual=16777219 declared=2 underreported_compressed_size: ACCEPTED invalid_deflate_stream: REJECTED error: Error -3 while decompressing data: invalid block type crc_mismatch: REJECTED ValueError: artifact is not a valid ZIP archive
No files found
Your first result was empty. Complete the same narrow, read-only ZIP decompression/member-stream security audit now and return substantive evidence or an explicit blocker. Never edit files. Scope only in /home/byk/Code/institutional-transition-lab: actual decompressed-byte limits; short/partial reads; CRC/corrupt/truncated streams; compression bombs; per-member and aggregate expanded-byte accounting; declared size mismatches at read time; exact content comparison for the unique required documents.json and v1.2-adjudication-package.json; cleanup/error behavior; narrowly corresponding tests in src/institution_lab/governance_adjudication.py and tests/test_governance_adjudication.py. Do not review archive path/name/mode/encryption/entry-count metadata, file opening, JSON, pins/hashes, CLI output, governance records/codings/outcomes/reports/dates, or source adjudication. Review unchanged current working copy. Findings first with exact file:line evidence and PASS/CONCERN/MUST-FIX/BLOCKED labels; deterministic regression for every defect; commands/probes run. Never return empty. End exactly MERGE or DO-NOT-MERGE.