Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

tomersein
Copy link
Contributor

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

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have tested my code in common scenarios and confirmed there are no regressions

Signed-off-by: tomersein <[email protected]>
@@ -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"`
Copy link
Contributor

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 👍

Copy link
Contributor Author

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?

Copy link
Contributor

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)

Copy link
Contributor Author

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support configuration of layer size in Syft
2 participants