Skip to content

Commit

Permalink
Remove default from unsupported agents for SCS results (AST-68004) (#912
Browse files Browse the repository at this point in the history
)

* Remove astCli from unsupported agents for scs results

* change brnach name

* Fix lint and add unit test

---------

Co-authored-by: Or Shamir Checkmarx <[email protected]>
  • Loading branch information
Korjen97 and OrShamirCM authored Nov 5, 2024
1 parent 87ba5a9 commit ae2ad00
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/commands/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,6 @@ func filterResultsByType(results *wrappers.ScanResultsCollection, excludedTypes

func filterScsResultsByAgent(results *wrappers.ScanResultsCollection, agent string) *wrappers.ScanResultsCollection {
unsupportedTypesByAgent := map[string][]string{
commonParams.DefaultAgent: {},
commonParams.VSCodeAgent: {commonParams.SCSScorecardType},
commonParams.JetbrainsAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
commonParams.EclipseAgent: {commonParams.SCSScorecardType, commonParams.SCSSecretDetectionType},
Expand Down
37 changes: 37 additions & 0 deletions internal/commands/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1520,3 +1520,40 @@ func TestRunGetResultsByScanIdSummaryHtmlFormat_SCSFlagNotEnabled_SCSNotPresentI
removeFileBySuffix(t, "html")
mock.SetScsMockVarsToDefault()
}

func TestFilterScsResultsByAgent_ShouldExcludeSCSAndContainers(t *testing.T) {
results := &wrappers.ScanResultsCollection{
Results: []*wrappers.ScanResult{
{Type: params.SCSScorecardType},
{Type: params.ScsType},
{Type: params.ContainersType},
{Type: params.SastType},
},
}

filteredResults := filterScsResultsByAgent(results, params.JetbrainsAgent)

hasSCSScorecard := false
hasSCS := false
hasContainers := false
hasSAST := false

for _, result := range filteredResults.Results {
switch result.Type {
case params.SCSScorecardType:
hasSCSScorecard = true
case params.ScsType:
hasSCS = true
case params.ContainersType:
hasContainers = true
case params.SastType:
hasSAST = true
}
}

assert.Assert(t, !hasSCSScorecard, "Expected SCSScorecard type to be excluded for Jetbrains agent")
assert.Assert(t, hasSCS, "Expected SCS type to be included in Jetbrains agent results")
assert.Assert(t, hasContainers, "Expected Containers type to be included in Jetbrains agent results")
assert.Assert(t, hasSAST, "Expected SAST type to be included in Jetbrains agent results")
assert.Equal(t, len(filteredResults.Results), 3, "Expected only 3 results after filtering for Jetbrains agent")
}

0 comments on commit ae2ad00

Please sign in to comment.