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; 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"