Skip to content

Commit

Permalink
fix: store bundle hash for ai fix
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed Jun 10, 2024
1 parent cd4af4f commit 0b44cc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions infrastructure/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ func (sc *Scanner) UploadAndAnalyzeWithIgnores(ctx context.Context,
if err != nil {
return []snyk.Issue{}, err
}
sc.BundleHashes[path] = bundleHash

converter := SarifConverter{sarif: *sarif}
issues, err = converter.toIssues(path)
Expand Down
8 changes: 6 additions & 2 deletions infrastructure/code/code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestUploadAndAnalyzeWithIgnores(t *testing.T) {
files := []string{diagnosticUri}
fakeCodeScanner := &FakeCodeScannerClient{rootPath: diagnosticUri}

c := New(
sc := New(
NewBundler(snykCodeMock, NewCodeInstrumentor()),
&snyk_api.FakeApiClient{CodeEnabled: true},
newTestCodeErrorReporter(),
Expand All @@ -406,7 +406,7 @@ func TestUploadAndAnalyzeWithIgnores(t *testing.T) {
notification.NewNotifier(),
fakeCodeScanner,
)
issues, _ := c.UploadAndAnalyzeWithIgnores(context.Background(), "", sliceToChannel(files), map[string]bool{})
issues, _ := sc.UploadAndAnalyzeWithIgnores(context.Background(), "", sliceToChannel(files), map[string]bool{})
assert.True(t, fakeCodeScanner.UploadAndAnalyzeWasCalled)
assert.False(t, issues[0].IsIgnored)
assert.Nil(t, issues[0].IgnoreDetails)
Expand All @@ -416,6 +416,10 @@ func TestUploadAndAnalyzeWithIgnores(t *testing.T) {
assert.Equal(t, "13 days", issues[1].IgnoreDetails.Expiration)
assert.Equal(t, 2024, issues[1].IgnoreDetails.IgnoredOn.Year())
assert.Equal(t, "Neil M", issues[1].IgnoreDetails.IgnoredBy)

// verify that bundle hash has been saved
assert.Equal(t, 1, len(sc.BundleHashes))
assert.Equal(t, snykCodeMock.Options.bundleHash, sc.BundleHashes[path])
}

func Test_Scan(t *testing.T) {
Expand Down

0 comments on commit 0b44cc4

Please sign in to comment.