mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-16 14:58:31 +00:00
fix(userspace/falco): init cmdline options after loading all config files.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
committed by
poiana
parent
7c8bdf0c9e
commit
252eb5cd40
@@ -133,12 +133,20 @@ config_loaded_res falco_configuration::init_from_file(
|
||||
std::cerr << "Cannot read config file (" + conf_filename + "): " + e.what() + "\n";
|
||||
throw e;
|
||||
}
|
||||
init_cmdline_options(cmdline_options);
|
||||
|
||||
// Only report top most schema validation status
|
||||
res[conf_filename] = validation_status[0];
|
||||
|
||||
// Load any `-o config_files=foo.yaml` cmdline additional option
|
||||
load_cmdline_config_files(cmdline_options);
|
||||
|
||||
// Merge all config files (both from main falco.yaml and `-o config_files=foo.yaml`)
|
||||
merge_config_files(conf_filename, res);
|
||||
|
||||
// Load all other `-o` cmdline options to override any config key
|
||||
init_cmdline_options(cmdline_options);
|
||||
|
||||
// Finally load the parsed config to our structure
|
||||
load_yaml(conf_filename);
|
||||
|
||||
return res;
|
||||
@@ -766,6 +774,16 @@ static bool split(const std::string &str, char delim, std::pair<std::string, std
|
||||
return true;
|
||||
}
|
||||
|
||||
void falco_configuration::load_cmdline_config_files(
|
||||
const std::vector<std::string> &cmdline_options) {
|
||||
for(const std::string &option : cmdline_options) {
|
||||
// Set all config_files options
|
||||
if(option.rfind(yaml_helper::configs_key, 0) == 0) {
|
||||
set_cmdline_option(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void falco_configuration::init_cmdline_options(const std::vector<std::string> &cmdline_options) {
|
||||
for(const std::string &option : cmdline_options) {
|
||||
set_cmdline_option(option);
|
||||
|
@@ -221,6 +221,8 @@ private:
|
||||
void init_logger();
|
||||
void load_engine_config(const std::string& config_name);
|
||||
void init_cmdline_options(const std::vector<std::string>& cmdline_options);
|
||||
void load_cmdline_config_files(const std::vector<std::string>& cmdline_options);
|
||||
|
||||
/**
|
||||
* Given a <key>=<value> specifier, set the appropriate option
|
||||
* in the underlying yaml config. <key> can contain '.'
|
||||
|
Reference in New Issue
Block a user