Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/durable_workflow/history_bundle_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,16 @@ def _check_payload_manifest(bundle: Mapping[str, Any], findings: list[dict[str,
)
)

if entry.get("codec") == "avro" and available:
# The same condition as the PHP and native verifiers: an available,
# unredacted Avro entry needs inline framing unless its diagnostic
# marks it as an external storage reference, which names an object
# outside the bundle.
if (
entry.get("codec") == "avro"
and available
and not redacted
and diagnostic != "external_storage_reference"
):
if not _string_or_none(entry.get("avro_framing")):
findings.append(
_finding(
Expand Down
82 changes: 82 additions & 0 deletions tests/test_history_bundle_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,88 @@ def test_writer_schema_fingerprint_mismatch_in_payload_manifest() -> None:
assert report["status"] == STATUS_FAILED


def test_external_storage_reference_entries_need_no_avro_framing() -> None:
signing_key = "secret"
bundle = _base_bundle()
bundle["payload_manifest"]["entries"].append(
{
"path": "payloads.arguments.data",
"codec": "avro",
"available": True,
"redacted": False,
"encoding": "external-storage-reference",
"diagnostic": "external_storage_reference",
}
)
bundle = _sign(bundle, signing_key, "key-1")

report = verify_bundle(bundle, signing_key=signing_key)

assert "payload_manifest.avro_framing_missing" not in _rule_names(report)


def test_external_encoding_without_matching_diagnostic_still_warns() -> None:
# PHP and native skip on the diagnostic alone, so an entry that only
# claims the external encoding is still checked.
signing_key = "secret"
bundle = _base_bundle()
bundle["payload_manifest"]["entries"].append(
{
"path": "payloads.arguments.data",
"codec": "avro",
"available": True,
"redacted": False,
"encoding": "external-storage-reference",
"diagnostic": None,
}
)
bundle = _sign(bundle, signing_key, "key-1")

report = verify_bundle(bundle, signing_key=signing_key)

assert "payload_manifest.avro_framing_missing" in _rule_names(report)


def test_redacted_avro_entry_needs_no_framing() -> None:
signing_key = "secret"
bundle = _base_bundle()
bundle["payload_manifest"]["entries"].append(
{
"path": "payloads.output.data",
"codec": "avro",
"available": True,
"redacted": True,
"encoding": "base64-avro-single-object",
"diagnostic": None,
}
)
bundle = _sign(bundle, signing_key, "key-1")

report = verify_bundle(bundle, signing_key=signing_key)

assert "payload_manifest.avro_framing_missing" not in _rule_names(report)


def test_inline_avro_entry_without_framing_still_warns() -> None:
signing_key = "secret"
bundle = _base_bundle()
bundle["payload_manifest"]["entries"].append(
{
"path": "payloads.output.data",
"codec": "avro",
"available": True,
"redacted": False,
"encoding": "base64-avro-single-object",
"diagnostic": None,
}
)
bundle = _sign(bundle, signing_key, "key-1")

report = verify_bundle(bundle, signing_key=signing_key)

assert "payload_manifest.avro_framing_missing" in _rule_names(report)


def test_required_evidence_sections_are_enforced() -> None:
signing_key = "secret"
bundle = _base_bundle()
Expand Down