@@ -313,15 +313,14 @@ func populateHash(hashFunc crypto.Hash, msg []byte) (hash.Hash, error) {
313
313
return h , nil
314
314
}
315
315
316
- // readArmoredSign reads an armored signture block with the given type. https://sourcegraph.com/github.com/golang/crypto/-/blob/openpgp/read.go#L24:6-24:17
316
+ // readArmoredSign read an armored signature block with the given type. https://sourcegraph.com/github.com/golang/crypto/-/blob/openpgp/read.go#L24:6-24:17
317
317
func readArmoredSign (r io.Reader ) (body io.Reader , err error ) {
318
- expectedType := "PGP SIGNATURE"
319
318
block , err := armor .Decode (r )
320
319
if err != nil {
321
320
return
322
321
}
323
- if block .Type != expectedType {
324
- return nil , fmt .Errorf ("expected '" + expectedType + "', got: " + block .Type )
322
+ if block .Type != openpgp . SignatureType {
323
+ return nil , fmt .Errorf ("expected '" + openpgp . SignatureType + "', got: " + block .Type )
325
324
}
326
325
return block .Body , nil
327
326
}
@@ -378,7 +377,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
378
377
log .Error (3 , "SignatureRead err: %v" , err )
379
378
return & CommitVerification {
380
379
Verified : false ,
381
- Reason : "Failed to extract signature " ,
380
+ Reason : "gpg.error.extract_sign " ,
382
381
}
383
382
}
384
383
//Generating hash of commit
@@ -387,7 +386,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
387
386
log .Error (3 , "PopulateHash: %v" , err )
388
387
return & CommitVerification {
389
388
Verified : false ,
390
- Reason : "Failed to generate hash of commit " ,
389
+ Reason : "gpg.error.generate_hash " ,
391
390
}
392
391
}
393
392
@@ -397,7 +396,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
397
396
log .Error (3 , "NoCommitterAccount: %v" , err )
398
397
return & CommitVerification {
399
398
Verified : false ,
400
- Reason : "No account linked to committer email " ,
399
+ Reason : "gpg.error.no_committer_account " ,
401
400
}
402
401
}
403
402
@@ -406,7 +405,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
406
405
log .Error (3 , "ListGPGKeys: %v" , err )
407
406
return & CommitVerification {
408
407
Verified : false ,
409
- Reason : "Failed to retrieve publics keys of committer " ,
408
+ Reason : "gpg.error.failed_retrieval_gpg_keys " ,
410
409
}
411
410
}
412
411
@@ -434,13 +433,13 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
434
433
}
435
434
return & CommitVerification { //Default at this stage
436
435
Verified : false ,
437
- Reason : "No known key found for this signature in database " ,
436
+ Reason : "gpg.error.no_gpg_keys_found " ,
438
437
}
439
438
}
440
439
441
440
return & CommitVerification {
442
- Verified : false , //Default value
443
- Reason : "Not a signed commit " , //Default value
441
+ Verified : false , //Default value
442
+ Reason : "gpg.error.not_signed_commit " , //Default value
444
443
}
445
444
}
446
445
0 commit comments