Skip to content

Commit

Permalink
verification_failed -> signature_refused
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed Aug 7, 2023
1 parent aaaeaaf commit cd13203
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions agent/integration/job_verification_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestJobVerification(t *testing.T) {
job: jobWithInvalidSignature,
mockBootstrapExpectation: func(bt *bintest.Mock) { bt.Expect().NotCalled() },
expectedExitStatus: "-1",
expectedSignalReason: agent.SignalReasonVerificationFailed,
expectedSignalReason: agent.SignalReasonSignatureRejected,
expectLogsContain: []string{"⚠️ ERROR"},
},
{
Expand All @@ -127,7 +127,7 @@ func TestJobVerification(t *testing.T) {
job: jobWithNoSignature,
mockBootstrapExpectation: func(bt *bintest.Mock) { bt.Expect().NotCalled() },
expectedExitStatus: "-1",
expectedSignalReason: agent.SignalReasonVerificationFailed,
expectedSignalReason: agent.SignalReasonSignatureRejected,
expectLogsContain: []string{"⚠️ ERROR"},
},
{
Expand All @@ -144,7 +144,7 @@ func TestJobVerification(t *testing.T) {
job: jobWithMismatchedStepAndJob,
mockBootstrapExpectation: func(bt *bintest.Mock) { bt.Expect().NotCalled() },
expectedExitStatus: "-1",
expectedSignalReason: agent.SignalReasonVerificationFailed,
expectedSignalReason: agent.SignalReasonSignatureRejected,
expectLogsContain: []string{
"⚠️ ERROR",
fmt.Sprintf(`the value of field "command" on the job (%q) does not match the value of the field on the step (%q)`,
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestWhenTheJobHasASignature_ButTheJobRunnerCantVerify_ItRefusesTheJob(t *te
}
}

if got, want := finish.SignalReason, agent.SignalReasonVerificationFailed; got != want {
if got, want := finish.SignalReason, agent.SignalReasonSignatureRejected; got != want {
t.Errorf("job.SignalReason = %q, want %q", got, want)
}
}
18 changes: 9 additions & 9 deletions agent/run_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
)

const (
SignalReasonAgentRefused = "agent_refused"
SignalReasonAgentStop = "agent_stop"
SignalReasonCancel = "cancel"
SignalReasonVerificationFailed = "verification_failed"
SignalReasonProcessRunError = "process_run_error"
SignalReasonAgentRefused = "agent_refused"
SignalReasonAgentStop = "agent_stop"
SignalReasonCancel = "cancel"
SignalReasonSignatureRejected = "signature_rejected"
SignalReasonProcessRunError = "process_run_error"
)

// Runs the job
Expand Down Expand Up @@ -95,7 +95,7 @@ func (r *JobRunner) Run(ctx context.Context) error {
VerificationBehaviourBlock,
)
exit.Status = -1
exit.SignalReason = SignalReasonVerificationFailed
exit.SignalReason = SignalReasonSignatureRejected
return nil
}

Expand All @@ -106,22 +106,22 @@ func (r *JobRunner) Run(ctx context.Context) error {
r.verificationFailureLogs(err, r.NoSignatureBehavior)
if r.NoSignatureBehavior == VerificationBehaviourBlock {
exit.Status = -1
exit.SignalReason = SignalReasonVerificationFailed
exit.SignalReason = SignalReasonSignatureRejected
return nil
}

case errors.As(err, &ise):
r.verificationFailureLogs(err, r.InvalidSignatureBehavior)
if r.InvalidSignatureBehavior == VerificationBehaviourBlock {
exit.Status = -1
exit.SignalReason = SignalReasonVerificationFailed
exit.SignalReason = SignalReasonSignatureRejected
return nil
}

case err != nil: // some other error
r.verificationFailureLogs(err, VerificationBehaviourBlock) // errors in verification are always fatal
exit.Status = -1
exit.SignalReason = SignalReasonVerificationFailed
exit.SignalReason = SignalReasonSignatureRejected
return nil

default: // no error, all good, keep going
Expand Down

0 comments on commit cd13203

Please sign in to comment.