This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dropped the ref check from the enricher (#65)
* dropped the ref check from the enricher * and the actual test
- Loading branch information
1 parent
e1acad0
commit 59b4fb2
Showing
4 changed files
with
54 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package enrichment | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
v1 "github.com/thought-machine/dracon/api/proto/v1" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetHash(t *testing.T) { | ||
expectedIssues := &v1.Issue{ | ||
Target: "pkg:golang/github.com/coreos/[email protected]", | ||
Type: "Vulnerable Dependency", | ||
Title: "[CVE-2018-1099] Improper Input Validation", | ||
Source: "git.foo.com/repo.git?ref=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
Severity: v1.Severity_SEVERITY_MEDIUM, | ||
Cvss: 5.5, | ||
Confidence: v1.Confidence_CONFIDENCE_HIGH, | ||
Description: fmt.Sprintf("CVSS Score: %v\nCvssVector: %s\nCve: %s\nCwe: %s\nReference: %s\n", | ||
"5.5", "CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N", "CVE-2018-1099", | ||
"", "https://ossindex.sonatype.org/vuln/8a190129-526c-4ee0-b663-92f38139c165"), | ||
} | ||
assert.Equal(t, GetHash(expectedIssues), "ccc217a4c2fd348bc5c6c4d73ad4311a") | ||
|
||
expectedIssues.Source = strings.NewReplacer("aa", "bc").Replace(expectedIssues.Source) | ||
// Test for regression on Bug where we would calculate ?ref=<> value for enrichment | ||
assert.Equal(t, GetHash(expectedIssues), "ccc217a4c2fd348bc5c6c4d73ad4311a") | ||
|
||
expectedIssues.Source = strings.NewReplacer("git.foo.com/repo.git", "https://example.com/foo/bar").Replace(expectedIssues.Source) | ||
assert.NotEqual(t, GetHash(expectedIssues), "3c73dcc2f7c647a4ff460249074a8d50") | ||
} |