Skip to content

Commit

Permalink
Fixing linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
diogo-fjrocha committed Apr 2, 2024
1 parent 18f8f08 commit 483a721
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
21 changes: 11 additions & 10 deletions internal/commands/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import (
const fileName = "cx_result"

const (
resultsCommand = "results"
codeBashingCommand = "codebashing"
vulnerabilityValue = "Reflected XSS All Clients"
languageValue = "PHP"
cweValue = "79"
jsonValue = "json"
tableValue = "table"
listValue = "list"
resultsCommand = "results"
codeBashingCommand = "codebashing"
vulnerabilityValue = "Reflected XSS All Clients"
languageValue = "PHP"
cweValue = "79"
jsonValue = "json"
tableValue = "table"
listValue = "list"
secretDetectionLine = "| Secret Detection 5 3 2 0 Completed |"
)

func flag(f string) string {
Expand Down Expand Up @@ -408,7 +409,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormatWithScsPartial(t *testing.T) {
scsSummary := "| SCS 5 3 2 0 Partial |"
assert.Equal(t, strings.Contains(cleanString, scsSummary), true,
"Expected SCS summary:"+scsSummary)
secretDetectionSummary := "| Secret Detection 5 3 2 0 Completed |"
secretDetectionSummary := secretDetectionLine
assert.Equal(t, strings.Contains(cleanString, secretDetectionSummary), true,
"Expected Secret Detection summary:"+secretDetectionSummary)
scorecardSummary := "| Scorecard 0 0 0 0 Failed |"
Expand All @@ -427,7 +428,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormatWithScsScorecardNotScanned(t *
scsSummary := "| SCS 5 3 2 0 Completed |"
assert.Equal(t, strings.Contains(stdoutString, scsSummary), true,
"Expected SCS summary:"+scsSummary)
secretDetectionSummary := "| Secret Detection 5 3 2 0 Completed |"
secretDetectionSummary := secretDetectionLine
assert.Equal(t, strings.Contains(stdoutString, secretDetectionSummary), true,
"Expected Secret Detection summary:"+secretDetectionSummary)
scorecardSummary := "| Scorecard - - - - - |"
Expand Down
10 changes: 6 additions & 4 deletions internal/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func createASTTestCommand() *cobra.Command {
)
}

func createASTTestCommandWithScs(ScsScanned, scsScanPartial, scorecardScanned bool) *cobra.Command {
func createASTTestCommandWithScs(scsScanned, scsScanPartial, scorecardScanned bool) *cobra.Command {
applicationWrapper := &mock.ApplicationsMockWrapper{}
scansMockWrapper := &mock.ScansMockWrapper{HasSCS: ScsScanned}
scansMockWrapper := &mock.ScansMockWrapper{HasSCS: scsScanned}
resultsSbomWrapper := &mock.ResultsSbomWrapper{}
resultsPdfWrapper := &mock.ResultsPdfWrapper{}
scansMockWrapper.Running = true
Expand Down Expand Up @@ -205,8 +205,10 @@ func executeRedirectedOsStdoutTestCommand(cmd *cobra.Command, args ...string) (b
w.Close()
os.Stdout = old
var buffer bytes.Buffer
io.Copy(&buffer, r)

_, errCopy := io.Copy(&buffer, r)
if errCopy != nil {
return buffer, errCopy
}
return buffer, err
}

Expand Down
6 changes: 4 additions & 2 deletions internal/commands/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,8 @@ func runCreateScanCommand(
} else {
logger.PrintIfVerbose("Skipping policy evaluation")
}
err = createReportsAfterScan(cmd, scanResponseModel.ID, scansWrapper, resultsSbomWrapper, resultsPdfReportsWrapper, resultsWrapper, risksOverviewWrapper, scsScanOverviewWrapper, policyResponseModel)
err = createReportsAfterScan(cmd, scanResponseModel.ID, scansWrapper, resultsSbomWrapper, resultsPdfReportsWrapper, resultsWrapper,
risksOverviewWrapper, scsScanOverviewWrapper, policyResponseModel)
if err != nil {
return err
}
Expand All @@ -1591,7 +1592,8 @@ func runCreateScanCommand(
return err
}
} else {
err = createReportsAfterScan(cmd, scanResponseModel.ID, scansWrapper, resultsSbomWrapper, resultsPdfReportsWrapper, resultsWrapper, risksOverviewWrapper, scsScanOverviewWrapper, nil)
err = createReportsAfterScan(cmd, scanResponseModel.ID, scansWrapper, resultsSbomWrapper, resultsPdfReportsWrapper, resultsWrapper,
risksOverviewWrapper, scsScanOverviewWrapper, nil)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion internal/wrappers/mock/scan-overview-mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,4 @@ func (s ScanOverviewMockWrapper) GetSCSOverviewByScanID(scanID string) (
},
},
}, nil, nil

}
4 changes: 2 additions & 2 deletions internal/wrappers/results-summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func (engineSummary *EngineResultSummary) Increment(level string) {
}
}

func (summary *ResultSummary) UpdateEngineResultSummary(engineType, severity string) {
summary.EnginesResult[engineType].Increment(severity)
func (r *ResultSummary) UpdateEngineResultSummary(engineType, severity string) {
r.EnginesResult[engineType].Increment(severity)
}

func (r *ResultSummary) HasEngine(engine string) bool {
Expand Down

0 comments on commit 483a721

Please sign in to comment.