Skip to content

Commit 41fe0b3

Browse files
FedeDPpoiana
authored andcommitted
chore(pkg,cmd): updated urlArchFmt to point to github pages urls.
Moreover, updated driverkit to v0.15.2 and dropped LastRunDistro support. Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent 790d97b commit 41fe0b3

File tree

7 files changed

+22
-73
lines changed

7 files changed

+22
-73
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GO ?= go
22
GORELEASER ?= goreleaser
33
output ?= dbg-go
44
TEST_FLAGS ?= -v -race -tags=test_all
5-
DRIVERKIT_VERSION=v0.15.1
5+
DRIVERKIT_VERSION=v0.15.2
66
LDFLAGS := -X github.com/falcosecurity/driverkit/pkg/driverbuilder/builder.defaultImageTag=${DRIVERKIT_VERSION}
77

88
.PHONY: build

cmd/generate/generate_configs.go

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func NewGenerateConfigsCmd() *cobra.Command {
2727
Short: "Generate new dbg configs",
2828
Long: `In auto mode, configs will be generated starting from kernel-crawler output.
2929
In this scenario, --target-{distro,kernelrelease,kernelversion} are available to filter to-be-generated configs. Regexes are allowed.
30-
Moreover, you can pass special value "load" as target-distro to make the tool automatically fetch latest distro kernel-crawler ran against.
3130
Instead, when auto mode is disabled, the tool is able to generate a single config (for each driver version).
3231
In this scenario, --target-{distro,kernelrelease,kernelversion} CANNOT be regexes but must be exact values.
3332
Also, in non-automatic mode, kernelurls will be retrieved using driverkit libraries.

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/aws/aws-sdk-go-v2/config v1.18.37
88
github.com/aws/aws-sdk-go-v2/credentials v1.13.35
99
github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5
10-
github.com/falcosecurity/driverkit v0.15.1
10+
github.com/falcosecurity/driverkit v0.15.2
1111
github.com/johannesboyne/gofakes3 v0.0.0-20230506070712-04da935ef877
1212
github.com/json-iterator/go v1.1.12
1313
github.com/olekukonko/tablewriter v0.0.5
@@ -115,12 +115,12 @@ require (
115115
github.com/subosito/gotenv v1.6.0 // indirect
116116
github.com/xlab/treeprint v1.2.0 // indirect
117117
go.starlark.net v0.0.0-20230831151029-c9e9adf3fde2 // indirect
118-
golang.org/x/crypto v0.12.0 // indirect
118+
golang.org/x/crypto v0.14.0 // indirect
119119
golang.org/x/mod v0.12.0 // indirect
120-
golang.org/x/net v0.14.0 // indirect
120+
golang.org/x/net v0.17.0 // indirect
121121
golang.org/x/oauth2 v0.11.0 // indirect
122-
golang.org/x/sys v0.12.0 // indirect
123-
golang.org/x/term v0.12.0 // indirect
122+
golang.org/x/sys v0.13.0 // indirect
123+
golang.org/x/term v0.13.0 // indirect
124124
golang.org/x/text v0.13.0 // indirect
125125
golang.org/x/time v0.3.0 // indirect
126126
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect

go.sum

+10
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ github.com/falcosecurity/driverkit v0.15.0 h1:pi4GT+qQU+6kx6w1/yZ3DsPqzXiHFkCs4N
139139
github.com/falcosecurity/driverkit v0.15.0/go.mod h1:RPI15yAVBOELYZ2iJUl3+cOwVBi4o8kWd0AYoBF4xrk=
140140
github.com/falcosecurity/driverkit v0.15.1 h1:wTSrY3QKzOv4oEaJZERWVsNd5tN7hJ8Y+9neGpfKeg4=
141141
github.com/falcosecurity/driverkit v0.15.1/go.mod h1:RPI15yAVBOELYZ2iJUl3+cOwVBi4o8kWd0AYoBF4xrk=
142+
github.com/falcosecurity/driverkit v0.15.2 h1:QDC3PEzpIILTwZA8/bqGZYBXxWRD2ZVVEAtZcDtLLno=
143+
github.com/falcosecurity/driverkit v0.15.2/go.mod h1:RXG4bbofv903PwXKZne3RgnFcVKlyOTioKeWnDt9qBw=
142144
github.com/falcosecurity/falcoctl v0.6.0 h1:+VW6/HJ9mWU2p8apiTQuKRHFsBngfG1s35ao4X2BEfc=
143145
github.com/falcosecurity/falcoctl v0.6.0/go.mod h1:4Hx4h3KtcaQzPKxvYn5S9x4IHxwd6QRK9Gu04HHNbhE=
144146
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
@@ -429,6 +431,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
429431
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
430432
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
431433
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
434+
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
435+
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
432436
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
433437
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
434438
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -505,6 +509,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
505509
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
506510
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
507511
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
512+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
513+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
508514
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
509515
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
510516
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -576,6 +582,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
576582
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
577583
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
578584
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
585+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
586+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
579587
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
580588
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
581589
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -584,6 +592,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
584592
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
585593
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
586594
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
595+
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
596+
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
587597
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
588598
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
589599
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

pkg/generate/constants.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ limitations under the License.
1515
package generate
1616

1717
const (
18-
urlArchFmt = "https://raw.githubusercontent.com/falcosecurity/kernel-crawler/kernels/%s/list.json"
19-
urlLastDistro = "https://raw.githubusercontent.com/falcosecurity/kernel-crawler/kernels/last_run_distro.txt"
18+
urlArchFmt = "https://falcosecurity.github.io/kernel-crawler/%s/list.json"
2019
)

pkg/generate/generate.go

+3-41
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,23 @@ package generate
1717
import (
1818
"errors"
1919
"fmt"
20-
"log/slog"
21-
"os"
22-
"path/filepath"
23-
"strings"
24-
2520
"github.com/falcosecurity/dbg-go/pkg/root"
2621
"github.com/falcosecurity/dbg-go/pkg/validate"
2722
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
2823
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
2924
json "github.com/json-iterator/go"
3025
"golang.org/x/sync/errgroup"
3126
"gopkg.in/yaml.v3"
27+
"log/slog"
28+
"os"
29+
"path/filepath"
3230
)
3331

3432
var (
3533
testJsonData []byte
3634
testCacheData bool
3735
)
3836

39-
func loadLastRunDistro() (string, error) {
40-
lastDistroBytes, err := getURL(urlLastDistro)
41-
if err != nil {
42-
return "", err
43-
}
44-
lastDistro := strings.TrimSuffix(string(lastDistroBytes), "\n")
45-
if lastDistro == "*" {
46-
// Fix up regex (empty regex -> always true)
47-
lastDistro = ""
48-
}
49-
return lastDistro, nil
50-
}
51-
5237
func Run(opts Options) error {
5338
slog.Info("generating config files")
5439
if opts.Auto {
@@ -85,29 +70,6 @@ func autogenerateConfigs(opts Options) error {
8570
testJsonData = jsonData
8671
}
8772

88-
// either download latest distro from kernel-crawler
89-
// or translate the driverkit distro provided by the user to its kernel-crawler naming
90-
if opts.Distro == "load" {
91-
// Fetch last distro kernel-crawler ran against
92-
lastDistro, err := loadLastRunDistro()
93-
if err != nil {
94-
return err
95-
}
96-
slog.Info("loaded last-distro", "distro", lastDistro)
97-
98-
// If lastDistro is empty it means we need to run on all supported distros; this is done automatically.
99-
if lastDistro != "" {
100-
// Map back the kernel crawler distro to our internal driverkit distro
101-
opts.Distro = root.ToDriverkitDistro(root.KernelCrawlerDistro(lastDistro))
102-
if opts.Distro == "" {
103-
return fmt.Errorf("kernel-crawler last run distro '%s' unsupported.\n", lastDistro)
104-
}
105-
} else {
106-
// This will match all supported distros
107-
opts.Distro = ""
108-
}
109-
}
110-
11173
fullJson := map[string][]validate.DriverkitYaml{}
11274

11375
// Unmarshal the big json

pkg/generate/generate_test.go

+2-23
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,6 @@ func TestGenerate(t *testing.T) {
5353
expectError bool
5454
expectedMinConfigs int
5555
}{
56-
"run in auto mode with loaded from kernel-crawler distro on multiple driver versions": {
57-
opts: Options{
58-
Options: root.Options{
59-
RepoRoot: "./test/",
60-
Architecture: "amd64",
61-
DriverVersion: []string{"1.0.0+driver", "2.0.0+driver"},
62-
Target: root.Target{
63-
Distro: "load", // Should load it from lastDistro kernel crawler file
64-
},
65-
DriverName: "falco",
66-
},
67-
Auto: true,
68-
},
69-
expectError: false,
70-
expectedMinConfigs: 1,
71-
},
7256
"run in auto mode with any target distro filter on single driver version": {
7357
opts: Options{
7458
Options: root.Options{
@@ -289,17 +273,12 @@ func TestGenerate(t *testing.T) {
289273
statsOpts.KernelRelease = ""
290274
statsOpts.Distro = ""
291275

292-
stats, err := statter.GetDriverStats(statsOpts)
276+
driverStats, err := statter.GetDriverStats(statsOpts)
293277
assert.NoError(t, err)
294-
assert.GreaterOrEqual(t, len(stats), test.expectedMinConfigs)
278+
assert.GreaterOrEqual(t, len(driverStats), test.expectedMinConfigs)
295279

296280
// Validate all generated files
297281
validateOpts := validate.Options{Options: test.opts.Options}
298-
if validateOpts.Distro == "load" {
299-
// When we load from last kernel-crawler distro,
300-
// force validate all
301-
validateOpts.Distro = ""
302-
}
303282
err = validate.Run(validateOpts)
304283
assert.NoError(t, err)
305284
}

0 commit comments

Comments
 (0)