Skip to content

Commit

Permalink
leo feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Oct 5, 2023
1 parent 00f689f commit 65a1337
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions cli/internal/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func runVerify(cmd *cobra.Command, _ []string) error {
}
return &attestationDocFormatterImpl{log}
}
// TODO(elchead): unify the formatters to share the parsing logic
v := &verifyCmd{log: log}
fetcher := attestationconfigapi.NewFetcher()
return v.verify(cmd, fileHandler, verifyClient, formatterFactory, fetcher)
Expand Down Expand Up @@ -295,7 +294,7 @@ type jsonAttestationDocFormatter struct {
func (f *jsonAttestationDocFormatter) format(ctx context.Context, docString string, _ bool,
_ bool, _ measurements.M, attestationServiceURL string,
) (string, error) {
instanceInfo, err := unmarshalInstanceInfo(docString)
instanceInfo, err := extractInstanceInfo(docString)
if err != nil {
return "", fmt.Errorf("unmarshal instance info: %w", err)
}
Expand Down Expand Up @@ -376,7 +375,7 @@ func (f *attestationDocFormatterImpl) format(ctx context.Context, docString stri
if err != nil {
return "", fmt.Errorf("parsing SNP report: %w", err)
}
f.printSNPReport(b, snpReport)
f.buildSNPReport(b, snpReport)
if err := parseMAAToken(ctx, b, instanceInfo.MAAToken, attestationServiceURL); err != nil {
return "", fmt.Errorf("print MAA token: %w", err)
}
Expand Down Expand Up @@ -477,7 +476,7 @@ func (f *attestationDocFormatterImpl) parseQuotes(b *strings.Builder, quotes []*
return nil
}

func (f *attestationDocFormatterImpl) printSNPReport(b *strings.Builder, report verify.SNPReport) {
func (f *attestationDocFormatterImpl) buildSNPReport(b *strings.Builder, report verify.SNPReport) {
writeTCB := func(tcb verify.TCBVersion) {
writeIndentfln(b, 3, "Secure Processor bootloader SVN: %d", tcb.Bootloader)
writeIndentfln(b, 3, "Secure Processor operating system SVN: %d", tcb.TEE)
Expand Down Expand Up @@ -842,7 +841,7 @@ func newTCBVersion(tcbVersion kds.TCBVersion) (res verify.TCBVersion) {
}
}

func unmarshalInstanceInfo(docString string) (azureInstanceInfo, error) {
func extractInstanceInfo(docString string) (azureInstanceInfo, error) {
var doc attestationDoc
if err := json.Unmarshal([]byte(docString), &doc); err != nil {
return azureInstanceInfo{}, fmt.Errorf("unmarshal attestation document: %w", err)
Expand Down
5 changes: 3 additions & 2 deletions internal/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only
*/

/*
Package verify provides the the types for the types of the verify report in JSON format.
Package verify provides the types for the verify report in JSON format.
At the moment the package is concerned with providing an interface for constellation verify and the attestationconfigapi upload tool through JSON serialization.
The package provides an interface for constellation verify and
the attestationconfigapi upload tool through JSON serialization.
*/
package verify

Expand Down

0 comments on commit 65a1337

Please sign in to comment.