Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan repository - show license violation on Github security issues #575

Merged
merged 11 commits into from
Nov 16, 2023
Prev Previous commit
Next Next commit
cleanup tests
  • Loading branch information
attiasas committed Nov 15, 2023
commit 03caadab05546d7eeb4702856b25e54ccef151cf
61 changes: 0 additions & 61 deletions scanpullrequest/scanpullrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,67 +220,6 @@ func TestGetNewViolationsCaseNoNewViolations(t *testing.T) {
assert.Len(t, licenseViolations, 0)
}

func TestGetAllVulnerabilities(t *testing.T) {
// Current scan with 2 vulnerabilities - XRAY-1 and XRAY-2
currentScan := services.ScanResponse{
Vulnerabilities: []services.Vulnerability{
{
IssueId: "XRAY-1",
Summary: "summary-1",
Severity: "high",
Components: map[string]services.Component{"component-A": {}, "component-B": {}},
},
{
IssueId: "XRAY-2",
Summary: "summary-2",
Severity: "low",
Components: map[string]services.Component{"component-C": {}, "component-D": {}},
},
},
}

expected := []formats.VulnerabilityOrViolationRow{
{
Summary: "summary-1",
IssueId: "XRAY-1",
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
SeverityDetails: formats.SeverityDetails{Severity: "high"},
ImpactedDependencyName: "component-A",
},
},
{
Summary: "summary-1",
IssueId: "XRAY-1",
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
SeverityDetails: formats.SeverityDetails{Severity: "high"},
ImpactedDependencyName: "component-B",
},
},
{
Summary: "summary-2",
IssueId: "XRAY-2",
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
SeverityDetails: formats.SeverityDetails{Severity: "low"},
ImpactedDependencyName: "component-C",
},
},
{
Summary: "summary-2",
IssueId: "XRAY-2",
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
SeverityDetails: formats.SeverityDetails{Severity: "low"},
ImpactedDependencyName: "component-D",
},
},
}
// Run createAllIssuesRows and make sure that XRAY-1 and XRAY-2 vulnerabilities exists in the results
vulnerabilities, licenses, err := getScanVulnerabilitiesRows(&xrayutils.Results{ScaResults: []xrayutils.ScaScanResult{xrayutils.ScaScanResult{XrayResults: []services.ScanResponse{currentScan}}}, ExtendedScanResults: &xrayutils.ExtendedScanResults{}}, nil)
assert.NoError(t, err)
assert.Len(t, vulnerabilities, 4)
assert.Len(t, licenses, 0)
assert.ElementsMatch(t, expected, vulnerabilities)
}

func TestGetNewVulnerabilities(t *testing.T) {
// Previous scan with only one vulnerability - XRAY-1
previousScan := services.ScanResponse{
Expand Down
Loading