@@ -7,6 +7,7 @@ package taskverifier
77
88import (
99 "crypto/sha256"
10+ "errors"
1011 "fmt"
1112 "time"
1213
@@ -31,15 +32,15 @@ func NewTaskVerifier(keysManager remoteconfig.KeysManager, config *config.Config
3132
3233func (t * TaskVerifier ) UnwrapTaskFromSignedEnvelope (envelope * privateactionspb.RemoteConfigSignatureEnvelope ) (* types.Task , error ) {
3334 if envelope == nil {
34- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , fmt . Errorf ("task is missing signed envelope" ))
35+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , errors . New ("task is missing signed envelope" ))
3536 }
3637
3738 if len (envelope .Data ) == 0 {
38- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , fmt . Errorf ("data is missing" ))
39+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , errors . New ("data is missing" ))
3940 }
4041
4142 if len (envelope .Signatures ) == 0 {
42- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , fmt . Errorf ("signatures are missing" ))
43+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , errors . New ("signatures are missing" ))
4344 }
4445
4546 if envelope .HashType != privateactionspb .HashType_SHA256 {
@@ -50,20 +51,20 @@ func (t *TaskVerifier) UnwrapTaskFromSignedEnvelope(envelope *privateactionspb.R
5051 var task privateactionspb.PrivateActionTask
5152 err := proto .Unmarshal (envelope .Data , & task )
5253 if err != nil {
53- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , fmt . Errorf ("failed to unmarshal task" ))
54+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , errors . New ("failed to unmarshal task" ))
5455 }
5556
5657 if task .ExpirationTime == nil {
57- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , fmt . Errorf ("expiration time is missing" ))
58+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_INTERNAL_ERROR , errors . New ("expiration time is missing" ))
5859 }
5960
6061 if task .ExpirationTime .AsTime ().Before (time .Now ()) {
61- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_EXPIRED_TASK , fmt . Errorf ("task is expired" ))
62+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_EXPIRED_TASK , errors . New ("task is expired" ))
6263 }
6364
6465 signature , localKey := t .getCandidateSignatureWithKey (envelope )
6566 if localKey == nil {
66- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_SIGNATURE_KEY_NOT_FOUND , fmt . Errorf ("no matching key found" ))
67+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_SIGNATURE_KEY_NOT_FOUND , errors . New ("no matching key found" ))
6768 }
6869
6970 localKeyType := localKey .GetKeyType ()
@@ -77,11 +78,11 @@ func (t *TaskVerifier) UnwrapTaskFromSignedEnvelope(envelope *privateactionspb.R
7778 }
7879
7980 if task .OrgId != t .config .OrgId {
80- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_MISMATCHED_ORG_ID , fmt . Errorf ("task orgId doesn't match the orgId of the runner" ))
81+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_MISMATCHED_ORG_ID , errors . New ("task orgId doesn't match the orgId of the runner" ))
8182 }
8283
8384 if task .GetConnectionInfo ().RunnerId != t .config .RunnerId {
84- return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_MISMATCHED_RUNNER_ID , fmt . Errorf ("connection runnerId doesn't match the id of the runner" ))
85+ return nil , util .NewPARError (aperrorpb .ActionPlatformErrorCode_MISMATCHED_RUNNER_ID , errors . New ("connection runnerId doesn't match the id of the runner" ))
8586 }
8687
8788 return mapPbTaskToStruct (& task ), nil
0 commit comments