Canonifying internal order for plugins and their components to make it

deterministic.
This commit is contained in:
Robin Sommer 2013-07-17 17:31:16 -07:00
parent 57b05a2989
commit d8801bb9c4
8 changed files with 41 additions and 17 deletions

@ -1 +1 @@
Subproject commit c2e73c9e1efed6bfdf2d977d716c97773c39492e
Subproject commit b1d4faf23900d4753e93a68abbba45ae3bf96d03

View file

@ -72,7 +72,7 @@ public:
* from what's passed to the constructor but upper-cased and
* canonified to allow being part of a script-level ID.
*/
const char* Name() const { return name; }
virtual const char* Name() const { return name; }
/**
* Returns a canonocalized version of the analyzer's name. The

View file

@ -64,7 +64,7 @@ public:
* from what's passed to the constructor but upper-cased and
* canonified to allow being part of a script-level ID.
*/
const char* Name() const { return name; }
virtual const char* Name() const { return name; }
/**
* Returns a canonocalized version of the analyzer's name. The

View file

@ -45,6 +45,12 @@ public:
*/
component::Type Type() const;
/**
* Returns a descriptive name for the analyzer. This name must be
* unique across all components of the same type.
*/
virtual const char* Name() const = 0;
/**
* Returns a textual representation of the component. The default
* version just output the type. Derived version should call the

View file

@ -30,9 +30,18 @@ bool Manager::LoadPluginsFrom(const std::string& dir)
return false;
}
static bool plugin_cmp(const Plugin* a, const Plugin* b)
{
return a->Name() < b->Name();
}
bool Manager::RegisterPlugin(Plugin *plugin)
{
Manager::PluginsInternal()->push_back(plugin);
// Sort plugins by name to make sure we have a deterministic order.
PluginsInternal()->sort(plugin_cmp);
return true;
}

View file

@ -156,9 +156,18 @@ Plugin::component_list Plugin::Components() const
return components;
}
static bool component_cmp(const Component* a, const Component* b)
{
return a->Name() < b->Name();
}
void Plugin::AddComponent(Component* c)
{
components.push_back(c);
// Sort components by name to make sure we have a deterministic
// order.
components.sort(component_cmp);
}
void Plugin::AddBifInitFunction(bif_init_func c)

View file

@ -3,8 +3,8 @@
#empty_field (empty)
#unset_field -
#path conn
#open 2013-07-08-20-05-18
#open 2013-07-18-00-18-33
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p proto service duration orig_bytes resp_bytes conn_state local_orig missed_bytes history orig_pkts orig_ip_bytes resp_pkts resp_ip_bytes tunnel_parents
#types time string addr port addr port enum string interval count count string bool count string count count count count table[string]
1278600802.069419 UWkUyAuUGXf 10.20.80.1 50343 10.0.0.15 80 tcp - 0.004152 9 3429 SF - 0 ShADadfF 7 381 7 3801 (empty)
#close 2013-07-08-20-05-18
#close 2013-07-18-00-18-33

View file

@ -3,38 +3,38 @@
#empty_field (empty)
#unset_field -
#path packet_filter
#open 2013-07-08-20-05-17
#open 2013-07-18-00-18-33
#fields ts node filter init success
#types time string string bool bool
1373313917.926565 - ip or not ip T T
#close 2013-07-08-20-05-17
1374106713.105591 - ip or not ip T T
#close 2013-07-18-00-18-33
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path packet_filter
#open 2013-07-08-20-05-18
#open 2013-07-18-00-18-33
#fields ts node filter init success
#types time string string bool bool
1373313918.205206 - port 42 T T
#close 2013-07-08-20-05-18
1374106713.385541 - port 42 T T
#close 2013-07-18-00-18-33
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path packet_filter
#open 2013-07-08-20-05-18
#open 2013-07-18-00-18-33
#fields ts node filter init success
#types time string string bool bool
1373313918.491383 - (vlan) and (ip or not ip) T T
#close 2013-07-08-20-05-18
1374106713.664282 - (vlan) and (ip or not ip) T T
#close 2013-07-18-00-18-33
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path packet_filter
#open 2013-07-08-20-05-18
#open 2013-07-18-00-18-33
#fields ts node filter init success
#types time string string bool bool
1373313918.795264 - ((((((((((((udp and port 3544) or (udp and port 514)) or ((tcp and port 2811) or (tcp and port 21))) or (tcp and port 502)) or ((((tcp and port 6669) or (tcp and port 6666)) or (tcp and port 6668)) or (tcp and port 6667))) or (tcp and port 1080)) or ((udp and port 2152) or (udp and port 2123))) or ((((((((tcp and port 631) or (tcp and port 8888)) or (tcp and port 3128)) or (tcp and port 80)) or (tcp and port 1080)) or (tcp and port 8000)) or (tcp and port 81)) or (tcp and port 8080))) or (udp and port 5072)) or ((tcp and port 25) or (tcp and port 587))) or (((((((((((tcp and port 5223) or (tcp and port 585)) or (tcp and port 614)) or (tcp and port 993)) or (tcp and port 636)) or (tcp and port 989)) or (tcp and port 995)) or (tcp and port 443)) or (tcp and port 563)) or (tcp and port 990)) or (tcp and port 992))) or (((((udp and port 5355) or (tcp and port 53)) or (udp and port 5353)) or (udp and port 137)) or (udp and port 53))) or (tcp and port 22) T T
#close 2013-07-08-20-05-18
1374106713.957005 - ((((((((((((((((((((((tcp and port 5223) or (tcp and port 585)) or (tcp and port 614)) or (tcp and port 993)) or (tcp and port 636)) or (tcp and port 989)) or (tcp and port 995)) or (tcp and port 443)) or (tcp and port 563)) or (tcp and port 990)) or (tcp and port 992)) or ((tcp and port 2811) or (tcp and port 21))) or ((((tcp and port 6669) or (tcp and port 6666)) or (tcp and port 6668)) or (tcp and port 6667))) or ((udp and port 2152) or (udp and port 2123))) or (tcp and port 22)) or (tcp and port 1080)) or ((((((((tcp and port 631) or (tcp and port 8888)) or (tcp and port 3128)) or (tcp and port 80)) or (tcp and port 1080)) or (tcp and port 8000)) or (tcp and port 81)) or (tcp and port 8080))) or (udp and port 5072)) or ((tcp and port 25) or (tcp and port 587))) or (tcp and port 502)) or (udp and port 514)) or (((((udp and port 5355) or (tcp and port 53)) or (udp and port 5353)) or (udp and port 137)) or (udp and port 53))) or (udp and port 3544) T T
#close 2013-07-18-00-18-33