Redact sensitive fields' default:/example: from the exported schema - #75
Merged
Merged
Conversation
sensitive: true already marked a field writeOnly/x-permittable-sensitive and redacted it from logs, but annotate() still copied that same field's default:/example: into the exported JSON Schema in cleartext — the one output channel meant for client-generator tooling or a public docs endpoint. optional :ssn, :string, sensitive: true, default: "000-00-0000" exported the real default alongside writeOnly: true. Skip the default:/example: assignment when field[:sensitive] is set, consistent with how every other untranslatable or sensitive fact in this file is handled: omitted, with the x-permittable-* extension as the only signal. The non-sensitive case is unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
The bug
sensitive: truemarks a fieldwriteOnly/x-permittable-sensitivein the exported OpenAPI/JSON Schema document and registers it for log redaction, butannotate()inlib/permittable/json_schema.rbstill copied that same field'sdefault:/example:into the exported document in cleartext:exported
The exported schema is the one output channel meant to leave the app — client-generator tooling or a public docs endpoint — unlike the request log a
sensitive:value is otherwise redacted from. Shipping the real default/example there defeats the point of marking the field sensitive in the first place.The fix
annotate()now skips thedefault:/example:assignment entirely whenfield[:sensitive]is set:Omitting the keys, rather than redacting to a placeholder string, matches how every other untranslatable or opaque fact in this file is already handled — left out, with an
x-permittable-*extension (here,writeOnly/x-permittable-sensitive, already present) as the only signal that something is missing.descriptionis untouched: it's authored documentation text, not the value itself. The non-sensitive case (default:/example:with nosensitive:) is unaffected, and the cascade from a sensitive nested/array block onto its children already resolvesfield[:sensitive]beforeannotate()runs, so it's covered by the same check with no extra plumbing.Verification
bundle exec rspec spec/json_schema_spec.rb— 64 examples, 0 failuresbundle exec rspec(full suite) — 853 examples, 0 failuresbundle exec rubocop lib/permittable/json_schema.rb spec/json_schema_spec.rb— no offensesspec/json_schema_spec.rbreproducing the exact scenario from the bug report, confirmed to fail before the implementation change (default/examplespresent alongsidewriteOnly) and pass after:json-field test that had asserted the buggy behavior (default/examples exported alongsidesensitive: true) — split into a plain-annotation case and a sensitive-omission case🤖 Generated with Claude Code