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

feat(misconf): Support custom URLs for policy bundle #4834

Merged
merged 6 commits into from
Jul 26, 2023

Conversation

simar7
Copy link
Member

@simar7 simar7 commented Jul 17, 2023

Description

This PR adds support for custom policy bundles to be specified with a flag --policy-bundle-url as an option to Trivy.

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@simar7 simar7 self-assigned this Jul 17, 2023
@simar7 simar7 marked this pull request as ready for review July 19, 2023 13:42
pkg/flag/misconf_flags.go Outdated Show resolved Hide resolved
pkg/policy/policy.go Outdated Show resolved Hide resolved
This PR adds support for custom policy bundles to be specified
with a flag `--policy-bundle-url` as an option to Trivy.

Fixes: #4672

Signed-off-by: Simar <simar@linux.com>
Signed-off-by: Simar <simar@linux.com>
Signed-off-by: Simar <simar@linux.com>
Signed-off-by: Simar <simar@linux.com>
@@ -76,10 +76,13 @@ func NewClient(cacheDir string, quiet bool, opts ...Option) (*Client, error) {
}, nil
}

func (c *Client) populateOCIArtifact() error {
func (c *Client) populateOCIArtifact(policyBundleRepository string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if adding policyRepo here rather than passing the repo to each method?

// Client implements policy operations
type Client struct {
*options
policyDir string
quiet bool
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean adding repo to NewClient.

func NewClient(cacheDir, repo string, quiet bool, opts ...Option) (*Client, error) {

func NewClient(cacheDir string, quiet bool, opts ...Option) (*Client, error) {

Signed-off-by: Simar <simar@linux.com>
@knqyf263 knqyf263 added this pull request to the merge queue Jul 26, 2023
Merged via the queue into main with commit 11618c9 Jul 26, 2023
26 checks passed
@knqyf263 knqyf263 deleted the custom-url-policy-bundle branch July 26, 2023 09:11
AnaisUrlichs pushed a commit to AnaisUrlichs/trivy that referenced this pull request Aug 10, 2023
* feat(misconf): Support custom URLs for policy bundle

This PR adds support for custom policy bundles to be specified
with a flag `--policy-bundle-url` as an option to Trivy.

Fixes: aquasecurity#4672

Signed-off-by: Simar <simar@linux.com>

* update docs

Signed-off-by: Simar <simar@linux.com>

* rename flag to `--policy-bundle-repository`

Signed-off-by: Simar <simar@linux.com>

* fix field

* rebase and update docs

Signed-off-by: Simar <simar@linux.com>

* set policyBundleRepo on client

Signed-off-by: Simar <simar@linux.com>

---------

Signed-off-by: Simar <simar@linux.com>
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.

feat: Support custom URLs for builtin policies
3 participants