mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-30 21:25:06 +00:00
chore(userspace/falco): print a warn message if -o includes=
is passed to cmdline.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
parent
45754fda9f
commit
1deafee5f7
@ -605,5 +605,12 @@ void falco_configuration::set_cmdline_option(yaml_helper& config, const std::str
|
||||
throw std::logic_error("Error parsing config option \"" + opt + "\". Must be of the form key=val or key.subkey=val");
|
||||
}
|
||||
|
||||
config.set_scalar(keyval.first, keyval.second);
|
||||
if (keyval.first.rfind(yaml_helper::includes_key, 0) == 0)
|
||||
{
|
||||
falco_logger::log(falco_logger::level::WARNING, "Ignoring '-o " + yaml_helper::includes_key + "' directive: cannot be overridden by cmdline.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
config.set_scalar(keyval.first, keyval.second);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ private:
|
||||
class yaml_helper
|
||||
{
|
||||
public:
|
||||
inline static const std::string includes_key = "includes";
|
||||
|
||||
/**
|
||||
* Load the YAML document represented by the input string.
|
||||
*/
|
||||
@ -98,7 +100,7 @@ public:
|
||||
const auto config_folder = ppath.parent_path();
|
||||
// Parse files to be included
|
||||
std::vector<std::string> include_files;
|
||||
get_sequence<std::vector<std::string>>(include_files, "includes");
|
||||
get_sequence<std::vector<std::string>>(include_files, includes_key);
|
||||
for(const std::string& include_file : include_files)
|
||||
{
|
||||
// If user specifies a relative include file,
|
||||
@ -111,7 +113,8 @@ public:
|
||||
}
|
||||
if (include_file_path == ppath)
|
||||
{
|
||||
throw std::runtime_error("Config error: 'includes' directive tried to recursively include main config file: " + path + ".");
|
||||
throw std::runtime_error(
|
||||
"Config error: '" + includes_key + "' directive tried to recursively include main config file: " + path + ".");
|
||||
}
|
||||
if (std::filesystem::exists(include_file_path) && std::filesystem::is_regular_file(include_file_path))
|
||||
{
|
||||
@ -124,9 +127,10 @@ public:
|
||||
* (that use load_from_file_int recursively).
|
||||
*/
|
||||
const auto &key = n.first.Scalar();
|
||||
if (key == "includes")
|
||||
if (key == includes_key)
|
||||
{
|
||||
throw std::runtime_error("Config error: 'includes' directive in included config file " + include_file + ".");
|
||||
throw std::runtime_error(
|
||||
"Config error: '" + includes_key + "' directive in included config file " + include_file + ".");
|
||||
}
|
||||
// We allow to override keys.
|
||||
// We don't need to use `get_node()` here,
|
||||
|
Loading…
Reference in New Issue
Block a user