Skip to content

Commit a8b267f

Browse files
committed
Merge branch 'master' into env-lint-test
Signed-off-by: Talon James Bowler <[email protected]>
2 parents 998f003 + ba6f3df commit a8b267f

File tree

20 files changed

+698
-219
lines changed

20 files changed

+698
-219
lines changed

api/services/control/control.pb.go

Lines changed: 261 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/control/control.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ message BuildHistoryRecord {
211211
int32 numCachedSteps = 15;
212212
int32 numTotalSteps = 16;
213213
int32 numCompletedSteps = 17;
214+
Descriptor externalError = 18;
214215
// TODO: tags
215216
// TODO: unclipped logs
216217
}
@@ -219,6 +220,7 @@ message UpdateBuildHistoryRequest {
219220
string Ref = 1;
220221
bool Pinned = 2;
221222
bool Delete = 3;
223+
bool Finalize = 4;
222224
}
223225

224226
message UpdateBuildHistoryResponse {}

cache/remotecache/s3/s3.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ func (s3Client *s3Client) getManifest(ctx context.Context, key string, config *v
408408
if err := decoder.Decode(config); err != nil {
409409
return false, errors.WithStack(err)
410410
}
411+
if _, err := decoder.Token(); !errors.Is(err, io.EOF) {
412+
return false, errors.Errorf("unexpected data after JSON object")
413+
}
411414

412415
return true, nil
413416
}

control/control.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,23 @@ func (c *Controller) ListenBuildHistory(req *controlapi.BuildHistoryRequest, srv
283283
}
284284

285285
func (c *Controller) UpdateBuildHistory(ctx context.Context, req *controlapi.UpdateBuildHistoryRequest) (*controlapi.UpdateBuildHistoryResponse, error) {
286-
if !req.Delete {
287-
err := c.history.UpdateRef(ctx, req.Ref, func(r *controlapi.BuildHistoryRecord) error {
288-
if req.Pinned == r.Pinned {
289-
return nil
290-
}
291-
r.Pinned = req.Pinned
292-
return nil
293-
})
286+
if req.Delete {
287+
err := c.history.Delete(ctx, req.Ref)
294288
return &controlapi.UpdateBuildHistoryResponse{}, err
295289
}
296290

297-
err := c.history.Delete(ctx, req.Ref)
291+
if req.Finalize {
292+
err := c.history.Finalize(ctx, req.Ref)
293+
return &controlapi.UpdateBuildHistoryResponse{}, err
294+
}
295+
296+
err := c.history.UpdateRef(ctx, req.Ref, func(r *controlapi.BuildHistoryRecord) error {
297+
if req.Pinned == r.Pinned {
298+
return nil
299+
}
300+
r.Pinned = req.Pinned
301+
return nil
302+
})
298303
return &controlapi.UpdateBuildHistoryResponse{}, err
299304
}
300305

executor/runcexecutor/executor.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,13 @@ func (w *runcExecutor) Exec(ctx context.Context, id string, process executor.Pro
422422
defer f.Close()
423423

424424
spec := &specs.Spec{}
425-
if err := json.NewDecoder(f).Decode(spec); err != nil {
425+
dec := json.NewDecoder(f)
426+
if err := dec.Decode(spec); err != nil {
426427
return err
427428
}
429+
if _, err := dec.Token(); !errors.Is(err, io.EOF) {
430+
return errors.Errorf("unexpected data after JSON spec object")
431+
}
428432

429433
if process.Meta.User != "" {
430434
uid, gid, sgids, err := oci.GetUser(state.Rootfs, process.Meta.User)
@@ -610,9 +614,14 @@ func runcProcessHandle(ctx context.Context, killer procKiller) (*procHandle, con
610614
go func() {
611615
// Wait for pid
612616
select {
613-
case <-ctx.Done():
617+
case <-p.ended:
614618
return // nothing to kill
615619
case <-p.ready:
620+
select {
621+
case <-p.ended:
622+
return
623+
default:
624+
}
616625
}
617626

618627
for {

exporter/attestation/unbundle.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package attestation
33
import (
44
"context"
55
"encoding/json"
6+
"io"
67
"os"
78
"path"
89
"strings"
@@ -141,6 +142,9 @@ func unbundle(root string, bundle exporter.Attestation) ([]exporter.Attestation,
141142
if err := dec.Decode(&stmt); err != nil {
142143
return nil, errors.Wrap(err, "cannot decode in-toto statement")
143144
}
145+
if _, err := dec.Token(); !errors.Is(err, io.EOF) {
146+
return nil, errors.New("in-toto statement is not a single JSON object")
147+
}
144148
if bundle.InToto.PredicateType != "" && stmt.PredicateType != bundle.InToto.PredicateType {
145149
return nil, errors.Errorf("bundle entry %s does not match required predicate type %s", stmt.PredicateType, bundle.InToto.PredicateType)
146150
}

frontend/dockerfile/dockerfile2llb/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error {
13541354
return errors.New("checksum can't be specified for multiple sources")
13551355
}
13561356
if !isHTTPSource(cfg.params.SourcePaths[0]) {
1357-
return errors.New("checksum can't be specified for non-HTTP sources")
1357+
return errors.New("checksum can't be specified for non-HTTP(S) sources")
13581358
}
13591359
}
13601360

frontend/dockerfile/dockerfile_addchecksum_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ ADD --checksum=%s foo /tmp/foo
162162
dockerui.DefaultLocalNameContext: dir,
163163
},
164164
}, nil)
165-
require.Error(t, err, "checksum can't be specified for non-HTTP sources")
165+
require.Error(t, err, "checksum can't be specified for non-HTTP(S) sources")
166166
})
167167
}

0 commit comments

Comments
 (0)