Skip to content

Commit

Permalink
Merge pull request #119 from deeglaze/nilvalidate
Browse files Browse the repository at this point in the history
Add some nil checking to validate.go
  • Loading branch information
deeglaze authored Mar 19, 2024
2 parents 606477d + c50f298 commit 05c9303
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,21 @@ func validateKeys(report *spb.Report, options *Options) error {
}

func validateKeyKind(report *spb.Attestation) (*x509.Certificate, error) {
if report == nil {
return nil, fmt.Errorf("attestation cannot be nil")
}
if report.GetReport() == nil {
return nil, fmt.Errorf("attestation report cannot be nil")
}
if report.GetCertificateChain() == nil {
return nil, fmt.Errorf("attestation certificate chain cannot be nil")
}

info, err := abi.ParseSignerInfo(report.GetReport().GetSignerInfo())
if err != nil {
return nil, err
}

switch info.SigningKey {
case abi.VcekReportSigner:
if len(report.GetCertificateChain().VcekCert) != 0 {
Expand Down

0 comments on commit 05c9303

Please sign in to comment.