mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-25 20:30:47 +00:00
refacotr(configuration): enhance readability of get_driver_mode
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
This commit is contained in:
@@ -108,24 +108,23 @@ void falco_configuration::init(const std::string& conf_filename, const std::vect
|
|||||||
|
|
||||||
static driver_mode_type get_driver_mode(const std::string& input){
|
static driver_mode_type get_driver_mode(const std::string& input){
|
||||||
// Set driver mode if not already set.
|
// Set driver mode if not already set.
|
||||||
if( input == "bpf" )
|
const std::unordered_map<std::string, driver_mode_type> driver_mode_lut = {
|
||||||
{
|
{"kmod",driver_mode_type::KMOD},
|
||||||
return driver_mode_type::BPF;
|
{"bpf",driver_mode_type::BPF},
|
||||||
|
{"modern_bpf",driver_mode_type::MODERN_BPF},
|
||||||
|
{"custom",driver_mode_type::CUSTOM},
|
||||||
|
};
|
||||||
|
|
||||||
|
if(driver_mode_lut.find(input) != driver_mode_lut.end()) {
|
||||||
|
return driver_mode_lut.at(input);
|
||||||
|
} else {
|
||||||
|
return driver_mode_type::KMOD;
|
||||||
}
|
}
|
||||||
else if( input == "modern_bpf" )
|
|
||||||
{
|
|
||||||
return driver_mode_type::MODERN_BPF;
|
|
||||||
}
|
|
||||||
else if( input == "custom" )
|
|
||||||
{
|
|
||||||
return driver_mode_type::CUSTOM;
|
|
||||||
}
|
|
||||||
return driver_mode_type::KMOD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void falco_configuration::load_yaml(const std::string& config_name, const yaml_helper& config)
|
void falco_configuration::load_yaml(const std::string& config_name, const yaml_helper& config)
|
||||||
{
|
{
|
||||||
m_driver_mode = get_driver_mode(config.get_scalar<string>("driver_mode", ""));
|
m_driver_mode = get_driver_mode(config.get_scalar<std::string>("driver_mode", ""));
|
||||||
|
|
||||||
std::list<std::string> rules_files;
|
std::list<std::string> rules_files;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user