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

Method ProcessComponentVSA

internal/validate/vsa/service.go:57–91  ·  view source on GitHub ↗

ProcessComponentVSA processes VSA generation, writing, and attestation for a single component

(ctx context.Context, report applicationsnapshot.Report, comp applicationsnapshot.Component, gitURL, digest string)

Source from the content-addressed store, hash-verified

55
56// ProcessComponentVSA processes VSA generation, writing, and attestation for a single component
57func (s *Service) ProcessComponentVSA(ctx context.Context, report applicationsnapshot.Report, comp applicationsnapshot.Component, gitURL, digest string) (string, error) {
58 generator := NewGenerator(report, comp, s.policySource, s.policy)
59 writer := &Writer{
60 FS: s.fs,
61 TempDirPrefix: s.outputDir,
62 FilePerm: 0o600,
63 }
64
65 // Generate and write Predicate (new format)
66 writtenPath, err := GenerateAndWritePredicate(ctx, generator, writer)
67 if err != nil {
68 return "", fmt.Errorf("failed to generate and write component Predicate: %w", err)
69 }
70
71 // Create attestor and attest Predicate
72 // Use the image reference (without digest) as the repo for the subject name
73 imageRef := comp.ContainerImage
74 if idx := strings.LastIndex(imageRef, "@"); idx != -1 {
75 imageRef = imageRef[:idx] // Remove digest to get just the image reference
76 }
77 attestor, err := NewAttestor(writtenPath, imageRef, digest, s.signer)
78 if err != nil {
79 return "", fmt.Errorf("failed to create component attestor: %w", err)
80 }
81
82 envelopePath, err := AttestVSA(ctx, attestor)
83 if err != nil {
84 return "", fmt.Errorf("failed to attest component Predicate: %w", err)
85 }
86
87 log.WithFields(log.Fields{
88 "envelope_path": envelopePath,
89 }).Info("[VSA] Component Predicate attested and envelope written")
90 return envelopePath, nil
91}
92
93// ProcessSnapshotVSA processes VSA generation, writing, and attestation for the application snapshot
94func (s *Service) ProcessSnapshotVSA(ctx context.Context, report applicationsnapshot.Report) (string, error) {

Callers 2

ProcessAllVSAsMethod · 0.95

Calls 6

NewGeneratorFunction · 0.85
NewAttestorFunction · 0.85
AttestVSAFunction · 0.85
ErrorfMethod · 0.65
InfoMethod · 0.65

Tested by 1