Skip to content

Commit 794d16b

Browse files
authored
fix(referrer): remove sha256 digest validation (#447)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 16c54e7 commit 794d16b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

app/controlplane/internal/biz/referrer.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest, rootKind, use
153153
return nil, NewErrInvalidUUID(err)
154154
}
155155

156-
if _, err = cr_v1.NewHash(digest); err != nil {
157-
return nil, NewErrValidation(fmt.Errorf("invalid digest format: %w", err))
158-
}
159-
160156
// We pass the list of organizationsIDs from where to look for the referrer
161157
// For now we just pass the list of organizations the user is member of
162158
// in the future we will expand this to publicly available orgs and so on.

app/controlplane/internal/biz/referrer_integration_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ func (s *referrerIntegrationTestSuite) TestExtractAndPersists() {
197197
s.Equal([]uuid.UUID{s.workflow1.ID}, got.WorkflowIDs)
198198
})
199199

200+
s.T().Run("can get sha1 digests too", func(t *testing.T) {
201+
got, err := s.Referrer.GetFromRoot(ctx, wantReferrerCommit.Digest, "", s.user.ID)
202+
s.NoError(err)
203+
s.Equal(wantReferrerCommit.Digest, got.Digest)
204+
})
205+
200206
s.T().Run("can't be accessed by a second user in another org", func(t *testing.T) {
201207
// the user2 has not access to org1
202208
got, err := s.Referrer.GetFromRoot(ctx, wantReferrerAtt.Digest, "", s.user2.ID)
@@ -255,13 +261,6 @@ func (s *referrerIntegrationTestSuite) TestExtractAndPersists() {
255261
require.Len(t, got.References, 0)
256262
})
257263

258-
s.T().Run("or it's an invalid digest", func(t *testing.T) {
259-
got, err := s.Referrer.GetFromRoot(ctx, "sha256:deadbeef", "", s.user.ID)
260-
s.True(biz.IsErrValidation(err))
261-
s.ErrorContains(err, "invalid digest format")
262-
s.Nil(got)
263-
})
264-
265264
s.T().Run("or it does not exist", func(t *testing.T) {
266265
got, err := s.Referrer.GetFromRoot(ctx, "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "", s.user.ID)
267266
s.True(biz.IsNotFound(err))

0 commit comments

Comments
 (0)