Skip to content

Commit a20fa43

Browse files
committed
add LicenseViolationRow
1 parent a10364b commit a20fa43

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

utils/formats/conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func ConvertToVulnerabilityTableRow(rows []VulnerabilityOrViolationRow) (tableRo
102102
return
103103
}
104104

105-
func ConvertToLicenseViolationTableRow(rows []LicenseRow) (tableRows []licenseViolationTableRow) {
105+
func ConvertToLicenseViolationTableRow(rows []LicenseViolationRow) (tableRows []licenseViolationTableRow) {
106106
for i := range rows {
107107
tableRows = append(tableRows, licenseViolationTableRow{
108108
licenseKey: rows[i].LicenseKey,

utils/formats/simplejsonapi.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
type SimpleJsonResults struct {
1414
Vulnerabilities []VulnerabilityOrViolationRow `json:"vulnerabilities"`
1515
SecurityViolations []VulnerabilityOrViolationRow `json:"securityViolations"`
16-
LicensesViolations []LicenseRow `json:"licensesViolations"`
16+
LicensesViolations []LicenseViolationRow `json:"licensesViolations"`
1717
Licenses []LicenseRow `json:"licenses"`
1818
OperationalRiskViolations []OperationalRiskViolationRow `json:"operationalRiskViolations"`
1919
SecretsVulnerabilities []SourceCodeRow `json:"secrets"`
@@ -54,9 +54,15 @@ type VulnerabilityOrViolationRow struct {
5454
Technology techutils.Technology `json:"-"`
5555
}
5656

57+
type LicenseViolationRow struct {
58+
LicenseRow
59+
Watch string `json:"watch,omitempty"`
60+
}
61+
5762
type LicenseRow struct {
5863
ImpactedDependencyDetails
5964
LicenseKey string `json:"licenseKey"`
65+
LicenseName string `json:"licenseName,omitempty"`
6066
ImpactPaths [][]ComponentRow `json:"impactPaths"`
6167
}
6268

utils/results/conversion/simplejsonparser/simplejsonparser.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ func (sjc *CmdResultsSimpleJsonConverter) ParseSast(_ results.ScanTarget, isViol
160160
return
161161
}
162162

163-
func PrepareSimpleJsonViolations(target results.ScanTarget, scaResponse services.ScanResponse, pretty, jasEntitled bool, applicabilityRuns ...*sarif.Run) ([]formats.VulnerabilityOrViolationRow, []formats.LicenseRow, []formats.OperationalRiskViolationRow, error) {
163+
func PrepareSimpleJsonViolations(target results.ScanTarget, scaResponse services.ScanResponse, pretty, jasEntitled bool, applicabilityRuns ...*sarif.Run) ([]formats.VulnerabilityOrViolationRow, []formats.LicenseViolationRow, []formats.OperationalRiskViolationRow, error) {
164164
var securityViolationsRows []formats.VulnerabilityOrViolationRow
165-
var licenseViolationsRows []formats.LicenseRow
165+
var licenseViolationsRows []formats.LicenseViolationRow
166166
var operationalRiskViolationsRows []formats.OperationalRiskViolationRow
167167
_, _, err := results.PrepareScaViolations(
168168
target,
@@ -241,17 +241,21 @@ func addSimpleJsonSecurityViolation(securityViolationsRows *[]formats.Vulnerabil
241241
}
242242
}
243243

244-
func addSimpleJsonLicenseViolation(licenseViolationsRows *[]formats.LicenseRow, pretty bool) results.ParseScaViolationFunc {
244+
func addSimpleJsonLicenseViolation(licenseViolationsRows *[]formats.LicenseViolationRow, pretty bool) results.ParseScaViolationFunc {
245245
return func(violation services.Violation, cves []formats.CveRow, applicabilityStatus jasutils.ApplicabilityStatus, severity severityutils.Severity, impactedPackagesName, impactedPackagesVersion, impactedPackagesType string, fixedVersion []string, directComponents []formats.ComponentRow, impactPaths [][]formats.ComponentRow) error {
246246
*licenseViolationsRows = append(*licenseViolationsRows,
247-
formats.LicenseRow{
248-
LicenseKey: getLicenseKey(violation.LicenseKey, violation.IssueId),
249-
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
250-
SeverityDetails: severityutils.GetAsDetails(severity, applicabilityStatus, pretty),
251-
ImpactedDependencyName: impactedPackagesName,
252-
ImpactedDependencyVersion: impactedPackagesVersion,
253-
ImpactedDependencyType: impactedPackagesType,
254-
Components: directComponents,
247+
formats.LicenseViolationRow{
248+
Watch: violation.WatchName,
249+
LicenseRow: formats.LicenseRow{
250+
LicenseKey: getLicenseKey(violation.LicenseKey, violation.IssueId),
251+
LicenseName: violation.LicenseName,
252+
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{
253+
SeverityDetails: severityutils.GetAsDetails(severity, applicabilityStatus, pretty),
254+
ImpactedDependencyName: impactedPackagesName,
255+
ImpactedDependencyVersion: impactedPackagesVersion,
256+
ImpactedDependencyType: impactedPackagesType,
257+
Components: directComponents,
258+
},
255259
},
256260
},
257261
)

0 commit comments

Comments
 (0)