-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
43 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,13 @@ func TestEnrich(t *testing.T) { | |
Cve: "sonatype-2020-1214", | ||
}, | ||
} | ||
|
||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
|
||
httpmock.RegisterResponder("GET", "https://api.first.org/data/v1/epss", | ||
httpmock.NewBytesResponder(200, epssTestResponse())) | ||
|
||
enriched, err := enricher.Enrich(vulnerabilities, nil) | ||
|
||
assert.NoError(t, err) | ||
|
@@ -48,3 +55,34 @@ func TestEnrich_Error(t *testing.T) { | |
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "EPSS API request failed with status code") | ||
} | ||
|
||
func epssTestResponse() []byte { | ||
response := ` | ||
[ | ||
// { | ||
// "coordinates": "pkg:gem/[email protected]", | ||
// "description": "TZInfo provides daylight savings aware transformations between times in different time zones.", | ||
// "reference": "https://ossindex.sonatype.org/component/pkg:gem/[email protected]?utm_source=mozilla&utm_medium=integration&utm_content=5.0", | ||
// "vulnerabilities": [ | ||
// { | ||
// "id": "CVE-2022-31163", | ||
// "displayName": "CVE-2022-31163", | ||
// "title": "[CVE-2022-31163] CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')", | ||
// "description": "TZInfo... ", | ||
// "cvssScore": 8.1, | ||
// "cvssVector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", | ||
// "cwe": "CWE-22", | ||
// "cve": "CVE-2022-31163", | ||
// "reference": "https://ossindex.sonatype.org/vulnerability/CVE-2022-31163?component-type=gem&component-name=tzinfo&utm_source=mozilla&utm_medium=integration&utm_content=5.0", | ||
// "externalReferences": [ | ||
// "http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2022-31163", | ||
// "https://github.com/tzinfo/tzinfo/releases/tag/v0.3.61", | ||
// "https://github.com/tzinfo/tzinfo/releases/tag/v1.2.10", | ||
// "https://github.com/tzinfo/tzinfo/security/advisories/GHSA-5cm2-9h8c-rvfx" | ||
// ] | ||
// } | ||
// ] | ||
// } | ||
]` | ||
return []byte(response) | ||
} |
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