Skip to content

Commit

Permalink
chore: bump trivy-0.51.1 (#2054)
Browse files Browse the repository at this point in the history
* chore: bump trivy-0.51.1

Signed-off-by: chenk <hen.keinan@gmail.com>

* chore: bump trivy-0.51.1

Signed-off-by: chenk <hen.keinan@gmail.com>

* chore: bump trivy-0.51.1

Signed-off-by: chenk <hen.keinan@gmail.com>

* chore: bump trivy-0.51.1

Signed-off-by: chenk <hen.keinan@gmail.com>

* chore: bump trivy-0.51.1

Signed-off-by: chenk <hen.keinan@gmail.com>

---------

Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan authored May 12, 2024
1 parent d567158 commit c19a52b
Show file tree
Hide file tree
Showing 23 changed files with 356 additions and 439 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Keeps security report resources updated
| trivy.image.pullPolicy | string | `"IfNotPresent"` | pullPolicy is the imge pull policy used for trivy image , valid values are (Always, Never, IfNotPresent) |
| trivy.image.registry | string | `"ghcr.io"` | registry of the Trivy image |
| trivy.image.repository | string | `"aquasecurity/trivy"` | repository of the Trivy image |
| trivy.image.tag | string | `"0.50.4"` | tag version of the Trivy image |
| trivy.image.tag | string | `"0.51.1"` | tag version of the Trivy image |
| trivy.imageScanCacheDir | string | `"/tmp/trivy/.cache"` | imageScanCacheDir the flag to set custom path for trivy image scan `cache-dir` parameter. Only applicable in image scan mode. |
| trivy.includeDevDeps | bool | `false` | includeDevDeps include development dependencies in the report (supported: npm, yarn) (default: false) note: this flag is only applicable when trivy.command is set to filesystem |
| trivy.insecureRegistries | object | `{}` | The registry to which insecure connections are allowed. There can be multiple registries with different keys. |
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ trivy:
# -- repository of the Trivy image
repository: aquasecurity/trivy
# -- tag version of the Trivy image
tag: 0.50.4
tag: 0.51.1
# -- imagePullSecret is the secret name to be used when pulling trivy image from private registries example : reg-secret
# It is the user responsibility to create the secret for the private registry in `trivy-operator` namespace
imagePullSecret: ~
Expand Down
2 changes: 1 addition & 1 deletion deploy/static/trivy-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3025,7 +3025,7 @@ metadata:
app.kubernetes.io/managed-by: kubectl
data:
trivy.repository: "ghcr.io/aquasecurity/trivy"
trivy.tag: "0.50.4"
trivy.tag: "0.51.1"
trivy.imagePullPolicy: "IfNotPresent"
trivy.additionalVulnerabilityReportFields: ""
trivy.severity: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL"
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/crds/clustervulnerability-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ report:
scanner:
name: Trivy
vendor: Aqua Security
version: 0.50.4
version: 0.51.1
summary:
criticalCount: 0
highCount: 4
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/crds/sbom-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ report:
scanner:
name: Trivy
vendor: Aqua Security
version: 0.50.4
version: 0.51.1
summary:
componentsCount: 5
dependenciesCount: 5
Expand Down
146 changes: 71 additions & 75 deletions go.mod

Large diffs are not rendered by default.

374 changes: 185 additions & 189 deletions go.sum

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,18 @@ func buildPolicyLoader(tc trivyoperator.ConfigData) (policy.Loader, error) {
if err != nil {
return nil, fmt.Errorf("OCI artifact error: %w", err)
}
ro := types.RegistryOptions{}
if registryUser != "" && registryPassword != "" {
artifact.RegistryOptions = types.RegistryOptions{
ro = types.RegistryOptions{
Credentials: []types.Credential{
{
Username: registryUser,
Password: registryPassword,
},
},
}
artifact.RegistryOptions = ro
}
policyLoader := policy.NewPolicyLoader(tc.PolicyBundleOciRef(), gcache.New(1).LRU().Build(), mp.WithOCIArtifact(artifact))
policyLoader := policy.NewPolicyLoader(tc.PolicyBundleOciRef(), gcache.New(1).LRU().Build(), ro, mp.WithOCIArtifact(artifact))
return policyLoader, nil
}
2 changes: 1 addition & 1 deletion pkg/plugins/trivy/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func TestPlugin_Init(t *testing.T) {
},
Data: map[string]string{
"trivy.repository": DefaultImageRepository,
"trivy.tag": "0.50.4",
"trivy.tag": "0.51.1",
"trivy.severity": DefaultSeverity,
"trivy.slow": "true",
"trivy.mode": string(Standalone),
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/trivy/jobspec_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/plugins/trivy/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (p *plugin) Init(ctx trivyoperator.PluginContext) error {
return ctx.EnsureConfig(trivyoperator.PluginConfig{
Data: map[string]string{
keyTrivyImageRepository: DefaultImageRepository,
keyTrivyImageTag: "0.50.4",
keyTrivyImageTag: "0.51.1",
KeyTrivySeverity: DefaultSeverity,
keyTrivySlow: "true",
keyTrivyMode: string(Standalone),
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/trivy/testdata/fixture/alpine_sbom.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"type": "application",
"group": "aquasecurity",
"name": "trivy",
"version": "0.50.4"
"version": "0.51.1"
}
]
},
Expand Down
40 changes: 21 additions & 19 deletions pkg/policy/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"sync"
"time"

"github.com/aquasecurity/trivy/pkg/fanal/types"
mp "github.com/aquasecurity/trivy/pkg/policy"
"github.com/bluele/gcache"
"github.com/go-logr/logr"
"golang.org/x/xerrors"
"os"
"path/filepath"
ctrl "sigs.k8s.io/controller-runtime"
"strings"
"sync"
"time"
)

const (
Expand All @@ -26,22 +26,24 @@ type Loader interface {
}

type policyLoader struct {
PolicyRepo string
mutex sync.RWMutex
cache gcache.Cache
expiration *time.Duration
options []mp.Option
logger logr.Logger
PolicyRepo string
mutex sync.RWMutex
cache gcache.Cache
expiration *time.Duration
options []mp.Option
logger logr.Logger
RegistryOptions types.RegistryOptions
}

func NewPolicyLoader(pr string, cache gcache.Cache, opts ...mp.Option) Loader {
func NewPolicyLoader(pr string, cache gcache.Cache, registryOptions types.RegistryOptions, opts ...mp.Option) Loader {
expiration := 24 * time.Hour
return &policyLoader{
PolicyRepo: pr,
cache: cache,
options: opts,
expiration: &expiration,
logger: ctrl.Log.WithName("policyLoader"),
PolicyRepo: pr,
cache: cache,
options: opts,
expiration: &expiration,
logger: ctrl.Log.WithName("policyLoader"),
RegistryOptions: registryOptions,
}
}

Expand Down Expand Up @@ -96,7 +98,7 @@ func (pl *policyLoader) getBuiltInPolicies(ctx context.Context) ([]string, error
return nil, xerrors.Errorf("policy client error: %w", err)
}

if err = client.DownloadBuiltinPolicies(ctx); err != nil {
if err = client.DownloadBuiltinPolicies(ctx, pl.RegistryOptions); err != nil {
return nil, xerrors.Errorf("failed to download built-in policies: %w", err)
}
return client.LoadBuiltinPolicies()
Expand Down
9 changes: 5 additions & 4 deletions pkg/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aquasecurity/trivy-operator/pkg/plugins/trivy"
"github.com/aquasecurity/trivy-operator/pkg/policy"
"github.com/aquasecurity/trivy-operator/pkg/utils"
"github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/iac/scan"
"github.com/bluele/gcache"
. "github.com/onsi/gomega"
Expand All @@ -35,7 +36,7 @@ func TestPolicies_PoliciesByKind(t *testing.T) {
"library.kubernetes.rego": "<REGO_A>",
"library.utils.rego": "<REGO_B>",
"policy.access_to_host_pid.rego": "<REGO_C>",
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build()), "1.27.1")
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build(), types.RegistryOptions{}), "1.27.1")
_, err := config.PoliciesByKind("Pod")
g.Expect(err).To(MatchError("kinds not defined for policy: policy.access_to_host_pid.rego"))
})
Expand All @@ -44,7 +45,7 @@ func TestPolicies_PoliciesByKind(t *testing.T) {
g := NewGomegaWithT(t)
config := policy.NewPolicies(map[string]string{
"policy.access_to_host_pid.kinds": "Workload",
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build()), "1.27.1")
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build(), types.RegistryOptions{}), "1.27.1")
_, err := config.PoliciesByKind("Pod")
g.Expect(err).To(MatchError("expected policy not found: policy.access_to_host_pid.rego"))
})
Expand All @@ -71,7 +72,7 @@ func TestPolicies_PoliciesByKind(t *testing.T) {
"policy.privileged": "<REGO_E>",
// This one should be skipped (no policy. prefix)
"foo": "bar",
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build()), "1.27.1")
}, testConfig{}, ctrl.Log.WithName("policy logger"), policy.NewPolicyLoader("", gcache.New(1).LRU().Build(), types.RegistryOptions{}), "1.27.1")
g.Expect(config.PoliciesByKind("Pod")).To(Equal(map[string]string{
"policy.access_to_host_pid.rego": "<REGO_C>",
"policy.cpu_not_limited.rego": "<REGO_D>",
Expand Down Expand Up @@ -145,7 +146,7 @@ func TestPolicies_Supported(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
g := NewGomegaWithT(t)
log := ctrl.Log.WithName("resourcecontroller")
ready, err := policy.NewPolicies(tc.data, testConfig{}, log, policy.NewPolicyLoader("", gcache.New(1).LRU().Build()), "1.27.1").SupportedKind(tc.resource, tc.rbacEnable)
ready, err := policy.NewPolicies(tc.data, testConfig{}, log, policy.NewPolicyLoader("", gcache.New(1).LRU().Build(), types.RegistryOptions{}), "1.27.1").SupportedKind(tc.resource, tc.rbacEnable)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(ready).To(Equal(tc.expected))
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/vulnerabilityreport/controller/testdata/sbom.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"scanner": {
"name": "Trivy",
"vendor": "Aqua Security",
"version": "0.50.4"
"version": "0.51.1"
},
"summary": {
"componentsCount": 5,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/sbom-client-server/workload/00-sbom-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,7 @@ report:
scanner:
name: Trivy
vendor: Aqua Security
version: 0.50.4
version: 0.51.1
summary:
componentsCount: 110
dependenciesCount: 110
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/sbom-fs/workload/00-sbom-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,7 @@ report:
scanner:
name: Trivy
vendor: Aqua Security
version: 0.50.4
version: 0.51.1
summary:
componentsCount: 110
dependenciesCount: 110
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/sbom-standalone/workload/00-sbom-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,7 @@ report:
scanner:
name: Trivy
vendor: Aqua Security
version: 0.50.4
version: 0.51.1
summary:
componentsCount: 110
dependenciesCount: 110
Expand Down
Loading

0 comments on commit c19a52b

Please sign in to comment.