Skip to content

Commit d55ecac

Browse files
authored
Merge pull request #3408 from buildkite/check-go-pipeline-68
Upgrade to go-pipeline v0.15.0
2 parents d957824 + 11ae28b commit d55ecac

File tree

4 files changed

+25
-46
lines changed

4 files changed

+25
-46
lines changed

agent/integration/job_verification_integration_test.go

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package integration
22

33
import (
4-
"context"
54
"strings"
65
"testing"
76

@@ -286,7 +285,7 @@ var (
286285

287286
func TestJobVerification(t *testing.T) {
288287
t.Parallel()
289-
ctx := context.Background()
288+
ctx := t.Context()
290289

291290
cases := []struct {
292291
name string
@@ -593,12 +592,20 @@ func TestJobVerification(t *testing.T) {
593592
tc.mockBootstrapExpectation(mb)
594593
defer mb.CheckAndClose(t) //nolint:errcheck // bintest logs to t
595594

596-
stepWithInvariants := signature.CommandStepWithInvariants{
597-
CommandStep: tc.job.Step,
598-
RepositoryURL: tc.repositoryURL,
595+
t.Logf("%s: signing step with key: %v", t.Name(), tc.signingKey)
596+
if tc.signingKey != nil {
597+
err := signature.SignSteps(
598+
ctx,
599+
pipeline.Steps{&tc.job.Step},
600+
tc.signingKey,
601+
tc.repositoryURL,
602+
signature.WithEnv(pipelineUploadEnv),
603+
)
604+
if err != nil {
605+
t.Fatalf("signing step: %v", err)
606+
}
599607
}
600608

601-
tc.job.Step = signStep(t, ctx, tc.signingKey, pipelineUploadEnv, stepWithInvariants)
602609
err := runJob(t, ctx, testRunJobConfig{
603610
job: &tc.job,
604611
server: server,
@@ -686,25 +693,3 @@ func jwksFromKeys(t *testing.T, jwkes ...jwk.Key) jwk.Set {
686693

687694
return set
688695
}
689-
690-
func signStep(
691-
t *testing.T,
692-
ctx context.Context,
693-
key jwk.Key,
694-
env map[string]string,
695-
stepWithInvariants signature.CommandStepWithInvariants,
696-
) pipeline.CommandStep {
697-
t.Helper()
698-
699-
t.Logf("%s: signing step with key: %v", t.Name(), key)
700-
if key == nil {
701-
return stepWithInvariants.CommandStep
702-
}
703-
704-
signature, err := signature.Sign(ctx, key, &stepWithInvariants, signature.WithEnv(env))
705-
if err != nil {
706-
t.Fatalf("signing step: %v", err)
707-
}
708-
stepWithInvariants.Signature = signature
709-
return stepWithInvariants.CommandStep
710-
}

agent/verify_job.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,22 @@ func (e *invalidSignatureError) Unwrap() error {
3535
}
3636

3737
func (r *JobRunner) verifyJob(ctx context.Context, keySet any) error {
38-
step := r.conf.Job.Step
38+
step := &r.conf.Job.Step
3939

40-
if step.Signature == nil {
41-
r.agentLogger.Debug("verifyJob: Job.Step.Signature == nil")
42-
return ErrNoSignature
43-
}
44-
45-
stepWithInvariants := &signature.CommandStepWithInvariants{
46-
CommandStep: step,
47-
RepositoryURL: r.conf.Job.Env["BUILDKITE_REPO"],
48-
}
49-
50-
// Verify the signature
51-
err := signature.Verify(
40+
// First, verify the signature.
41+
err := signature.VerifyStep(
5242
ctx,
53-
step.Signature,
43+
step,
5444
keySet,
55-
stepWithInvariants,
45+
r.conf.Job.Env["BUILDKITE_REPO"],
5646
signature.WithEnv(r.conf.Job.Env),
5747
signature.WithLogger(r.agentLogger),
5848
signature.WithDebugSigning(r.conf.AgentConfiguration.DebugSigning),
5949
)
50+
if err == signature.ErrNoSignature {
51+
r.agentLogger.Debug("verifyJob: Job.Step.Signature == nil")
52+
return ErrNoSignature
53+
}
6054
if err != nil {
6155
r.agentLogger.Debug("failed to verifyJob: step.Signature.Verify(Job.Env, stepWithInvariants, JWKS) = %v", err)
6256
return newInvalidSignatureError(ErrVerificationFailed)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/aws/aws-sdk-go-v2/service/kms v1.41.3
1717
github.com/brunoscheufler/aws-ecs-metadata-go v0.0.0-20220812150832-b6b31c6eeeaf
1818
github.com/buildkite/bintest/v3 v3.3.0
19-
github.com/buildkite/go-pipeline v0.14.0
19+
github.com/buildkite/go-pipeline v0.15.0
2020
github.com/buildkite/interpolate v0.1.5
2121
github.com/buildkite/roko v1.3.1
2222
github.com/buildkite/shellwords v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ github.com/brunoscheufler/aws-ecs-metadata-go v0.0.0-20220812150832-b6b31c6eeeaf
116116
github.com/brunoscheufler/aws-ecs-metadata-go v0.0.0-20220812150832-b6b31c6eeeaf/go.mod h1:CeKhh8xSs3WZAc50xABMxu+FlfAAd5PNumo7NfOv7EE=
117117
github.com/buildkite/bintest/v3 v3.3.0 h1:RTWcSaJRlOT6t/K311ejPf+0J3LE/QEODzVG3vlLnWo=
118118
github.com/buildkite/bintest/v3 v3.3.0/go.mod h1:btqpTsVODiJcb0NMdkkmtMQ6xoFc2W/nY5yy+3I0zcs=
119-
github.com/buildkite/go-pipeline v0.14.0 h1:TMkFalrkniy2l5wEfmGyckT5kf21akWOY07i4esosAI=
120-
github.com/buildkite/go-pipeline v0.14.0/go.mod h1:VE37qY3X5pmAKKUMoDZvPsHOQuyakB9cmXj9Qn6QasA=
119+
github.com/buildkite/go-pipeline v0.15.0 h1:ae/TEXC/4HhajbED2vKcRL5vZTtb9C71cajzwoBlP8s=
120+
github.com/buildkite/go-pipeline v0.15.0/go.mod h1:VE37qY3X5pmAKKUMoDZvPsHOQuyakB9cmXj9Qn6QasA=
121121
github.com/buildkite/interpolate v0.1.5 h1:v2Ji3voik69UZlbfoqzx+qfcsOKLA61nHdU79VV+tPU=
122122
github.com/buildkite/interpolate v0.1.5/go.mod h1:dHnrwHew5O8VNOAgMDpwRlFnhL5VSN6M1bHVmRZ9Ccc=
123123
github.com/buildkite/roko v1.3.1 h1:t7K30ceLLYn6k7hQP4oq1c7dVlhgD5nRcuSRDEEnY1s=

0 commit comments

Comments
 (0)