Repository navigation
fix(resolver): keep the fields a schema opens - #653
Open
LKSNDRTMLKV wants to merge 1 commit into
Open
LKSNDRTMLKV wants to merge 1 commit into
LKSNDRTMLKV wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #375.
The decision, and what it turned up
The founder decided #375 as option 2: keep the resolver's hand-rolled filter as a deliberate second opinion, document that in the code, and treat the parity test as the contract. The issue rested that choice on "nothing is broken today". Checking that claim against the code before documenting it found it false.
batchIdandserialNumberto the public throughx-public-envelope-fields. No other schema in core's catalog opens anything.redact_passportcomposes its policy withProductGroupAccessPolicy::for_passport, which applies those openings. So the public view the vault signs carries both fields.apply_access_tier_filterfiltered the envelope withpassport_default(), which opens nothing, so at Public it dropped both fields. The handler then re-attachedpublicJwsSignature. A battery passport at schema 2.7.0 or later was therefore served from/dpp/{dppId}(JSON) with a body its own proof does not cover.Documenting a filter that breaks its contract as harmless would have been a false comment. So this PR makes the filter honour the contract, and only then documents it.
What changes
envelope_policy. The envelope pass takes its policy from the composition the vault uses,for_passport, keyed by the passport's ownproductGroupandschemaVersion.ProductGroupand its key throughcatalog_key, so no mapping and no opening is restated.passport_default(). That fails closed, as before.The filter still does not call
redact_passport. It stays an independent pass over the payload the vault signed. A second opinion that called the same function would check nothing.The doc comment on
apply_access_tier_filterrecords the decision. It says the filter is:It names the parity test as the contract, which a change must keep rather than update.
The envelope's view changes only by the two openings.
for_passportdiffers frompassport_default()only in what the envelope scope does not consult, apart frompublic_envelope_fields. TheproductGroupDatapass, the unknown-group backstop and the legacy pass-through are unchanged.Tests (
crates/dpp-resolver/src/handlers/resolve_json.rs)this_filter_removes_nothing_from_a_view_the_vault_already_signed, the contract. It now runs at every battery schema version core embeds, read fromVersionedSchemaRegistry, withbatchIdandserialNumberpopulated. It first asserts that the list reaches 2.6.0 and the catalog's current version. A schema that adds an opening is covered the day core ships it.a_battery_passport_at_the_current_schema_is_served_with_batch_id_and_serial_numberreads the catalog's current version.an_envelope_with_a_schema_version_core_does_not_carry_fails_closedandan_envelope_with_a_product_group_core_does_not_know_fails_closed.unknown_product_group_tag_fails_closed_at_public_tieranduntagged_legacy_product_group_data_passes_through.Corrections to the issue's table
filter_by_audienceremovesPASSPORT_PROOF_FIELDSat the envelope root, and the handler re-attachespublicJwsSignatureafterwards.personalData. It is classIndividual, so the resolver's envelope pass removes it at Public, and the signed Public view never carries it either. At tiers above Public, the resolver would treat statements differently fromredact_passport. That is unreachable, becauseparse_access_tieralways answers Public.Checked
just checkgreen on this branch: 1932 tests passed, 3 skipped, audit included.dpp-resolver: 176 tests passed. Clippy with the full feature set is clean.passport_default()put back for the envelope pass. The contract fails at "battery schema 2.7.0", the first version with the opening. The current-schema test fails too, with the servedbatchIdNonewhere the signed view has"BATCH-42".