diff --git a/testdata/messages/summarycomment/summary/summary_both_simplified.md b/testdata/messages/summarycomment/summary/summary_both_simplified.md index 0f8be7f67..c7c9bf2c2 100644 --- a/testdata/messages/summarycomment/summary/summary_both_simplified.md +++ b/testdata/messages/summarycomment/summary/summary_both_simplified.md @@ -4,12 +4,12 @@ ## 📗 Scan Summary --- -- Frogbot scanned for violations and vulnerabilities and found 9 issues +- Frogbot scanned for violations and vulnerabilities and found 13 issues | Scan Category | Status | Security Issues | | --------------------- | :-----------------------------------: | ----------------------------------- | -| **Software Composition Analysis** | ✅ Done | 6 Issues Found: ❗ī¸ 1 Critical, 🔴 2 High, 🟠 1 Medium, 🟡 1 Low, âšĒī¸ 1 Unknown | +| **Software Composition Analysis** | ✅ Done | 9 Issues Found: ❗ī¸ 2 Critical, 🔴 3 High, 🟠 2 Medium, 🟡 1 Low, âšĒī¸ 1 Unknown | | **Contextual Analysis** | ✅ Done | - | -| **Static Application Security Testing (SAST)** | ✅ Done | 3 Issues Found: 🔴 2 High, 🟡 1 Low | +| **Static Application Security Testing (SAST)** | ✅ Done | 4 Issues Found: 🔴 3 High, 🟡 1 Low | | **Secrets** | ✅ Done | - | | **Infrastructure as Code (IaC)** | ℹī¸ Not Scanned | - | \ No newline at end of file diff --git a/testdata/messages/summarycomment/summary/summary_both_standard.md b/testdata/messages/summarycomment/summary/summary_both_standard.md index 48c8ae3b6..30f1b29a4 100644 --- a/testdata/messages/summarycomment/summary/summary_both_standard.md +++ b/testdata/messages/summarycomment/summary/summary_both_standard.md @@ -1,11 +1,11 @@ ## 📗 Scan Summary -- Frogbot scanned for violations and vulnerabilities and found 9 issues +- Frogbot scanned for violations and vulnerabilities and found 13 issues | Scan Category | Status | Security Issues | | --------------------- | :-----------------------------------: | ----------------------------------- | -| **Software Composition Analysis** | ✅ Done |
6 Issues Found 1 Critical
2 High
1 Medium
1 Low
1 Unknown
| +| **Software Composition Analysis** | ✅ Done |
9 Issues Found 2 Critical
3 High
2 Medium
1 Low
1 Unknown
| | **Contextual Analysis** | ✅ Done | - | -| **Static Application Security Testing (SAST)** | ✅ Done |
3 Issues Found 2 High
1 Low
| +| **Static Application Security Testing (SAST)** | ✅ Done |
4 Issues Found 3 High
1 Low
| | **Secrets** | ✅ Done | - | | **Infrastructure as Code (IaC)** | ℹī¸ Not Scanned | - | \ No newline at end of file diff --git a/testdata/messages/summarycomment/summary/summary_violation_simplified.md b/testdata/messages/summarycomment/summary/summary_violation_simplified.md index 52c74bae9..58185dd84 100644 --- a/testdata/messages/summarycomment/summary/summary_violation_simplified.md +++ b/testdata/messages/summarycomment/summary/summary_violation_simplified.md @@ -4,12 +4,12 @@ ## 📗 Scan Summary --- -- Frogbot scanned for violations and found 9 issues +- Frogbot scanned for violations and found 4 issues | Scan Category | Status | Security Issues | | --------------------- | :-----------------------------------: | ----------------------------------- | -| **Software Composition Analysis** | ✅ Done | 6 Issues Found: ❗ī¸ 1 Critical, 🔴 2 High, 🟠 1 Medium, 🟡 1 Low, âšĒī¸ 1 Unknown | +| **Software Composition Analysis** | ✅ Done | 3 Issues Found: ❗ī¸ 1 Critical, 🔴 1 High, 🟠 1 Medium | | **Contextual Analysis** | ✅ Done | - | -| **Static Application Security Testing (SAST)** | ✅ Done | 3 Issues Found: 🔴 2 High, 🟡 1 Low | +| **Static Application Security Testing (SAST)** | ✅ Done | 1 Issues Found: 🔴 1 High | | **Secrets** | ✅ Done | - | | **Infrastructure as Code (IaC)** | ℹī¸ Not Scanned | - | \ No newline at end of file diff --git a/testdata/messages/summarycomment/summary/summary_violation_standard.md b/testdata/messages/summarycomment/summary/summary_violation_standard.md index 6f005e487..245da163e 100644 --- a/testdata/messages/summarycomment/summary/summary_violation_standard.md +++ b/testdata/messages/summarycomment/summary/summary_violation_standard.md @@ -1,11 +1,11 @@ ## 📗 Scan Summary -- Frogbot scanned for violations and found 9 issues +- Frogbot scanned for violations and found 4 issues | Scan Category | Status | Security Issues | | --------------------- | :-----------------------------------: | ----------------------------------- | -| **Software Composition Analysis** | ✅ Done |
6 Issues Found 1 Critical
2 High
1 Medium
1 Low
1 Unknown
| +| **Software Composition Analysis** | ✅ Done |
3 Issues Found 1 Critical
1 High
1 Medium
| | **Contextual Analysis** | ✅ Done | - | -| **Static Application Security Testing (SAST)** | ✅ Done |
3 Issues Found 2 High
1 Low
| +| **Static Application Security Testing (SAST)** | ✅ Done |
1 Issues Found 1 High
| | **Secrets** | ✅ Done | - | | **Infrastructure as Code (IaC)** | ℹī¸ Not Scanned | - | \ No newline at end of file diff --git a/utils/outputwriter/outputcontent_test.go b/utils/outputwriter/outputcontent_test.go index 51a0b1f4c..19c64be1f 100644 --- a/utils/outputwriter/outputcontent_test.go +++ b/utils/outputwriter/outputcontent_test.go @@ -234,9 +234,9 @@ func TestScanSummaryContent(t *testing.T) { testCases := []struct { name string - context results.ResultContext includeSecrets bool scanStatus formats.ScanStatus + context results.ResultContext issues issues.ScansIssuesCollection cases []OutputTestCase }{ @@ -261,7 +261,7 @@ func TestScanSummaryContent(t *testing.T) { name: "Vulnerabilities", issues: testIssues, scanStatus: testScanStatus, - context: results.ResultContext{GitRepoHttpsCloneUrl: "url", IncludeVulnerabilities: true}, + context: results.ResultContext{IncludeVulnerabilities: true}, cases: []OutputTestCase{ { name: "Standard output", @@ -338,6 +338,7 @@ func TestScanSummaryContent(t *testing.T) { t.Run(tc.name+"_"+test.name, func(t *testing.T) { expectedOutput := GetExpectedTestOutput(t, test) tc.issues.ScanStatus = tc.scanStatus + tc.issues.ResultContext = tc.context output := ScanSummaryContent(tc.issues, tc.context, tc.includeSecrets, test.writer) assert.Equal(t, expectedOutput, output) }) diff --git a/utils/scandetails.go b/utils/scandetails.go index 9d673331a..631464abd 100644 --- a/utils/scandetails.go +++ b/utils/scandetails.go @@ -70,11 +70,6 @@ func (sc *ScanDetails) SetResultsContext(httpCloneUrl string, watches []string, return sc } -// func (sc *ScanDetails) SetXrayGraphScanParams(httpCloneUrl string, watches []string, jfrogProjectKey string, includeVulnerabilities, includeLicenses bool) *ScanDetails { -// sc.XrayGraphScanParams = createXrayScanParams(httpCloneUrl, watches, jfrogProjectKey, includeVulnerabilities, includeLicenses) -// return sc -// } - func (sc *ScanDetails) SetFixableOnly(fixable bool) *ScanDetails { sc.fixableOnly = fixable return sc diff --git a/utils/scandetails_test.go b/utils/scandetails_test.go index 5617350ce..36f486e8f 100644 --- a/utils/scandetails_test.go +++ b/utils/scandetails_test.go @@ -1,73 +1,11 @@ package utils import ( - "github.com/stretchr/testify/assert" "path/filepath" "testing" -) -func TestCreateResultsContext(t *testing.T) { - testCases := []struct { - name string - httpCloneUrl string - watches []string - jfrogProjectKey string - includeVulnerabilities bool - includeLicenses bool - }{ - { - name: "Violations and Vulnerabilities", - httpCloneUrl: "http://localhost:8080/my-user/my-project.git", - watches: []string{"watch-1", "watch-2"}, - jfrogProjectKey: "project", - includeVulnerabilities: true, - includeLicenses: true, - }, - { - name: "Violations - Project key", - httpCloneUrl: "", - watches: nil, - jfrogProjectKey: "project", - includeVulnerabilities: false, - includeLicenses: true, - }, - { - name: "Violations - Watches", - httpCloneUrl: "", - watches: []string{"watch-1", "watch-2"}, - jfrogProjectKey: "", - includeVulnerabilities: false, - includeLicenses: false, - }, - { - name: "Violations - GitInfoContext", - httpCloneUrl: "http://localhost:8080/my-user/my-project.git", - watches: nil, - jfrogProjectKey: "", - includeVulnerabilities: false, - includeLicenses: false, - }, - { - name: "Vulnerabilities", - httpCloneUrl: "", - watches: nil, - jfrogProjectKey: "", - includeVulnerabilities: true, - includeLicenses: true, - }, - } - for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { - scanDetails := &ScanDetails{} - scanDetails.SetResultsContext(testCase.httpCloneUrl, testCase.watches, testCase.jfrogProjectKey, testCase.includeVulnerabilities, testCase.includeLicenses) - assert.Equal(t, testCase.httpCloneUrl, scanDetails.XscGitInfoContext.GitRepoHttpsCloneUrl) - assert.Equal(t, testCase.watches, scanDetails.Watches) - assert.Equal(t, testCase.jfrogProjectKey, scanDetails.ProjectKey) - assert.Equal(t, testCase.includeVulnerabilities, scanDetails.IncludeVulnerabilities) - assert.Equal(t, testCase.includeLicenses, scanDetails.IncludeLicenses) - }) - } -} + "github.com/stretchr/testify/assert" +) func TestGetFullPathWorkingDirs(t *testing.T) { sampleProject := Project{