-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -141,6 +141,20 @@ func TestRedactMetadata_StructuredCommandLine(t *testing.T) { | |||||
redactor.RedactMetadata(event) | ||||||
|
||||||
assert.Empty(t, getCommandLineOptions(event), "--default_override options should be removed") | ||||||
|
||||||
// EXPLICIT_COMMAND_LINE flags should be dropped altogether. | ||||||
|
||||||
option = &clpb.Option{ | ||||||
OptionName: "build_metadata", | ||||||
OptionValue: `EXPLICIT_COMMAND_LINE=["secrets"]`, | ||||||
CombinedForm: `--build_metadata=EXPLICIT_COMMAND_LINE=["secrets"]`, | ||||||
} | ||||||
event = structuredCommandLineEvent(option) | ||||||
assert.NotEmpty(t, getCommandLineOptions(event), "sanity check: EXPLICIT_COMMAND_LINE should be an option before redacting") | ||||||
|
||||||
redactor.RedactMetadata(event) | ||||||
|
||||||
assert.Empty(t, getCommandLineOptions(event), "EXPLICIT_COMMAND_LINE should be removed") | ||||||
} | ||||||
|
||||||
func TestRedactMetadata_OptionsParsed_StripsURLSecretsAndRemoteHeaders(t *testing.T) { | ||||||
|
@@ -153,6 +167,7 @@ func TestRedactMetadata_OptionsParsed_StripsURLSecretsAndRemoteHeaders(t *testin | |||||
"--bes_header=foo=TOPSECRET", | ||||||
"--build_metadata=PATTERN=@//foo,NAME=@bar,SECRET=TOPSECRET@", | ||||||
"--some_other_flag=SUBFLAG=@//foo", | ||||||
"--build_metadata=EXPLICIT_COMMAND_LINE=[\"SECRET\"]", | ||||||
}, | ||||||
ExplicitCmdLine: []string{ | ||||||
"213wZJyTUyhXkj381312@explicit", | ||||||
|
@@ -161,6 +176,7 @@ func TestRedactMetadata_OptionsParsed_StripsURLSecretsAndRemoteHeaders(t *testin | |||||
"--bes_header=foo=TOPSECRET", | ||||||
"--build_metadata=PATTERN=@//foo,NAME=@bar,SECRET=TOPSECRET_EXPLICIT@", | ||||||
"--some_other_flag=SUBFLAG=@//foo", | ||||||
"--build_metadata=EXPLICIT_COMMAND_LINE=[\"SECRET\"]", | ||||||
}, | ||||||
} | ||||||
|
||||||
|
@@ -177,6 +193,7 @@ func TestRedactMetadata_OptionsParsed_StripsURLSecretsAndRemoteHeaders(t *testin | |||||
"--bes_header=<REDACTED>", | ||||||
"--build_metadata=PATTERN=@//foo,NAME=@bar,SECRET=", | ||||||
"--some_other_flag=//foo", | ||||||
"", | ||||||
}, | ||||||
optionsParsed.CmdLine) | ||||||
assert.Equal( | ||||||
|
@@ -188,6 +205,7 @@ func TestRedactMetadata_OptionsParsed_StripsURLSecretsAndRemoteHeaders(t *testin | |||||
"--bes_header=<REDACTED>", | ||||||
"--build_metadata=PATTERN=@//foo,NAME=@bar,SECRET=", | ||||||
"--some_other_flag=//foo", | ||||||
"", | ||||||
}, | ||||||
optionsParsed.ExplicitCmdLine) | ||||||
} | ||||||
|
@@ -271,9 +289,10 @@ func TestRedactMetadata_BuildMetadata_StripsURLSecrets(t *testing.T) { | |||||
redactor := redact.NewStreamingRedactor(testenv.GetTestEnv(t)) | ||||||
buildMetadata := &bespb.BuildMetadata{ | ||||||
Metadata: map[string]string{ | ||||||
"ALLOW_ENV": "SHELL", | ||||||
"ROLE": "METADATA_CI", | ||||||
"REPO_URL": "https://USERNAME:PASSWORD@github.com/buildbuddy-io/metadata_repo_url", | ||||||
"ALLOW_ENV": "SHELL", | ||||||
"ROLE": "METADATA_CI", | ||||||
"REPO_URL": "https://USERNAME:PASSWORD@github.com/buildbuddy-io/metadata_repo_url", | ||||||
"EXPLICIT_COMMAND_LINE": `["--remote_header=x-buildbuddy-platform.container-registry-password=SECRET", "--foo=SAFE"]`, | ||||||
}, | ||||||
} | ||||||
|
||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I think you can use
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 What I was really looking for was an assert.Equal that behaves more like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ah I bet it's to support dumping these into HTML templates without the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
} | ||||||
|
||||||
func TestRedactMetadata_WorkspaceStatus_StripsRepoURLCredentials(t *testing.T) { | ||||||
|
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 futureThere 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.