* *bit_list*: a list of consecutive integer values from 1 to the range
maximum
* *bool*: true or false
+* *dynamic*: a select type determined by loaded plugins
* *enum*: a string selected from the given range
* *implied*: an IPS rule option that takes no value but means true
* *int*: a whole number in the given range
return valid_multi(v, (const char*)range);
case PT_ENUM:
return valid_enum(v, (const char*)range);
+ case PT_DYNAMIC:
+ return valid_select(v, ((RangeQuery)range)());
// address values
case PT_MAC:
static const char* const pt2str[Parameter::PT_MAX] =
{
- "table", "list",
+ "table", "list", "dynamic",
"bool", "int", "real", "port",
"string", "select", "multi", "enum",
"mac", "ip4", "addr",
return pt2str[type];
}
+const char* Parameter::get_range() const
+{
+ switch ( type )
+ {
+ case PT_TABLE:
+ case PT_LIST:
+ return nullptr;
+
+ case PT_DYNAMIC:
+ return ((RangeQuery)range)();
+
+ default:
+ break;
+ }
+ return (char*)range;
+}
+
bool Parameter::get_bool() const
{
if ( !deflt )
struct SO_PUBLIC Parameter
{
+ typedef const char* (*RangeQuery)();
+
enum Type
{
PT_TABLE, // range is Parameter*, no default
PT_LIST, // range is Parameter*, no default
+ PT_DYNAMIC, // range is RangeQuery function ptr
PT_BOOL, // if you are reading this, get more coffee
PT_INT, // signed 64 bits or less determined by range
PT_REAL, // double
};
const char* name;
Type type;
- const void* range; // nullptr|const char*|const Parameter*
+ const void* range; // nullptr|const char*|RangeQuery|const Parameter*
const char* deflt;
const char* help;
const char* get_type() const;
+ const char* get_range() const;
bool validate(class Value&) const;
bool is_quoted() const
{ return ( type > PT_PORT ); }
- bool has_text_range() const
- { return !is_table() and range != nullptr; }
-
bool get_bool() const;
double get_number() const;
const char* get_string() const;
cout << " " << Markup::escape(p->help);
- if ( p->has_text_range() )
+ if ( const char* r = p->get_range() )
{
- if ( *((char*)p->range) == '(' )
- cout << " " << (char*)p->range;
+ if ( *r == '(' )
+ cout << " " << r;
else
- cout << " (" << (char*)p->range << ")";
+ cout << " (" << r << ")";
}
cout << endl;
}
#include "framework/module.h"
#include "managers/module_manager.h"
+#include "managers/plugin_manager.h"
#include "main.h"
#include "main/snort.h"
#include "main/snort_config.h"
// search engine module
//-------------------------------------------------------------------------
-// FIXIT-L valid search methods should be obtained from available mpse plugins
-#define SEARCH_METHODS \
- "ac_banded | ac_bnfa | ac_bnfa_q | ac_full | ac_full_q | " \
- "ac_sparse | ac_sparse_bands | ac_std"
+static const char* get_search_methods()
+{ return PluginManager::get_available_plugins(PT_SEARCH_ENGINE); }
static const Parameter search_engine_params[] =
{
{ "inspect_stream_inserts", Parameter::PT_BOOL, nullptr, "false",
"inspect reassembled payload - disabling is good for performance, bad for detection" },
- { "search_method", Parameter::PT_SELECT, SEARCH_METHODS, "ac_bnfa_q",
+ { "search_method", Parameter::PT_DYNAMIC, (void*)get_search_methods, "ac_bnfa_q",
"set fast pattern algorithm - choose available search engine" },
{ "split_any_any", Parameter::PT_BOOL, nullptr, "false",
#include "help.h"
#include "shell.h"
#include "detection/detect.h"
+#include "framework/base_api.h"
#include "framework/module.h"
#include "framework/parameter.h"
#include "managers/module_manager.h"
+#include "managers/plugin_manager.h"
#include "parser/config_file.h"
#include "parser/parser.h"
#include "parser/parse_utils.h"
// help as well.
//-------------------------------------------------------------------------
+static const char* get_alert_mode()
+{ return PluginManager::get_available_plugins(PT_LOGGER); }
+
static const Parameter s_params[] =
{
{ "-?", Parameter::PT_STRING, "(optional)", nullptr,
"<option prefix> output matching command line option quick help (same as --help-options)" },
- { "-A", Parameter::PT_STRING, nullptr, nullptr,
+ { "-A", Parameter::PT_DYNAMIC, (void*)get_alert_mode, nullptr,
"<mode> set alert mode: none, cmg, or alert_*" },
{ "-B", Parameter::PT_IMPLIED, nullptr, nullptr,
cout << " " << Markup::emphasis(Markup::escape(key));
if ( p->deflt )
- cout << " = " << Markup::escape((char*)p->deflt);
+ cout << " = " << Markup::escape(p->deflt);
cout << ": " << p->help;
- if ( p->range )
- cout << " { " << Markup::escape((char*)p->range) << " }";
+ if ( const char* r = p->get_range() )
+ cout << " { " << Markup::escape(r) << " }";
cout << endl;
}
cout << "\t" << Markup::emphasis(Markup::escape(key));
if ( p->deflt )
- cout << "\t" << Markup::escape((char*)p->deflt);
+ cout << "\t" << Markup::escape(p->deflt);
else
cout << "\t";
cout << "\t" << p->help;
- if ( p->range )
- cout << "\t" << Markup::escape((char*)p->range);
+ if ( const char* r = p->get_range() )
+ cout << "\t" << Markup::escape(r);
else
cout << "\t";
assert(false);
}
+const char* PluginManager::get_available_plugins(PlugType t)
+{
+ static std::string s;
+ s.clear();
+
+ for ( auto it = plug_map.begin(); it != plug_map.end(); ++it )
+ {
+ const auto* api = it->second.api;
+
+ if ( t != api->type )
+ continue;
+
+ if ( !s.empty() )
+ s += " | ";
+
+ s += api->name;
+ }
+ return s.c_str();
+}
+
static void instantiate(const BaseApi*, Module*, SnortConfig*);
static void instantiate(const BaseApi*, Module*, SnortConfig*, const char* name);
+
+ static const char* get_available_plugins(PlugType);
};
#endif