-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(image): return error early if total size of layers exceeds limit #8294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
dd15a36
8d164f0
e9ce12d
b857a6a
71da46a
92888b6
e5574ca
c72cbcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -520,7 +520,14 @@ $ trivy image --podman-host /run/user/1000/podman/podman.sock YOUR_IMAGE | |||||
| ``` | ||||||
|
|
||||||
| ### Prevent scanning oversized container images | ||||||
| Use the `--max-image-size` flag to avoid scanning images that exceed a specified size. The size is specified in a human-readable format (e.g., `100MB`, `10GB`). If the compressed image size exceeds the specified threshold, an error is returned immediately. Otherwise, all layers are pulled, stored in a temporary folder, and their uncompressed size is verified before scanning. Temporary layers are always cleaned up, even after a successful scan. | ||||||
| Use the `--max-image-size` flag to avoid scanning images that exceed a specified size. The size is specified in a human-readable format (e.g., `100MB`, `10GB`). | ||||||
|
|
||||||
| An error is returned in the following cases: | ||||||
| - if the compressed image size exceeds the limit, | ||||||
| - if the total size of the layers exceeds the specified limit during their pulling, | ||||||
|
||||||
| - if the total size of the layers exceeds the specified limit during their pulling, | |
| - if the total size of the uncompressed layers exceeds the specified limit during their pulling, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 92888b6
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2255,11 +2255,19 @@ func TestArtifact_Inspect(t *testing.T) { | |
| }, | ||
| { | ||
| name: "sad path, image size is larger than the maximum", | ||
| imagePath: "../../test/testdata/alpine-311.tar.gz", | ||
| imagePath: "../../test/testdata/image2.tar", | ||
|
||
| artifactOpt: artifact.Option{ | ||
| ImageOption: types.ImageOptions{MaxImageSize: units.MB * 4.1}, | ||
|
||
| }, | ||
| wantErr: "uncompressed image size 4.2MB exceeds maximum allowed size 4.1MB", | ||
| }, | ||
| { | ||
| name: "sad path, the first layer is larger than the threshold", | ||
| imagePath: "../../test/testdata/image2.tar", | ||
| artifactOpt: artifact.Option{ | ||
| ImageOption: types.ImageOptions{MaxImageSize: units.MB * 4}, | ||
| ImageOption: types.ImageOptions{MaxImageSize: units.MB * 1}, | ||
| }, | ||
| wantErr: "uncompressed image size 5.86MB exceeds maximum allowed size 4MB", | ||
| wantErr: "the accumulated size of uncompressed layers 2.1MB exceeds maximum allowed size 1MB", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, the most significant difference between markdown and mkdocs is that a newline is required before bullet points.
It's broken now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 92888b6