{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
+static const Parameter action_map_params[] =
+{
+ { "replace" , Parameter::PT_STRING, nullptr, nullptr,
+ "action you want to change" },
+
+ { "with" , Parameter::PT_STRING, nullptr, nullptr,
+ "action you want to use instead" },
+
+ { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
+};
+
static const Parameter ips_params[] =
{
+ { "action_map", Parameter::PT_LIST, action_map_params, nullptr,
+ "change actions like block to alert (applied after action_override)" },
+
+ { "action_override", Parameter::PT_STRING, nullptr, nullptr,
+ "use this action for all rules (applied before action_map)" },
+
{ "default_rule_state", Parameter::PT_ENUM, "no | yes | inherit", "inherit",
"enable or disable ips rules" },
public:
IpsModule() : Module("ips", ips_help, ips_params) { }
bool set(const char*, Value&, SnortConfig*) override;
+ bool end(const char*, int, SnortConfig*) override;
bool matches(const char*, std::string&) override;
Usage get_usage() const override
{ return DETECT; }
+
+private:
+ std::string replace;
+ std::string with;
};
bool IpsModule::matches(const char*, std::string&)
{
IpsPolicy* p = get_ips_policy();
- if ( v.is("default_rule_state") )
+ if ( v.is("action_override") )
+ p->action_override = v.get_string();
+
+ else if ( v.is("default_rule_state") )
p->default_rule_state = (IpsPolicy::Enable)v.get_uint8();
else if ( v.is("enable_builtin_rules") )
else if ( v.is("obfuscate_pii") )
p->obfuscate_pii = v.get_bool();
+ else if ( v.is("replace") )
+ replace = v.get_string();
+
else if ( v.is("rules") )
p->rules += v.get_string();
else if ( strstr(fqn, "variables.ports.") )
ParsePortVar(get_var_name(fqn), v.get_string());
+ else if ( v.is("with") )
+ with = v.get_string();
+
else
return false;
return true;
}
+bool IpsModule::end(const char* fqn, int idx, SnortConfig*)
+{
+ if ( idx and !strcmp(fqn, "ips.action_map") )
+ {
+ if ( replace.empty() or with.empty() )
+ {
+ ParseError("%s - must set both replace and with", fqn);
+ return false;
+ }
+
+ IpsPolicy* p = get_ips_policy();
+ p->action_map[replace] = with;
+
+ replace.clear();
+ with.clear();
+ }
+ return true;
+}
+
//-------------------------------------------------------------------------
// process module
//-------------------------------------------------------------------------