Skip to content

Add JSON schema validation to reject unknown fields#32

Merged
travier merged 2 commits intolatchset:mainfrom
sergio-correia:validation
Jan 29, 2026
Merged

Add JSON schema validation to reject unknown fields#32
travier merged 2 commits intolatchset:mainfrom
sergio-correia:validation

Conversation

@sergio-correia
Copy link
Contributor

Adds serde(deny_unknown_fields) attribute to TPM2Config to catch
typos and invalid field names in JSON configuration. Previously,
invalid fields like "pcrs_ids" were silently ignored, which could
lead to unexpected behavior.

@sergio-correia
Copy link
Contributor Author

@puiterwijk: please take a look when possible.

Signed-off-by: Sergio Correia <scorreia@redhat.com>
Adds serde(deny_unknown_fields) attribute to TPM2Config to catch
typos and invalid field names in JSON configuration. Previously,
invalid fields like "pcrs_ids" were silently ignored, which could
lead to unexpected behavior.

Signed-off-by: Sergio Correia <scorreia@redhat.com>
Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with that but this might mean that we can not extend this config in the future if we want to change the format. I don't know where/how it's used right now.

@sergio-correia
Copy link
Contributor Author

Could you please elaborate on your concern? The validation only applies to encryption input (TPM2Config at src/cli.rs:14), not to the stored format (Tpm2Inner at src/main.rs:92). This means older versions can still decrypt blobs created by newer versions with new fields, while users get immediate feedback on typos during encryption.

@travier
Copy link
Member

travier commented Jan 29, 2026

Thanks for the details. Makes sense.

@travier travier merged commit 5827e1f into latchset:main Jan 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants