MCPcopy Create free account
hub / github.com/conforma/cli / validateImageCmd

Function validateImageCmd

cmd/validate/image.go:56–591  ·  view source on GitHub ↗
(validate imageValidationFunc)

Source from the content-addressed store, hash-verified

54var newOPAEvaluator = evaluator.NewOPAEvaluator
55
56func validateImageCmd(validate imageValidationFunc) *cobra.Command {
57 data := &imageData{
58 strict: true,
59 workers: 5,
60 filterType: "include-exclude", // Default to include-exclude filter
61 vsaExpiration: 168 * time.Hour, // 7 days default
62 }
63
64 validOutputFormats := applicationsnapshot.OutputFormats
65
66 cmd := &cobra.Command{
67 Use: "image",
68 Short: "Validate conformance of container images with the provided policies",
69
70 Long: hd.Doc(`
71 Validate conformance of container images with the provided policies
72
73 For each image, validation is performed in stages to determine if the image
74 conforms to the provided policies.
75
76 The first validation stage determines if an image has been signed, and the
77 signature matches the provided public key. This is akin to the "cosign verify"
78 command.
79
80 The second validation stage determines if one or more attestations exist, and
81 those attestations have been signed matching the provided public key, similarly
82 to the "cosign verify-attestation" command. This stage temporarily stores the
83 attestations for usage in the next stage.
84
85 The final stage verifies the attestations conform to rego policies defined in
86 the EnterpriseContractPolicy.
87
88 Validation advances each stage as much as possible for each image in order to
89 capture all issues in a single execution.
90 `),
91
92 Example: hd.Doc(`
93 Validate single image with the policy defined in the EnterpriseContractPolicy
94 custom resource named "default" in the enterprise-contract-service Kubernetes
95 namespace:
96
97 ec validate image --image registry/name:tag
98
99 Validate multiple images from an ApplicationSnapshot Spec file:
100
101 ec validate image --images my-app.yaml
102
103 Validate attestation of images from an inline ApplicationSnapshot Spec:
104
105 ec validate image --images '{"components":[{"containerImage":"<image url>"}]}'
106
107 Use a different public key than the one from the EnterpriseContractPolicy resource:
108
109 ec validate image --image registry/name:tag --public-key <path/to/public/key>
110
111 Use a different Rekor URL than the one from the EnterpriseContractPolicy resource:
112
113 ec validate image --image registry/name:tag --rekor-url https://rekor.example.org

Calls 15

DestroyMethod · 0.95
generateVSAsDSSEMethod · 0.95
DetermineInputSpecFunction · 0.92
PreProcessPolicyFunction · 0.92
PolicySourcesFromFunction · 0.92
IsOpaEnabledFunction · 0.92
workerFunction · 0.85