ProcessComponentVSA processes VSA generation, writing, and attestation for a single component
(ctx context.Context, report applicationsnapshot.Report, comp applicationsnapshot.Component, gitURL, digest string)
| 55 | |
| 56 | // ProcessComponentVSA processes VSA generation, writing, and attestation for a single component |
| 57 | func (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 |
| 94 | func (s *Service) ProcessSnapshotVSA(ctx context.Context, report applicationsnapshot.Report) (string, error) { |