From 9fc2272ca5d48670fd7a4204069cc74265d1ae38 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Thu, 19 Sep 2024 14:40:20 +0000 Subject: [PATCH 1/2] fix(falco): allow plugin init_config map in json schema Signed-off-by: Luca Guerra --- userspace/falco/config_json_schema.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/userspace/falco/config_json_schema.h b/userspace/falco/config_json_schema.h index a9dd6f8871b..ba6419e72b3 100644 --- a/userspace/falco/config_json_schema.h +++ b/userspace/falco/config_json_schema.h @@ -587,7 +587,14 @@ const char config_schema_string[] = LONG_STRING_CONST( "type": "string" }, "init_config": { - "type": "string" + "anyOf": [ + { + "type": "object" + }, + { + "type": "string" + } + ] }, "open_params": { "type": "string" From 391741f8845a1b061d9048743b6959a2477c2c33 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Thu, 19 Sep 2024 14:40:43 +0000 Subject: [PATCH 2/2] update(tests): add test for plugin init_config map Signed-off-by: Luca Guerra --- .../falco/test_configuration_schema.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/unit_tests/falco/test_configuration_schema.cpp b/unit_tests/falco/test_configuration_schema.cpp index 9a740fd7e0e..ebb133613c8 100644 --- a/unit_tests/falco/test_configuration_schema.cpp +++ b/unit_tests/falco/test_configuration_schema.cpp @@ -97,6 +97,34 @@ TEST(Configuration, schema_wrong_embedded_key) EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_failed); } +TEST(Configuration, plugin_init_config) +{ + falco_configuration falco_config; + config_loaded_res res; + + std::string config = R"( +plugins: + - name: k8saudit + library_path: libk8saudit.so + init_config: + maxEventSize: 262144 + sslCertificate: /etc/falco/falco.pem +)"; + + EXPECT_NO_THROW(res = falco_config.init_from_content(config, {})); + EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_ok); + + config = R"( +plugins: + - name: k8saudit + library_path: libk8saudit.so + init_config: '{"maxEventSize": 262144, "sslCertificate": "/etc/falco/falco.pem"}' +)"; + + EXPECT_NO_THROW(res = falco_config.init_from_content(config, {})); + EXPECT_VALIDATION_STATUS(res, yaml_helper::validation_ok); +} + TEST(Configuration, schema_yaml_helper_validator) { yaml_helper conf;