Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/cmd/openshift-tests/run-upgrade/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func (o *RunUpgradeSuiteOptions) UpgradeTestPreSuite() error {
if err := clusterdiscovery.InitializeTestFramework(exutil.TestContext, config, o.GinkgoRunSuiteOptions.DryRun); err != nil {
return err
}
klog.V(4).Infof("Loaded test configuration: %#v", exutil.TestContext)
// Redact the bearer token exposure
testContextString := fmt.Sprintf("%#v", exutil.TestContext)
redactedTestContext := exutil.RedactBearerToken(testContextString)
klog.V(4).Infof("Loaded test configuration: %s", redactedTestContext)

return nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/test/extensions/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func InitializeOpenShiftTestsExtensionFramework() (*extension.Registry, *extensi
if err := clusterdiscovery.InitializeTestFramework(exutil.TestContext, config, false); err != nil {
panic(err)
}
klog.V(4).Infof("Loaded test configuration: %#v", exutil.TestContext)
// Redact the bearer token exposure
testContextString := fmt.Sprintf("%#v", exutil.TestContext)
redactedTestContext := exutil.RedactBearerToken(testContextString)
klog.V(4).Infof("Loaded test configuration: %s", redactedTestContext)

exutil.TestContext.ReportDir = os.Getenv("TEST_JUNIT_DIR")

Expand Down
9 changes: 3 additions & 6 deletions test/extended/util/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,13 +1040,10 @@ func (c *CLI) start(stdOutBuff, stdErrBuff *bytes.Buffer) (*exec.Cmd, error) {
return cmd, err
}

var reToken = regexp.MustCompile(`(?i)(Authorization:\s*Bearer\s+)[^\s"]+|((BearerToken:\s*")[^"]+)`)

func RedactBearerToken(args string) string {
if strings.Contains(args, "Authorization: Bearer") {
// redact bearer token
re := regexp.MustCompile(`Authorization:\s+Bearer.*\s+`)
args = re.ReplaceAllString(args, "Authorization: Bearer <redacted> ")
}
return args
return reToken.ReplaceAllString(args, `${1}${3}<redacted>`)
}

// getStartingIndexForLastN calculates a byte offset in a byte slice such that when using
Expand Down