You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix container-images flag to support prefix syntax and restrict to single images
- Add support for Syft-compatible prefix syntax (docker:, podman:, containerd:, registry:, docker-archive:, oci-archive:, oci-dir:, file:)
- Restrict scanning to single images only (prevent bulk directory/registry scanning)
- Remove singularity support
- Add comprehensive validation for all supported formats
- Maintain backward compatibility with traditional image:tag format
Fixes AST-108903
// Define supported prefixes for container image references
3322
+
// Note: 'dir:' prefix is intentionally excluded to prevent scanning entire directories
3323
+
supportedPrefixes:= []string{
3324
+
"docker:",
3325
+
"podman:",
3326
+
"containerd:",
3327
+
"registry:",
3328
+
"docker-archive:",
3329
+
"oci-archive:",
3330
+
"oci-dir:",
3331
+
"file:",
3332
+
}
3333
+
3334
+
// Check for explicitly forbidden prefixes first
3335
+
ifstrings.HasPrefix(containerImage, "dir:") {
3336
+
returnerrors.Errorf("Invalid value for --container-images flag. The 'dir:' prefix is not supported as it would scan entire directories rather than a single image")
returnerrors.Errorf("Invalid value for --container-images flag. Registry format must specify a single image, not just a registry URL. Use format: registry:<registry-url>/<image>:<tag> or registry:<image>:<tag>")
3419
+
}
3420
+
3421
+
// Check for registry:host:port format (just registry URL with port)
// This looks like registry:port format without image
3426
+
returnerrors.Errorf("Invalid value for --container-images flag. Registry format must specify a single image, not just a registry URL. Use format: registry:<registry-url>/<image>:<tag>")
3427
+
}
3428
+
}
3429
+
3430
+
returnnil
3431
+
}
3432
+
3433
+
// For daemon-based prefixes (docker:, podman:, containerd:)
3434
+
// Validate they follow the image:tag format, but be flexible with complex registry URLs
returnerrors.Errorf("Invalid value for --container-images flag. The value must be in the format <image-name>:<image-tag> or <image-name>.tar")
3461
+
returnerrors.Errorf("Invalid value for --container-images flag. The value must be in the format <image-name>:<image-tag>, <image-name>.tar, or use a supported prefix (docker:, podman:, containerd:, registry:, docker-archive:, oci-archive:, oci-dir:, file:)")
0 commit comments