Skip to content

Commit

Permalink
Adds Severity Field for Licenses Violations for Pull Request Scans (#672
Browse files Browse the repository at this point in the history
)
  • Loading branch information
imranzunzani authored Apr 9, 2024
1 parent 00489de commit 1098871
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Binary file modified images/violated-licenses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## ⚖️ Violated Licenses

---
| LICENSE | DIRECT DEPENDENCIES | IMPACTED DEPENDENCY |
| :---------------------: | :-----------------------------------: | :-----------------------------------: |
| License1 | Comp1 1.0 | Dep1 2.0 |
| License2 | root 1.0.0, minimatch 1.2.3 | Dep2 3.0 |
| SEVERITY | LICENSE | DIRECT DEPENDENCIES | IMPACTED DEPENDENCY |
| :---------------------: | :-----------------------------------: | :-----------------------------------: | :-----------------------------------: |
| High | License1 | Comp1 1.0 | Dep1 2.0 |
| High | License2 | root 1.0.0, minimatch 1.2.3 | Dep2 3.0 |
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
## ⚖️ Violated Licenses
<div align='center'>

| LICENSE | DIRECT DEPENDENCIES | IMPACTED DEPENDENCY |
| :---------------------: | :-----------------------------------: | :-----------------------------------: |
| License1 | Comp1 1.0 | Dep1 2.0 |
| License2 | root 1.0.0<br>minimatch 1.2.3 | Dep2 3.0 |
| SEVERITY | LICENSE | DIRECT DEPENDENCIES | IMPACTED DEPENDENCY |
| :---------------------: | :-----------------------------------: | :-----------------------------------: | :-----------------------------------: |
| High | License1 | Comp1 1.0 | Dep1 2.0 |
| High | License2 | root 1.0.0<br>minimatch 1.2.3 | Dep2 3.0 |

</div>
3 changes: 2 additions & 1 deletion utils/outputwriter/outputcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ func LicensesContent(licenses []formats.LicenseRow, writer OutputWriter) string
var contentBuilder strings.Builder
WriteContent(&contentBuilder, writer.MarkAsTitle("⚖️ Violated Licenses", 2))
// Content
table := NewMarkdownTable("LICENSE", "DIRECT DEPENDENCIES", "IMPACTED DEPENDENCY").SetDelimiter(writer.Separator())
table := NewMarkdownTable("SEVERITY", "LICENSE", "DIRECT DEPENDENCIES", "IMPACTED DEPENDENCY").SetDelimiter(writer.Separator())
for _, license := range licenses {
table.AddRowWithCellData(
NewCellData(license.Severity),
NewCellData(license.LicenseKey),
getDirectDependenciesCellData("%s %s", license.Components),
NewCellData(fmt.Sprintf("%s %s", license.ImpactedDependencyName, license.ImpactedDependencyVersion)),
Expand Down
7 changes: 7 additions & 0 deletions utils/outputwriter/outputcontent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,13 @@ func TestLicensesContent(t *testing.T) {
{
LicenseKey: "License1",
ImpactedDependencyDetails: formats.ImpactedDependencyDetails{

Components: []formats.ComponentRow{{Name: "Comp1", Version: "1.0"}},
ImpactedDependencyName: "Dep1",
ImpactedDependencyVersion: "2.0",
SeverityDetails: formats.SeverityDetails{
Severity: "High",
},
},
},
{
Expand All @@ -455,6 +459,9 @@ func TestLicensesContent(t *testing.T) {
},
ImpactedDependencyName: "Dep2",
ImpactedDependencyVersion: "3.0",
SeverityDetails: formats.SeverityDetails{
Severity: "High",
},
},
},
},
Expand Down

0 comments on commit 1098871

Please sign in to comment.