Skip to content

Commit

Permalink
[CWS] make disableBundledRules a dynamic test opts (#27276)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux authored Jul 3, 2024
1 parent 51437cf commit 00e95ee
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/security/tests/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestFilterOpenBasenameApprover(t *testing.T) {
Expression: fmt.Sprintf(`open.file.path == "{{.Root}}/%s"`, basename),
}

test, err := newTestModule(t, nil, []*rules.RuleDefinition{rule}, withStaticOpts(testOpts{disableBundledRules: true}))
test, err := newTestModule(t, nil, []*rules.RuleDefinition{rule}, withDynamicOpts(dynamicTestOpts{disableBundledRules: true}))
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/tests/module_tester_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func newTestModule(t testing.TB, macroDefs []*rules.MacroDefinition, ruleDefs []
return nil, err
}

if opts.staticOpts.disableBundledRules {
if opts.dynamicOpts.disableBundledRules {
ruleDefs = append(ruleDefs, &rules.RuleDefinition{
ID: events.NeedRefreshSBOMRuleID,
Disabled: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/tests/open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func TestOpenApproverZero(t *testing.T) {
Expression: `open.flags == 0 && process.file.name == "testsuite"`,
}

test, err := newTestModule(t, nil, []*rules.RuleDefinition{rule}, withStaticOpts(testOpts{disableBundledRules: true}))
test, err := newTestModule(t, nil, []*rules.RuleDefinition{rule}, withDynamicOpts(dynamicTestOpts{disableBundledRules: true}))
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/tests/testopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ type testOpts struct {
snapshotRuleMatchHandler func(*testModule, *model.Event, *rules.Rule)
enableFIM bool // only valid on windows
networkIngressEnabled bool
disableBundledRules bool
}

type dynamicTestOpts struct {
testDir string
disableAbnormalPathCheck bool
disableBundledRules bool
}

type tmOpts struct {
Expand Down

0 comments on commit 00e95ee

Please sign in to comment.