Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/debuginfo: Validate size of upload is set #2282

Merged
merged 1 commit into from
Dec 13, 2022
Merged
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 pkg/debuginfo/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ func (s *Store) InitiateUpload(ctx context.Context, req *debuginfopb.InitiateUpl
if req.Hash == "" {
return nil, status.Error(codes.InvalidArgument, "hash must be set")
}
if req.Size == 0 {
return nil, status.Error(codes.InvalidArgument, "size must be set")
}

// We don't want to blindly accept upload initiation requests that
// shouldn't have happened.
Expand Down
3 changes: 3 additions & 0 deletions pkg/debuginfo/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestStore(t *testing.T) {
_, err = debuginfoClient.InitiateUpload(ctx, &debuginfopb.InitiateUploadRequest{
BuildId: "abcd",
Hash: "foo",
Size: 2,
})
require.NoError(t, err)

Expand All @@ -144,6 +145,7 @@ func TestStore(t *testing.T) {
initiateResp, err := debuginfoClient.InitiateUpload(ctx, &debuginfopb.InitiateUploadRequest{
BuildId: "abcd",
Hash: "foo",
Size: 2,
})
require.NoError(t, err)

Expand Down Expand Up @@ -192,6 +194,7 @@ func TestStore(t *testing.T) {
_, err = debuginfoClient.InitiateUpload(ctx, &debuginfopb.InitiateUploadRequest{
BuildId: "abcd",
Hash: "foo",
Size: 2,
})
require.EqualError(t, err, "rpc error: code = AlreadyExists desc = Debuginfo already exists and is marked as invalid, but the proposed hash is the same as the one already available, therefore the upload is not accepted as it would result in the same invalid debuginfos.")

Expand Down