Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vulnfeeds/conversion/cve5/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/gkampitakis/go-snaps/snaps"
"github.com/google/go-cmp/cmp"
"github.com/google/osv/vulnfeeds/internal/testutils"
"github.com/google/osv/vulnfeeds/models"
"github.com/google/osv/vulnfeeds/vulns"
"github.com/ossf/osv-schema/bindings/go/osvconstants"
Expand Down Expand Up @@ -579,6 +580,7 @@ func TestConvertAndExportCVEToOSV(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
testutils.SetupGitVCR(t)
vWriter := bytes.NewBuffer(nil)
mWriter := bytes.NewBuffer(nil)
_, err := ConvertAndExportCVEToOSV(tc.cve, vWriter, mWriter, "")
Expand All @@ -591,6 +593,7 @@ func TestConvertAndExportCVEToOSV(t *testing.T) {
}

func TestCVE5Snapshot(t *testing.T) {
testutils.SetupGitVCR(t)
testDir := "../../test_data/cve5"
//TODO: split this into individual records.
files, err := os.ReadDir(testDir)
Expand Down
564 changes: 564 additions & 0 deletions vulnfeeds/conversion/cve5/testdata/TestCVE5Snapshot.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
version: 2
interactions: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
version: 2
interactions: []

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
version: 2
interactions: []
2 changes: 2 additions & 0 deletions vulnfeeds/conversion/cve5/version_extraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/osv/vulnfeeds/conversion"
"github.com/google/osv/vulnfeeds/internal/testutils"
"github.com/google/osv/vulnfeeds/models"
"github.com/google/osv/vulnfeeds/vulns"
"github.com/ossf/osv-schema/bindings/go/osvschema"
Expand Down Expand Up @@ -597,6 +598,7 @@ func TestExtractVersions(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
testutils.SetupGitVCR(t)
metrics := &models.ConversionMetrics{}
v := vulns.Vulnerability{
Vulnerability: &osvschema.Vulnerability{},
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions vulnfeeds/conversion/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"reflect"
"slices"
Expand Down Expand Up @@ -1281,10 +1280,10 @@ func TestReposFromReferences(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testutils.SetupGitVCR(t)
r := testutils.SetupGitVCR(t)
metrics := &models.ConversionMetrics{}
repoTagsCache := &git.InMemoryRepoTagsCache{}
if gotRepos := ReposFromReferences(tt.args.cache, tt.args.vp, tt.args.refs, tt.args.tagDenyList, repoTagsCache, metrics, http.DefaultClient); !reflect.DeepEqual(gotRepos, tt.wantRepos) {
if gotRepos := ReposFromReferences(tt.args.cache, tt.args.vp, tt.args.refs, tt.args.tagDenyList, repoTagsCache, metrics, r.GetDefaultClient()); !reflect.DeepEqual(gotRepos, tt.wantRepos) {
t.Errorf("ReposFromReferences() = %#v, want %#v", gotRepos, tt.wantRepos)
}
})
Expand Down
2 changes: 1 addition & 1 deletion vulnfeeds/git/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func RemoteRepoRefsWithRetry(repoURL string, retries uint64) (refs []*plumbing.R

ctx := context.Background()

backoff := retry.NewExponential(1 * time.Second)
backoff := retry.NewExponential(BackoffBaseDelay)
backoff = retry.WithMaxRetries(retries, backoff)
backoff = newLoggingBackoff(backoff, "RemoteRepoRefs")

Expand Down
3 changes: 2 additions & 1 deletion vulnfeeds/git/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
// Keep in sync with the intent of https://github.com/google/osv.dev/blob/26050deb42785bc5a4dc7d802eac8e7f95135509/osv/bug.py#L31
validVersion = regexp.MustCompile(`(?i)(\d+|(?:rc|alpha|beta|preview)\d*)`)
validVersionText = regexp.MustCompile(`(?i)(?:rc|alpha|beta|preview)\d*`)
BackoffBaseDelay = 1 * time.Second
)

// findFuzzyCommit takes an already normalized version and the mapping of repo tags to
Expand Down Expand Up @@ -197,7 +198,7 @@ func ValidateAndCanonicalizeLink(link string, httpClient *http.Client) (canonica
if httpClient == nil {
httpClient = http.DefaultClient
}
backoff := retry.NewExponential(1 * time.Second)
backoff := retry.NewExponential(BackoffBaseDelay)
loggingBackoff := newLoggingBackoff(retry.WithMaxRetries(3, backoff), "ValidateAndCanonicalizeLink")
if err := retry.Do(context.Background(), loggingBackoff, func(ctx context.Context) error {
req, err := http.NewRequestWithContext(ctx, http.MethodHead, link, nil)
Expand Down
4 changes: 4 additions & 0 deletions vulnfeeds/git/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ func TestValidateAndCanonicalizeLink_429(t *testing.T) {
}

func TestValidateAndCanonicalizeLink_Retries(t *testing.T) {
oldDelay := BackoffBaseDelay
BackoffBaseDelay = 1 * time.Millisecond
defer func() { BackoffBaseDelay = oldDelay }()

requests := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
requests++
Expand Down
Loading