Repository navigation
fix(sdk): DSPX-1561 parse manifests strictly - #4305
Open
dmihalcik-virtru wants to merge 1 commit into
Open
dmihalcik-virtru wants to merge 1 commit into
dmihalcik-virtru wants to merge 1 commit into
Conversation
Apply the parsing rules of the ZTDF assertions specification, Section 3, before LoadTDF or IsValidTdf decodes a manifest, and in Manifest.UnmarshalJSON, whether or not assertion verification is enabled. encoding/json keeps the last of duplicate members, folds case when matching names, and replaces invalid Unicode, so a scanner reads the raw bytes first: - duplicate member names anywhere in the manifest, compared after decoding escapes, fail with duplicate-member; - at every level of the manifest the SDK models, a case variant of a modelled member name, or two members whose names are case variants of each other, fail with ambiguous-member. The IsStreamable spelling that older Java writers used under encryptionInformation.method is still accepted; - invalid UTF-8 anywhere, and lone surrogates, noncharacters, and out-of-range numbers inside an assertion object, fail with invalid-json. Text that is not JSON at all, such as a manifest starting with a byte order mark, keeps its existing error. LoadTDF still only parses. ErrAssertionFailure gains a Reason holding a Section 9 code. It still unwraps to ErrTampered, and its message carries reason=<code>, with the id escaped and length-capped since it comes from the file. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This was referenced Nov 9, 2026
Contributor
Benchmark results, click to expandBulk Benchmark Results
TDF3 Benchmark Results
|
Contributor
|
Contributor
pflynn-virtru
approved these changes
Nov 12, 2026
This branch has not been deployed
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.
Proposed Changes
LoadTDF,IsValidTdf, andManifest.UnmarshalJSON, whether or not assertion verification is enabled. A scanner reads the raw bytes first, becauseencoding/jsonkeeps the last duplicate member, matches names case-insensitively, and replaces invalid Unicode. Rejected:duplicate-member);ambiguous-member). TheIsStreamablespelling written by older Java SDKs underencryptionInformation.methodis still accepted;invalid-json).LoadTDFremains parse-only.ErrAssertionFailuregainsReason(AssertionFailureReasonconstants with the Section 9 codes). It still unwraps toErrTampered; its message carriesreason=<code>, and the id is escaped and length-capped. When there is no id, the message no longer ends in an emptyid:.Split out of #4301 (draft; the complete change). Cross-SDK counterparts: opentdf/java-sdk#436, opentdf/web-sdk#1139.
Compatibility: manifests with duplicate or case-variant member names, or invalid UTF-8, no longer load. A scan of legitimate manifests found none affected apart from the accepted
IsStreamablespelling.Checklist
Testing Instructions
cd sdk && go test ./... -race(sdk/assertion_parse_test.go,sdk/assertion_json_test.go,sdk/null_statement_test.go);cd otdfctl && go test ./...(pkg/handlers/tdf_errors_test.gochecks the typed failure reaches the CLI).