Redact AppRole's Debug output (#145) - #146
Merged
Merged
Conversation
AppRole derived Debug, so formatting it -- or any downstream type that derives Debug over one, such as bootler's registration records -- printed the role id and secret id in clear text. A hand-written Debug prints both as "<redacted>", which fixes every container at once and lets bootler stop redacting the pair by hand. It ends in .finish() rather than .finish_non_exhaustive() so a field added later has to be classified explicitly. Closes #145
Contributor
Author
|
[Reviewer Round 1] No findings. This is a focused, appropriate fix for #145.
I recommend approval. Tests and CI were not rerun, as instructed. |
Contributor
Author
|
[Review Verdict Round 1: APPROVED] |
7 tasks done
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.
Summary
AppRoleused to deriveDebug, so formatting it with{:?}printed bothrole_idandsecret_idin clear text. The same happened for any type that derivesDebugand holds anAppRole. No deploy-core code formats anAppRoletoday, but bootler keepsAppRoles in types that deriveDebug(e.g.RegistrationSteps). Any futuretracingfield,expectmessage or error string over those types would leak the secret id. Fixing the type here protects every type that holds one.Changes:
src/bootroot_cmd.rs:Debugis removed fromAppRole's derive list.Clone,PartialEq,Eq,Serialize,Deserialize, the fields and their visibility are unchanged, so equality and serialized bytes are unaffected. A hand-writtenimpl std::fmt::Debug for AppRolereplaces the derive. It usesdebug_struct("AppRole")withrole_idthensecret_id, prints each as"<redacted>", and ends with.finish(), so any field added later must be classified explicitly. Neither id ever goes through its ownDebug. The output isAppRole { role_id: "<redacted>", secret_id: "<redacted>" }. This follows the in-crate precedent ofGenerationFile's hand-writtenDebug.app_role_debug_redacts_both_ids: it builds anAppRolewith a distinct sentinel in each field. It checks that both{:?}and{:#?}output contain neither sentinel and do contain<redacted>,role_idandsecret_id. It also pins the exact compact output. No secret value is compared withassert_eq!/assert_ne!.CHANGELOG.md: a new## [Unreleased]section has a### Changedentry saying theDebugoutput now redacts both ids. The matching[Unreleased]compare link is added too.role_idis redacted as well assecret_id: it is half of the AppRole login, and bootler's own redactions already treat the pair as secret.This should merge before the bootler change that re-pins deploy-core to this commit.
Closes #145
Deviations from the issue
None
Test plan
app_role_debug_redacts_both_ids(src/bootroot_cmd.rs): builds anAppRolewith distinct sentinels inrole_idandsecret_id, checks that neither{approle:?}nor{approle:#?}contains either sentinel and that both contain<redacted>,role_idandsecret_id, and pins the compact output toAppRole { role_id: "<redacted>", secret_id: "<redacted>" }cargo testandcargo test --features test-supportcargo fmt -- --check --config group_imports=StdExternalCratecargo clippy --all-targets -- -D warningsandcargo clippy --all-targets --features test-support -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --features test-supportmarkdownlint-cli2 "**/*.md"reports no issues in tracked files, including the newCHANGELOG.md[Unreleased]section and link reference. Locally it flags only a generated license file undertarget/doc/, which CI never sees