mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-08 18:19:30 +00:00
cleanup(rule_loader): add a common log message
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
This commit is contained in:
@@ -283,7 +283,7 @@ TEST_F(engine_loader_test, rule_incorrect_append_override)
|
||||
std::string rule_name = "failing_rule";
|
||||
|
||||
ASSERT_FALSE(load_rules(rules_content, "rules.yaml"));
|
||||
ASSERT_TRUE(std::string(m_load_result_json["errors"][0]["message"]).find("'override' and 'append: true' cannot be used together") != std::string::npos);
|
||||
ASSERT_TRUE(std::string(m_load_result_json["errors"][0]["message"]).find(OVERRIDE_APPEND_ERROR_MESSAGE) != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(engine_loader_test, rule_override_without_rule)
|
||||
|
@@ -448,7 +448,7 @@ static void read_item(
|
||||
|
||||
if(append == true && has_overrides)
|
||||
{
|
||||
THROW(true, "Keys 'override' and 'append: true' cannot be used together.", ctx);
|
||||
THROW(true, OVERRIDE_APPEND_ERROR_MESSAGE, ctx);
|
||||
}
|
||||
|
||||
// Since a list only has items, if we have chosen to append them we can append the entire object
|
||||
@@ -490,7 +490,7 @@ static void read_item(
|
||||
|
||||
if(append == true && has_overrides)
|
||||
{
|
||||
THROW(true, "Keys 'override' and 'append: true' cannot be used together.", ctx);
|
||||
THROW(true, OVERRIDE_APPEND_ERROR_MESSAGE, ctx);
|
||||
}
|
||||
|
||||
// Since a macro only has a condition, if we have chosen to append to it we can append the entire object
|
||||
@@ -528,8 +528,7 @@ static void read_item(
|
||||
bool has_overrides_replace = !override_replace.empty();
|
||||
bool has_overrides = has_overrides_append || has_overrides_replace;
|
||||
|
||||
THROW((has_append_flag && has_overrides),
|
||||
"Keys 'override' and 'append: true' cannot be used together. Add an append entry (e.g. 'condition: append') under override instead.", ctx);
|
||||
THROW((has_append_flag && has_overrides), OVERRIDE_APPEND_ERROR_MESSAGE, ctx);
|
||||
|
||||
if(has_overrides)
|
||||
{
|
||||
|
@@ -23,6 +23,9 @@ limitations under the License.
|
||||
#include "version.h"
|
||||
#include "falco_engine_version.h"
|
||||
|
||||
// Error message used when both 'override' and 'append' are specified.
|
||||
#define OVERRIDE_APPEND_ERROR_MESSAGE "Keys 'override' and 'append: true' cannot be used together. Add an append entry (e.g. 'condition: append') under override instead."
|
||||
|
||||
namespace rule_loader
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user