-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redact EXPLICIT_COMMAND_LINE
#4525
Conversation
@@ -282,6 +301,7 @@ func TestRedactMetadata_BuildMetadata_StripsURLSecrets(t *testing.T) { | |||
}) | |||
|
|||
assert.Equal(t, "https://github.com/buildbuddy-io/metadata_repo_url", buildMetadata.Metadata["REPO_URL"]) | |||
assert.Equal(t, `["--remote_header=\u003cREDACTED\u003e","--foo=SAFE"]`, buildMetadata.Metadata["EXPLICIT_COMMAND_LINE"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use <
and >
since they are plain ascii chars?
assert.Equal(t, `["--remote_header=\u003cREDACTED\u003e","--foo=SAFE"]`, buildMetadata.Metadata["EXPLICIT_COMMAND_LINE"]) | |
assert.Equal(t, `["--remote_header=<REDACTED>","--foo=SAFE"]`, buildMetadata.Metadata["EXPLICIT_COMMAND_LINE"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this initially, but it seems the JSON marshalling / unmarshalling code converts these into \u003c
and \u003e
. They're rendered correctly in the UI so it doesn't seem like a huge deal (there's a way to enable this escaping, but I'd kinda rather leave it enabled because I'm sure there's some reason for it).
What I was really looking for was an assert.Equal that behaves more like strings.EqualFold()
but couldn't find anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd kinda rather leave it enabled because I'm sure there's some reason for it
ah I bet it's to support dumping these into HTML templates without the <
being treated as a tag or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, TIL: https://codepen.io/bduffs/pen/LYXoKoP
I guess the HTML parser isn't aware of what's going on inside the <script>
and is just blindly looking for the closing </script>
.
func stripExplicitCommandLineFromCmdLine(tokens []string) { | ||
for i, token := range tokens { | ||
if strings.HasPrefix(token, buildMetadataOptionPrefix+explicitCommandLineName+"=") { | ||
tokens[i] = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearing out the arg (instead of dropping) might cause issues later, since a literal ""
argument is treated by bazel as an error, but seems fine for now since we won't actually render the ""
in the UI. just something to be aware of in case we see errors in the future
ERROR: Skipping '': invalid target name '': empty target name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, this should just be for UI rendering - we can switch to filtering if it causes issues.
Co-authored-by: Brandon Duffany <brandon@buildbuddy.io>
Explicitly redacts
EXPLICIT_COMMAND_LINE
in the BuildMetadata event so it can be rendered in the UI with<redacted>
for any command line options that should be redacted.In all other events, it's just dropped so we don't have to deal with parsing it.
Fixes: https://github.com/buildbuddy-io/buildbuddy-internal/issues/2540