From 17b42e1c7b345ba5f8f0a89c6695f328b261ee7d Mon Sep 17 00:00:00 2001 From: Fokion Sotiropoulos Date: Wed, 17 May 2023 23:26:51 +0100 Subject: [PATCH] hide other areas that we have the variables visible Signed-off-by: Fokion Sotiropoulos --- venom_output.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/venom_output.go b/venom_output.go index aa669dca..86ade9e5 100644 --- a/venom_output.go +++ b/venom_output.go @@ -24,16 +24,21 @@ func init() { } } -func (v *Venom) CleanUpSecrets(testSuite *TestSuite) *TestSuite { +func (v *Venom) CleanUpSecrets(testSuite TestSuite) TestSuite { for _, testCase := range testSuite.TestCases { - ctx := v.processSecrets(context.Background(), testSuite, &testCase) + ctx := v.processSecrets(context.Background(), &testSuite, &testCase) for _, result := range testCase.TestStepResults { for i, v := range result.ComputedVars { result.ComputedVars[i] = HideSensitive(ctx, v) } for i, v := range result.InputVars { - result.ComputedVars[i] = HideSensitive(ctx, v) + result.InputVars[i] = HideSensitive(ctx, v) + } + for i, v := range testCase.TestCaseInput.Vars { + testCase.TestCaseInput.Vars[i] = HideSensitive(ctx, v) } + result.Raw = HideSensitive(ctx, fmt.Sprint(result.Raw)) + result.Interpolated = HideSensitive(ctx, fmt.Sprint(result.Interpolated)) result.Systemout = HideSensitive(ctx, result.Systemout) result.Systemerr = HideSensitive(ctx, result.Systemerr) } @@ -46,7 +51,7 @@ func (v *Venom) OutputResult() error { if v.OutputDir == "" { return nil } - + cleanedTs := []TestSuite{} for i := range v.Tests.TestSuites { tcFiltered := []TestCase{} for _, tc := range v.Tests.TestSuites[i].TestCases { @@ -55,9 +60,11 @@ func (v *Venom) OutputResult() error { } } v.Tests.TestSuites[i].TestCases = tcFiltered + ts := v.CleanUpSecrets(v.Tests.TestSuites[i]) + cleanedTs = append(cleanedTs, ts) testsResult := &Tests{ - TestSuites: []TestSuite{v.Tests.TestSuites[i]}, + TestSuites: []TestSuite{ts}, Status: v.Tests.Status, NbTestsuitesFail: v.Tests.NbTestsuitesFail, NbTestsuitesPass: v.Tests.NbTestsuitesPass, @@ -95,7 +102,7 @@ func (v *Venom) OutputResult() error { log.Fatalf("Error: you have to use the --html-report flag") } - fname := strings.TrimSuffix(v.Tests.TestSuites[i].Filepath, filepath.Ext(v.Tests.TestSuites[i].Filepath)) + fname := strings.TrimSuffix(ts.Filepath, filepath.Ext(ts.Filepath)) fname = strings.ReplaceAll(fname, "/", "_") filename := path.Join(v.OutputDir, "test_results_"+fname+"."+v.OutputFormat) if err := os.WriteFile(filename, data, 0600); err != nil { @@ -106,7 +113,7 @@ func (v *Venom) OutputResult() error { if v.HtmlReport { testsResult := &Tests{ - TestSuites: v.Tests.TestSuites, + TestSuites: cleanedTs, Status: v.Tests.Status, NbTestsuitesFail: v.Tests.NbTestsuitesFail, NbTestsuitesPass: v.Tests.NbTestsuitesPass,