diff --git a/userspace/engine/falco_engine.h b/userspace/engine/falco_engine.h index 051f0b65..de7da082 100644 --- a/userspace/engine/falco_engine.h +++ b/userspace/engine/falco_engine.h @@ -77,6 +77,7 @@ public: // // Enable/Disable any rules matching the provided substring. + // If the substring is "", all rules are enabled/disabled. // When provided, enable/disable these rules in the // context of the provided ruleset. The ruleset (id) can later // be passed as an argument to process_event(). This allows diff --git a/userspace/engine/ruleset.cpp b/userspace/engine/ruleset.cpp index 47d593c3..57ed0ef0 100644 --- a/userspace/engine/ruleset.cpp +++ b/userspace/engine/ruleset.cpp @@ -213,7 +213,7 @@ void falco_ruleset::enable(const string &substring, bool enabled, uint16_t rules { bool matches; - matches = (val.first.find(substring) != string::npos); + matches = (substring == "" || (val.first.find(substring) != string::npos)); if (matches) { diff --git a/userspace/falco/falco.cpp b/userspace/falco/falco.cpp index 715a9aba..9c30a4ba 100644 --- a/userspace/falco/falco.cpp +++ b/userspace/falco/falco.cpp @@ -87,7 +87,7 @@ static void usage() " --cri Path to CRI socket for container metadata\n" " Use the specified socket to fetch data from a CRI-compatible runtime\n" " -d, --daemon Run as a daemon\n" - " -D Disable any rules matching the regex . Can be specified multiple times.\n" + " -D Disable any rules with names having the substring . Can be specified multiple times.\n" " Can not be specified with -t.\n" " -e Read the events from (in .scap format for sinsp events, or jsonl for\n" " k8s audit events) instead of tapping into live.\n" @@ -471,9 +471,9 @@ int falco_init(int argc, char **argv) try { - set disabled_rule_patterns; - string pattern; - string all_rules = ".*"; + set disabled_rule_substrings; + string substring; + string all_rules = ""; set disabled_rule_tags; set enabled_rule_tags; @@ -502,8 +502,8 @@ int falco_init(int argc, char **argv) daemon = true; break; case 'D': - pattern = optarg; - disabled_rule_patterns.insert(pattern); + substring = optarg; + disabled_rule_substrings.insert(substring); break; case 'e': trace_filename = optarg; @@ -781,15 +781,15 @@ int falco_init(int argc, char **argv) } // You can't both disable and enable rules - if((disabled_rule_patterns.size() + disabled_rule_tags.size() > 0) && + if((disabled_rule_substrings.size() + disabled_rule_tags.size() > 0) && enabled_rule_tags.size() > 0) { throw std::invalid_argument("You can not specify both disabled (-D/-T) and enabled (-t) rules"); } - for (auto pattern : disabled_rule_patterns) + for (auto substring : disabled_rule_substrings) { - falco_logger::log(LOG_INFO, "Disabling rules matching pattern: " + pattern + "\n"); - engine->enable_rule(pattern, false); + falco_logger::log(LOG_INFO, "Disabling rules matching substring: " + substring + "\n"); + engine->enable_rule(substring, false); } if(disabled_rule_tags.size() > 0)