-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated documentation for EPSS * STDOUT now renders EPSS percentage * Centralization of enrichment * Initial HTML rendering of EPSS score * Proper HTML rendering * Updates testify * Updates test coverage * Version bump to 0.4.0 * Updates CodeQL to v2 * Updates workflow versions
- Loading branch information
Showing
25 changed files
with
312 additions
and
2,302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,13 @@ func TestBytes() []byte { | |
"version": "v0.6.0", | ||
"cpe": "cpe:2.3:a:CycloneDX:cyclonedx-go:v0.6.0:*:*:*:*:*:*:*", | ||
"purl": "pkg:golang/github.com/CycloneDX/[email protected]", | ||
"licenses": [ | ||
{ | ||
"license": { | ||
"id": "MIT" | ||
} | ||
} | ||
], | ||
"properties": [{ | ||
"name": "syft:package:metadataType", | ||
"value": "GolangBinMetadata" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,14 @@ func TestPurls(t *testing.T) { | |
assert.Len(t, purls, 1) | ||
assert.Equal(t, "pkg:golang/github.com/CycloneDX/[email protected]", purls[0]) | ||
} | ||
|
||
func TestLicenses(t *testing.T) { | ||
var sbom cyclone.BOM | ||
err := json.Unmarshal(TestBytes(), &sbom) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, sbom) | ||
|
||
licenses := Licenses(&sbom) | ||
|
||
assert.Len(t, licenses, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,10 @@ func TestPurls(t *testing.T) { | |
assert.Len(t, purls, 1) | ||
assert.Equal(t, "pkg:golang/github.com/CycloneDX/[email protected]", purls[0]) | ||
} | ||
|
||
func TestLicenses(t *testing.T) { | ||
var sbom BOM | ||
licenses := sbom.Licenses() | ||
|
||
assert.Len(t, licenses, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,10 @@ func TestPurls(t *testing.T) { | |
assert.Len(t, purls, 1) | ||
assert.Equal(t, "pkg:golang/github.com/CycloneDX/[email protected]", purls[0]) | ||
} | ||
|
||
func TestLicenses(t *testing.T) { | ||
var sbom BOM | ||
licenses := sbom.Licenses() | ||
|
||
assert.Len(t, licenses, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package enrichment | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"strings" | ||
|
||
"github.com/kirinlabs/HttpRequest" | ||
|
||
"github.com/devops-kung-fu/bomber/models" | ||
) | ||
|
||
const epssBaseURL = "https://api.first.org/data/v1/epss?cve=" | ||
|
||
// Enrich adds epss score data to vulnerabilities | ||
func Enrich(vulnerabilities []models.Vulnerability) (enriched []models.Vulnerability, err error) { | ||
identifiers := []string{} | ||
for _, v := range vulnerabilities { | ||
identifiers = append(identifiers, v.ID) | ||
} | ||
req := HttpRequest.NewRequest() | ||
resp, _ := req.JSON().Get(fmt.Sprintf("%s%s", epssBaseURL, strings.Join(identifiers, ","))) | ||
defer func() { | ||
_ = resp.Close() | ||
}() | ||
|
||
log.Println("EPSS Response Status:", resp.StatusCode()) | ||
|
||
body, _ := resp.Body() | ||
if resp.StatusCode() == 200 { | ||
var epss models.Epss | ||
err = json.Unmarshal(body, &epss) | ||
if err != nil { | ||
return | ||
} | ||
log.Println("EPSS response total:", epss.Total) | ||
|
||
for i, v := range vulnerabilities { | ||
for _, sv := range epss.Scores { | ||
if sv.Cve == v.ID { | ||
vulnerabilities[i].Epss = sv | ||
} | ||
} | ||
} | ||
return vulnerabilities, nil | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package enrichment | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/devops-kung-fu/bomber/models" | ||
) | ||
|
||
func TestEnrich(t *testing.T) { | ||
vulnerabilities := []models.Vulnerability{ | ||
{ | ||
ID: "CVE-2021-43138", | ||
}, | ||
{ | ||
ID: "CVE-2020-15084", | ||
}, | ||
{ | ||
ID: "CVE-2020-28282", | ||
}, | ||
{ | ||
ID: "sonatype-2020-1214", | ||
}, | ||
} | ||
enriched, err := Enrich(vulnerabilities) | ||
|
||
assert.NoError(t, err) | ||
assert.Len(t, enriched, 4) | ||
|
||
assert.Empty(t, enriched[3].Epss.Cve) | ||
assert.Equal(t, enriched[0].Epss.Cve, "CVE-2021-43138") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.