-
Notifications
You must be signed in to change notification settings - Fork 580
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
add set layer limit #3464
base: main
Are you sure you want to change the base?
add set layer limit #3464
Conversation
Signed-off-by: tomersein <[email protected]>
cmd/syft/internal/options/source.go
Outdated
@@ -20,7 +22,8 @@ type sourceConfig struct { | |||
} | |||
|
|||
type fileSource struct { | |||
Digests []string `json:"digests" yaml:"digests" mapstructure:"digests"` | |||
Digests []string `json:"digests" yaml:"digests" mapstructure:"digests"` | |||
MaxLayerSize string `json:"max-layer-size" yaml:"max-layer-size" mapstructure:"max-layer-size"` |
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.
Hey, @tomersein I think we should add this configuration to the imageSource
(see here), instead of the fileSource
. Other than that, I think this PR is probably good. Thanks 👍
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.
hi @kzantow the image-souce doesn't work when i put it inside, only filesource.
does it make sense?
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.
You need to add a PostLoad
hook for the imageSource
; I think it would look like this:
func (c *imageSource) PostLoad() error {
if c.MaxLayerSize != "" {
perFileReadLimit, err := humanize.ParseBytes(c.MaxLayerSize)
if err != nil {
return err
}
stereoscopeFile.SetPerFileReadLimit(int64(perFileReadLimit))
}
return nil
}
You could ensure it's the right signature with:
var _ clio.PostLoader = (*imageSource)(nil)
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.
@kzantow
fixed, however when I locally check it, for some reason I can reproduce the previous behavior.
I try to config 1B to the maximum layer size, just to make sure the set works.. but the scan passes.
I wonder if it related to some caching my laptop does.
Signed-off-by: tomersein <[email protected]>
Description
Please include a summary of the changes along with any relevant motivation and context,
or link to an issue where this is explained.
Type of change
Checklist: