Trace sensitive attributes in custom dev builds#2478
Merged
carolynvs merged 3 commits intogetporter:mainfrom Dec 6, 2022
Merged
Trace sensitive attributes in custom dev builds#2478carolynvs merged 3 commits intogetporter:mainfrom
carolynvs merged 3 commits intogetporter:mainfrom
Conversation
75913b8 to
8f6d2e7
Compare
Instead of adding and removing println statements that write out sensitive data to assist with troubleshooting while writing code, only to have to remember to remove them before committing, I've added tracing.SetSensitiveAttributes. In all normal builds created by go build, or our magefile targets, that function is a noop and does nothing. However if you build with go build -tags traceSensitiveAttributes, then that function will write out the passed attributes (which contain sensitive data) to the listening open telemetry collector (if any). When porter runs with traceSensitiveAttributes set, a warning is printed to stderr to indicate the different behavior. I hope this will give us a way to make it easy to debug in development while ensuring that we don't ever actually trace sensitive attributes in real builds. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
8f6d2e7 to
9211900
Compare
Support quickly tracing the json value of an object. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Demonstrate how to use span.SetSensitiveAttributes by tracing the CNAB claim and credentials (both of which can contain sensitive data) when a bundle is run. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.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.
What does this change
Instead of adding and removing println statements that write out sensitive data to assist with troubleshooting while writing code, only to have to remember to remove them before committing, I've added tracing.SetSensitiveAttributes.
In all normal builds created by go build, or our magefile targets, that function is a noop and does nothing. However if you build with go build -tags traceSensitiveAttributes, then that function will write out the passed attributes (which contain sensitive data) to the listening open telemetry collector (if any).
When porter runs with traceSensitiveAttributes set, a warning is printed to stderr to indicate the different behavior.
I hope this will give us a way to make it easy to debug in development while ensuring that we don't ever actually trace sensitive attributes in real builds.
What issue does it fix
I really needed this when I was refactoring parameter resolution, and in the past I know we have accidentally committed println statements that we shouldn't have. So this puts in a safer way to help us develop this area of the code.
Notes for the reviewer
I considered making this a configuration setting, but I thought this did a better job of making it real hard to someone to accidentally leak sensitive data. Most people don't do their own builds, let alone with artisanal build flags so if you end up with a build of Porter that traces sensitive data, it's clear they opted into it.
❓ I'm open to suggestions for the name of
SetSensitiveAttributes. I mimicked theSetAttributesfunction but maybe we should stuff more info about how the function behaves into the name?Checklist
Reviewer Checklist