Skip to content

Commit 6dcabdd

Browse files
nikpivkinsimar7
authored andcommitted
chore(deps) bump Trivy
Signed-off-by: Nikita Pivkin <nikita.pivkin@smartforce.io>
1 parent a76c0e9 commit 6dcabdd

File tree

7 files changed

+66
-74
lines changed

7 files changed

+66
-74
lines changed

cmd/avd_generator/main.go

+19-14
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,38 @@ import (
55
goast "go/ast"
66
"go/parser"
77
"go/token"
8-
"io"
98
"os"
109
"path/filepath"
1110
"strings"
1211
"text/template"
1312

1413
policies "github.com/aquasecurity/trivy-checks"
1514
"github.com/aquasecurity/trivy/pkg/iac/framework"
16-
_ "github.com/aquasecurity/trivy/pkg/iac/rego"
17-
registered "github.com/aquasecurity/trivy/pkg/iac/rules"
15+
"github.com/aquasecurity/trivy/pkg/iac/rego"
16+
"github.com/aquasecurity/trivy/pkg/iac/rules"
1817
"github.com/aquasecurity/trivy/pkg/iac/scan"
1918
types "github.com/aquasecurity/trivy/pkg/iac/types/rules"
2019
)
2120

2221
func main() {
22+
generateDocs("avd_docs")
23+
}
24+
25+
func generateDocs(path string) {
2326
var generateCount int
2427

25-
for _, metadata := range registered.GetRegistered(framework.ALL) {
26-
writeDocsFile(metadata, "avd_docs")
28+
// Clean up all Go checks
29+
rules.Reset()
30+
31+
// Load Rego checks
32+
rego.LoadAndRegister()
33+
34+
for _, metadata := range rules.GetRegistered(framework.ALL) {
35+
writeDocsFile(metadata, path)
2736
generateCount++
2837
}
2938

30-
fmt.Printf("\nGenerated %d files in avd_docs\n", generateCount)
39+
fmt.Printf("\nGenerated %d files in %s\n", generateCount, path)
3140
}
3241

3342
// nolint: cyclop
@@ -94,7 +103,7 @@ func generateExamplesForEngine(rule scan.Rule, engine *scan.EngineMetadata, docp
94103
if err != nil {
95104
fail("error occurred creating the %s file for %s", provider, docpath)
96105
}
97-
defer func() { _ = file.Close() }()
106+
defer file.Close()
98107

99108
if err := tmpl.Execute(file, rule); err != nil {
100109
fail("error occurred generating the document %v", err)
@@ -109,17 +118,13 @@ func fail(msg string, args ...interface{}) {
109118
os.Exit(1)
110119
}
111120

112-
func readFileFromPolicyFS(path string) (io.Reader, error) {
113-
path = strings.TrimPrefix(path, "rules/")
114-
return policies.EmbeddedPolicyFileSystem.Open(path)
115-
116-
}
117-
118121
func GetExampleValuesFromFile(filename string, exampleType string) ([]string, error) {
119-
r, err := readFileFromPolicyFS(filename)
122+
r, err := policies.EmbeddedPolicyFileSystem.Open(filename)
120123
if err != nil {
121124
return nil, err
122125
}
126+
defer r.Close()
127+
123128
f, err := parser.ParseFile(token.NewFileSet(), filename, r, parser.AllErrors)
124129
if err != nil {
125130
return nil, err

cmd/avd_generator/main_test.go

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
11
package main
22

33
import (
4-
"fmt"
54
"os"
6-
"path"
75
"path/filepath"
8-
"runtime"
96
"testing"
107

11-
"github.com/aquasecurity/trivy/pkg/iac/framework"
12-
registered "github.com/aquasecurity/trivy/pkg/iac/rules"
138
"github.com/stretchr/testify/assert"
149
"github.com/stretchr/testify/require"
1510
)
1611

17-
func init() { // change the pwd for the test to top level defesc dir
18-
_, filename, _, _ := runtime.Caller(0)
19-
dir := path.Join(path.Dir(filename), "../..")
20-
err := os.Chdir(dir)
21-
if err != nil {
22-
panic(err)
23-
}
24-
}
25-
2612
func Test_AVDPageGeneration(t *testing.T) {
2713
tmpDir := t.TempDir()
2814
defer func() {
2915
os.RemoveAll(tmpDir)
3016
}()
3117

32-
var generateCount int
33-
for _, metadata := range registered.GetRegistered(framework.ALL) {
34-
writeDocsFile(metadata, tmpDir)
35-
generateCount++
36-
}
37-
fmt.Printf("\nGenerated %d files in avd_docs\n", generateCount)
18+
generateDocs(tmpDir)
3819

3920
// check golang policies
4021
b, err := os.ReadFile(filepath.Join(tmpDir, "aws/rds/AVD-AWS-0077", "Terraform.md"))

go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ go 1.22.0
55
toolchain go1.22.2
66

77
require (
8-
github.com/aquasecurity/trivy v0.54.1-0.20240830061815-3a5d09175956
8+
github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1
99
github.com/liamg/iamgo v0.0.9
1010
github.com/liamg/memoryfs v1.6.0
1111
github.com/open-policy-agent/opa v0.67.1
12-
github.com/owenrumney/squealer v1.2.3
13-
github.com/samber/lo v1.46.0
12+
github.com/owenrumney/squealer v1.2.4
13+
github.com/samber/lo v1.47.0
1414
github.com/stretchr/testify v1.9.0
1515
gopkg.in/yaml.v3 v3.0.1
1616
mvdan.cc/sh/v3 v3.8.0
1717
)
1818

1919
require (
20-
dario.cat/mergo v1.0.0 // indirect
20+
dario.cat/mergo v1.0.1 // indirect
2121
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
2222
github.com/Microsoft/go-winio v0.6.2 // indirect
2323
github.com/OneOfOne/xxhash v1.2.8 // indirect
@@ -65,7 +65,7 @@ require (
6565
github.com/gorilla/mux v1.8.1 // indirect
6666
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
6767
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
68-
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
68+
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
6969
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7070
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
7171
github.com/kevinburke/ssh_config v1.2.0 // indirect
@@ -77,7 +77,7 @@ require (
7777
github.com/mattn/go-runewidth v0.0.15 // indirect
7878
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
7979
github.com/mitchellh/mapstructure v1.5.0 // indirect
80-
github.com/moby/buildkit v0.15.1 // indirect
80+
github.com/moby/buildkit v0.15.2 // indirect
8181
github.com/moby/docker-image-spec v1.3.1 // indirect
8282
github.com/moby/locker v1.0.1 // indirect
8383
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -133,7 +133,7 @@ require (
133133
golang.org/x/sys v0.23.0 // indirect
134134
golang.org/x/text v0.17.0 // indirect
135135
golang.org/x/time v0.6.0 // indirect
136-
golang.org/x/tools v0.23.0 // indirect
136+
golang.org/x/tools v0.24.0 // indirect
137137
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
138138
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
139139
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
@@ -142,7 +142,7 @@ require (
142142
gopkg.in/ini.v1 v1.67.0 // indirect
143143
gopkg.in/warnings.v0 v0.1.2 // indirect
144144
gopkg.in/yaml.v2 v2.4.0 // indirect
145-
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
145+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
146146
oras.land/oras-go/v2 v2.3.1 // indirect
147147
sigs.k8s.io/yaml v1.4.0 // indirect
148148
)

go.sum

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2-
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
3-
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
2+
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
3+
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
44
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
55
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
66
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
@@ -26,8 +26,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
2626
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
2727
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
2828
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
29-
github.com/aquasecurity/trivy v0.54.1-0.20240830061815-3a5d09175956 h1:+VO7TT3yr7Vcsev2qGxKvWjTOwHXExhtIN/EtiiaMlY=
30-
github.com/aquasecurity/trivy v0.54.1-0.20240830061815-3a5d09175956/go.mod h1:WYFvGq6bmKoVMVQ0UIa3QwiX9t9tOpV8Y9Cq6E9CB20=
29+
github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1 h1:73LIE4lUNO9QBo65hsWaTam85wAySri2mlQIza6fZXk=
30+
github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1/go.mod h1:Q/GQxnF41AI1oeeo68n18HFRn11Mkji5T8oZjQfbNk8=
3131
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
3232
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
3333
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
@@ -90,8 +90,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
9090
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
9191
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
9292
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
93-
github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY=
94-
github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
93+
github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4=
94+
github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
9595
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
9696
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
9797
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
@@ -193,8 +193,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737
193193
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
194194
github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM=
195195
github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM=
196-
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
197-
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
196+
github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
197+
github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
198198
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
199199
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
200200
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
@@ -244,8 +244,8 @@ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTS
244244
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
245245
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
246246
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
247-
github.com/moby/buildkit v0.15.1 h1:J6wrew7hphKqlq1wuu6yaUb/1Ra7gEzDAovylGztAKM=
248-
github.com/moby/buildkit v0.15.1/go.mod h1:Yis8ZMUJTHX9XhH9zVyK2igqSHV3sxi3UN0uztZocZk=
247+
github.com/moby/buildkit v0.15.2 h1:DnONr0AoceTWyv+plsQ7IhkSaj+6o0WyoaxYPyTFIxs=
248+
github.com/moby/buildkit v0.15.2/go.mod h1:Yis8ZMUJTHX9XhH9zVyK2igqSHV3sxi3UN0uztZocZk=
249249
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
250250
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
251251
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
@@ -276,8 +276,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
276276
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
277277
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
278278
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
279-
github.com/owenrumney/squealer v1.2.3 h1:7v2BGNReEHYGyopOpjnurbnowk5WWagpN/u9KEu0uUU=
280-
github.com/owenrumney/squealer v1.2.3/go.mod h1:F3PF/UaTAzaexT/cvvMYCSRHLRPBCiUcPClz3SZ6618=
279+
github.com/owenrumney/squealer v1.2.4 h1:77CEDP10mgvFLWHzUIBTfFIj9RkJ5h36YQhZ48GtjsQ=
280+
github.com/owenrumney/squealer v1.2.4/go.mod h1:F3PF/UaTAzaexT/cvvMYCSRHLRPBCiUcPClz3SZ6618=
281281
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
282282
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
283283
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
@@ -316,8 +316,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
316316
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
317317
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
318318
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
319-
github.com/samber/lo v1.46.0 h1:w8G+oaCPgz1PoCJztqymCFaKwXt+5cCXn51uPxExFfQ=
320-
github.com/samber/lo v1.46.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
319+
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
320+
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
321321
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
322322
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
323323
github.com/shirou/gopsutil/v3 v3.24.2 h1:kcR0erMbLg5/3LcInpw0X/rrPSqq4CDPyI6A6ZRC18Y=
@@ -367,10 +367,10 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
367367
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
368368
github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes=
369369
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
370-
github.com/testcontainers/testcontainers-go v0.32.0 h1:ug1aK08L3gCHdhknlTTwWjPHPS+/alvLJU/DRxTD/ME=
371-
github.com/testcontainers/testcontainers-go v0.32.0/go.mod h1:CRHrzHLQhlXUsa5gXjTOfqIEJcrK5+xMDmBr/WMI88E=
372-
github.com/testcontainers/testcontainers-go/modules/localstack v0.32.0 h1:FITjE+DSDD136HQho7ThA6cEtUouZzDf7FvMBL2Muog=
373-
github.com/testcontainers/testcontainers-go/modules/localstack v0.32.0/go.mod h1:JasdXHmUT8MTDYfyJza3JjO/k+QA3m8K2GQfnFQM++g=
370+
github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw=
371+
github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8=
372+
github.com/testcontainers/testcontainers-go/modules/localstack v0.33.0 h1:AhbUGUjneEnMyTV5aTsPYzDiAWrba1duPtiV+Z9CKdY=
373+
github.com/testcontainers/testcontainers-go/modules/localstack v0.33.0/go.mod h1:J5vMq1fXXiTfwcJplMClHhn+j8+MbIMv7Lic4d9E8qU=
374374
github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4=
375375
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=
376376
github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4=
@@ -494,8 +494,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
494494
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
495495
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
496496
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
497-
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
498-
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
497+
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
498+
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
499499
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
500500
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
501501
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -549,8 +549,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
549549
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
550550
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
551551
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
552-
k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI=
553-
k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
552+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
553+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
554554
mvdan.cc/sh/v3 v3.8.0 h1:ZxuJipLZwr/HLbASonmXtcvvC9HXY9d2lXZHnKGjFc8=
555555
mvdan.cc/sh/v3 v3.8.0/go.mod h1:w04623xkgBVo7/IUK89E0g8hBykgEpN0vgOj3RJr6MY=
556556
oras.land/oras-go/v2 v2.3.1 h1:lUC6q8RkeRReANEERLfH86iwGn55lbSWP20egdFHVec=

test/docker_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/aquasecurity/trivy/pkg/iac/rego"
1313
"github.com/aquasecurity/trivy/pkg/iac/scan"
1414
"github.com/aquasecurity/trivy/pkg/iac/scanners/dockerfile"
15-
"github.com/aquasecurity/trivy/pkg/iac/scanners/options"
1615
"github.com/liamg/memoryfs"
1716
"github.com/stretchr/testify/assert"
1817
"github.com/stretchr/testify/require"
@@ -76,8 +75,8 @@ func Test_Docker_RegoPoliciesFromDisk(t *testing.T) {
7675
policiesPath, err := filepath.Abs("../checks/docker")
7776
require.NoError(t, err)
7877
scanner := dockerfile.NewScanner(
79-
options.ScannerWithPolicyDirs(filepath.Base(policiesPath)),
80-
options.ScannerWithEmbeddedLibraries(true),
78+
rego.WithPolicyDirs(filepath.Base(policiesPath)),
79+
rego.WithEmbeddedLibraries(true),
8180
)
8281
memfs := memoryfs.New()
8382
// add policies
@@ -126,7 +125,7 @@ func Test_Docker_RegoPoliciesEmbedded(t *testing.T) {
126125
entries, err := os.ReadDir("./testdata/dockerfile")
127126
require.NoError(t, err)
128127

129-
scanner := dockerfile.NewScanner(options.ScannerWithEmbeddedPolicies(true), options.ScannerWithEmbeddedLibraries(true))
128+
scanner := dockerfile.NewScanner(rego.WithEmbeddedPolicies(true), rego.WithEmbeddedLibraries(true))
130129
srcFS := os.DirFS("../")
131130

132131
results, err := scanner.ScanFS(context.TODO(), srcFS, "test/testdata/dockerfile")

test/kubernetes_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"strings"
88
"testing"
99

10+
"github.com/aquasecurity/trivy/pkg/iac/rego"
1011
"github.com/aquasecurity/trivy/pkg/iac/scan"
1112
"github.com/aquasecurity/trivy/pkg/iac/scanners/kubernetes"
12-
"github.com/aquasecurity/trivy/pkg/iac/scanners/options"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
1515
)
@@ -21,9 +21,9 @@ func Test_Kubernetes_RegoPoliciesFromDisk(t *testing.T) {
2121
require.NoError(t, err)
2222

2323
scanner := kubernetes.NewScanner(
24-
options.ScannerWithPerResultTracing(true),
25-
options.ScannerWithEmbeddedPolicies(true),
26-
options.ScannerWithEmbeddedLibraries(true),
24+
rego.WithPerResultTracing(true),
25+
rego.WithEmbeddedPolicies(true),
26+
rego.WithEmbeddedLibraries(true),
2727
)
2828

2929
srcFS := os.DirFS("../")
@@ -81,7 +81,11 @@ func Test_Kubernetes_RegoPoliciesEmbedded(t *testing.T) {
8181
entries, err := os.ReadDir("./testdata/kubernetes")
8282
require.NoError(t, err)
8383

84-
scanner := kubernetes.NewScanner(options.ScannerWithEmbeddedPolicies(true), options.ScannerWithEmbeddedLibraries(true), options.ScannerWithEmbeddedLibraries(true))
84+
scanner := kubernetes.NewScanner(
85+
rego.WithEmbeddedPolicies(true),
86+
rego.WithEmbeddedLibraries(true),
87+
rego.WithEmbeddedLibraries(true),
88+
)
8589

8690
srcFS := os.DirFS("../")
8791

test/rego/rego_checks_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ func TestRegoChecks(t *testing.T) {
3636
regoScanner := rego.NewScanner(
3737
trivyTypes.SourceCloud,
3838
options.ScannerWithFrameworks(framework.CIS_AWS_1_2, framework.CIS_AWS_1_4, framework.Default),
39+
rego.WithPolicyDirs("."),
40+
rego.WithEmbeddedLibraries(true),
3941
)
40-
err := regoScanner.LoadPolicies(true, false, checks.EmbeddedPolicyFileSystem, []string{"."}, nil)
42+
43+
err := regoScanner.LoadPolicies(checks.EmbeddedPolicyFileSystem)
4144
require.NoError(t, err)
4245

4346
missedIDs, _ := lo.Difference(getMigratedChecksIDs(), lo.Keys(tests))

0 commit comments

Comments
 (0)