ValidateImageWithVSACheck executes validation with VSA expiration checking. If a valid, unexpired VSA exists, validation is skipped.
(ctx context.Context, comp app.SnapshotComponent, snap *app.SnapshotSpec, p policy.Policy, evaluators []evaluator.Evaluator, detailed bool, vsaChecker *vsa.VSAChecker, vsaExpiration time.Duration)
| 173 | // ValidateImageWithVSACheck executes validation with VSA expiration checking. |
| 174 | // If a valid, unexpired VSA exists, validation is skipped. |
| 175 | func ValidateImageWithVSACheck(ctx context.Context, comp app.SnapshotComponent, snap *app.SnapshotSpec, p policy.Policy, evaluators []evaluator.Evaluator, detailed bool, vsaChecker *vsa.VSAChecker, vsaExpiration time.Duration) (*output.Output, error) { |
| 176 | if trace.IsEnabled() { |
| 177 | region := trace.StartRegion(ctx, "ec:validate-image-with-vsa-check") |
| 178 | defer region.End() |
| 179 | trace.Logf(ctx, "", "image=%q vsa-expiration=%v", comp.ContainerImage, vsaExpiration) |
| 180 | } |
| 181 | |
| 182 | // Check for existing valid VSA |
| 183 | isValid, err := vsaChecker.IsValidVSA(ctx, comp.ContainerImage, vsaExpiration) |
| 184 | if err != nil { |
| 185 | log.Warnf("Failed to check for existing VSA for image %s: %v", comp.ContainerImage, err) |
| 186 | // Continue with validation on VSA lookup failure |
| 187 | } else if isValid { |
| 188 | log.WithFields(log.Fields{ |
| 189 | "image": comp.ContainerImage, |
| 190 | "expiration_threshold": vsaExpiration, |
| 191 | }).Info("Valid VSA found, skipping validation") |
| 192 | |
| 193 | // Return nil to indicate validation was skipped due to valid VSA |
| 194 | return nil, nil |
| 195 | } else { |
| 196 | log.Debugf("No valid VSA found for image %s, proceeding with validation", comp.ContainerImage) |
| 197 | } |
| 198 | |
| 199 | // Perform normal validation, if no valid VSA is found |
| 200 | log.Debugf("Performing full validation for image %s", comp.ContainerImage) |
| 201 | return ValidateImage(ctx, comp, snap, p, evaluators, detailed) |
| 202 | } |
| 203 | |
| 204 | func resolveAndSetImageUrl(ctx context.Context, url string, asi *application_snapshot_image.ApplicationSnapshotImage) (string, error) { |
| 205 | // Ensure image URL contains a digest to avoid ambiguity in the next |