()
| 23 | ) |
| 24 | |
| 25 | func newAttestationVerifyCmd() *cobra.Command { |
| 26 | var fileOrURL string |
| 27 | cmd := &cobra.Command{ |
| 28 | Use: "verify file-or-url", |
| 29 | Short: "verify an attestation", |
| 30 | Long: "Verify an attestation by validating its validation material against the configured trusted root", |
| 31 | DisableFlagsInUseLine: true, |
| 32 | Example: ` # verify local attestation |
| 33 | chainloop attestation verify --bundle attestation.json |
| 34 | |
| 35 | # verify an attestation stored in an https endpoint |
| 36 | chainloop attestation verify -b https://myrepository/attestation.json`, |
| 37 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 38 | res, err := action.NewAttestationVerifyAction(ActionOpts).Run(cmd.Context(), fileOrURL) |
| 39 | if err != nil { |
| 40 | return fmt.Errorf("verifying attestation: %w", err) |
| 41 | } |
| 42 | if res { |
| 43 | ActionOpts.Logger.Info().Msg("attestation verified successfully") |
| 44 | } else { |
| 45 | ActionOpts.Logger.Warn().Msg("attestation couldn't be verified") |
| 46 | } |
| 47 | |
| 48 | return nil |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | cmd.Flags().StringVarP(&fileOrURL, "bundle", "b", "", "bundle path or URL") |
| 53 | cobra.CheckErr(cmd.MarkFlagRequired("bundle")) |
| 54 | |
| 55 | return cmd |
| 56 | } |
no test coverage detected