From 34bace2c8ed917716b8b77fb5a370ec7d9ce8236 Mon Sep 17 00:00:00 2001
From: Federico Di Pierro <nierro92@gmail.com>
Date: Thu, 5 Sep 2024 08:58:40 +0200
Subject: [PATCH] new(pkg/falco): port rule disable,enable tags to newly
 introduced in Falco 0.38 `rule:` config.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
---
 pkg/falco/tester_options.go | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/pkg/falco/tester_options.go b/pkg/falco/tester_options.go
index ff92f84..e994ee6 100644
--- a/pkg/falco/tester_options.go
+++ b/pkg/falco/tester_options.go
@@ -61,17 +61,30 @@ func WithConfig(f run.FileAccessor) TestOption {
 
 // WithEnabledTags runs Falco with enabled rules tags through the `-t` option.
 func WithEnabledTags(tags ...string) TestOption {
-	return withMultipleArgValues("-t", tags...)
+	return func(o *testOptions) {
+		o.args = append(o.args, "-o", "rules[].disable.rule=*")
+		for _, t := range tags {
+			o.args = append(o.args, "-o", "rules[].enable.tag="+t)
+		}
+	}
 }
 
 // WithDisabledTags runs Falco with disabled rules tags through the `-T` option.
 func WithDisabledTags(tags ...string) TestOption {
-	return withMultipleArgValues("-T", tags...)
+	return func(o *testOptions) {
+		for _, t := range tags {
+			o.args = append(o.args, "-o", "rules[].disable.tag="+t)
+		}
+	}
 }
 
-// WithDisabledRules runs Falco with disabled rules through the `-D` option.
+// WithDisabledRules runs Falco with disabled rules through the `rules:` config option.
 func WithDisabledRules(rules ...string) TestOption {
-	return withMultipleArgValues("-D", rules...)
+	return func(o *testOptions) {
+		for _, r := range rules {
+			o.args = append(o.args, "-o", "rules[].disable.rule="+r)
+		}
+	}
 }
 
 // WithEnabledSources runs Falco with enabled event sources through the `--enable-source` option.