Skip to content

Commit

Permalink
verify: verify active manifest at Coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
davidweisse committed Jun 26, 2024
1 parent bc6626f commit 178daf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func runGenerate(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("failed to marshal manifest: %w", err)
}
if err := os.WriteFile(flags.manifestPath, manifestData, 0o644); err != nil {
if err := os.WriteFile(flags.manifestPath, append(manifestData, '\n'), 0o644); err != nil {
return fmt.Errorf("failed to write manifest: %w", err)
}

Expand Down
10 changes: 9 additions & 1 deletion cli/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package cmd

import (
"bytes"
"crypto/sha256"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -99,7 +100,7 @@ func runVerify(cmd *cobra.Command, _ []string) error {
}
log.Debug("Got response")

fmt.Fprintln(cmd.OutOrStdout(), "✔️ Successfully verified coordinator")
fmt.Fprintln(cmd.OutOrStdout(), "✔️ Successfully verified Coordinator CVM based on reference values from manifest")

filelist := map[string][]byte{
coordRootPEMFilename: resp.RootCA,
Expand All @@ -118,6 +119,13 @@ func runVerify(cmd *cobra.Command, _ []string) error {
}

fmt.Fprintf(cmd.OutOrStdout(), "✔️ Wrote Coordinator configuration and keys to %s\n", filepath.Join(flags.workspaceDir, verifyDir))

currentManifest := resp.Manifests[len(resp.Manifests)-1]
if !bytes.Equal(currentManifest, manifestBytes) {
return fmt.Errorf("manifest active at Coordinator does not match expected manifest")
}

fmt.Fprintln(cmd.OutOrStdout(), "✔️ Manifest active at Coordinator matches expected manifest")
fmt.Fprintln(cmd.OutOrStdout(), " Please verify the manifest history and policies")

return nil
Expand Down

0 comments on commit 178daf4

Please sign in to comment.