Skip to content

Commit

Permalink
fix: store bundle hash for ai fix [IDE-380] (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu authored Jun 10, 2024
1 parent 9f7a25a commit 0963926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 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, c: sc.c}
issues, err = converter.toIssues(path)
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/code/code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ func TestUploadAndAnalyzeWithIgnores(t *testing.T) {

scanner := New(
NewBundler(c, snykCodeMock, NewCodeInstrumentor()),

&snyk_api.FakeApiClient{CodeEnabled: true},
newTestCodeErrorReporter(),
ux2.NewTestAnalytics(c),
Expand All @@ -408,6 +409,7 @@ func TestUploadAndAnalyzeWithIgnores(t *testing.T) {
fakeCodeScanner,
)
issues, _ := scanner.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 @@ -417,6 +419,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(scanner.BundleHashes))
assert.Equal(t, snykCodeMock.Options.bundleHash, scanner.BundleHashes[path])
}

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

0 comments on commit 0963926

Please sign in to comment.