Skip to content
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

Remove the experiment flag from output redactor #1452

Merged
merged 7 commits into from
Jun 21, 2021

Conversation

keithduncan
Copy link
Contributor

This will remove the output-redactor experiment flag and enable it all the time.

I have read through the redactor source code and added a couple more comments to help me understand it. It appears sound to me. I identified one issue which I added a test for to verify where if two needles share a prefix the shortest one will be redacted while the tail of the longer will be printed. This seems unlikely to occur in practice.

I have also ensured support for an empty list of redacted vars throughout so that (once the flag is changed) a lack of vars to redact will act as the switch to disable the Redactor being added to the log stream processing. This gives us an escape hatch should there be any issues.

Updated docs are in buildkite/docs#1073

If there is a trailing comma in a list we get empty string, now that will be dropped.

This will also return an empty array when specifying a blank string for list fields e.g.:

`--redact-vars=`
`--redact-vars=''`
`--redact-vars ''`
Ensure getValuesToRedact returns something sensible
@keithduncan
Copy link
Contributor Author

The remaining change to make here is in bootstrap.go setupRedactors to change how we enable / disable the redacting to be based on whether there are any variables to redact. I’m hoping to pair with @eleanorakh on that tomorrow.

if valueAsSlice, ok := value.([]string); ok {
normalizedSlice := []string{}

for _, value := range valueAsSlice {
// Split values with commas into fields
for _, normalized := range strings.Split(value, ",") {
if normalized == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has broader implications beyond the redaction change as it affects the other list type config parameters.

Those fields are:

  • Tags
  • TagsFromEC2MetaDataPaths
  • TagsFromGCPMetaDataPaths
  • Experiments

None of those convey semantic meaning to an empty string so I don’t have concerns that this will result in a change in practice.

@@ -65,3 +65,50 @@ func TestRedactorResetMidStream(t *testing.T) {
t.Errorf("Redaction failed: %s", buf.String())
}
}

func TestRedactorSlowLoris(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@keithduncan keithduncan marked this pull request as ready for review June 17, 2021 05:59
@keithduncan
Copy link
Contributor Author

I’ve added the last piece to this which is enabling the redactor code path based on whether there are any vars to redact. I’ve verified that it isn’t enabled when --redacted-vars= is provided on the command line 🎉

Copy link
Contributor

@yob yob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So great to see an experimental feature graduate to general availability 😍

I gave this a go, and confirmed the redaction was enabled without any experiment flags:

Screenshot from 2021-06-19 10-15-19

Do we definitely want to output the comment into every build log? I guess it might be nice to offer the visible reassurance that redaction is enabled?

@keithduncan
Copy link
Contributor Author

Do we definitely want to output the comment into every build log? I guess it might be nice to offer the visible reassurance that redaction is enabled?

Good point, I don’t think we should print our own stuff during the command step. I’ve conditionalised this logging on whether --debug is being used, I also had it print the env var name patterns it is matching:

Screen Shot 2021-06-21 at 11 13 23

@keithduncan keithduncan merged commit 59a9720 into main Jun 21, 2021
@keithduncan keithduncan deleted the keithduncan/enable-output-redactor branch June 21, 2021 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants