Enabling to specific a set of plugins with the -N option.

Bro will then print information only about the plugins specified.
This commit is contained in:
Robin Sommer 2014-06-18 13:19:04 -07:00
parent 58fbee5701
commit 55de5c60f4
2 changed files with 27 additions and 14 deletions

2
cmake

@ -1 +1 @@
Subproject commit 7fcf13fff1f2a5c08fba2821f848ab490032d617
Subproject commit 39bb3cd8b4ce49b3fea2e0e12919d2385e870065

View file

@ -116,6 +116,7 @@ SecondaryPath* secondary_path = 0;
extern char version[];
char* command_line_policy = 0;
vector<string> params;
set<string> requested_plugins;
char* proc_status_file = 0;
int snaplen = 0; // this gets set from the scripting-layer's value
@ -250,14 +251,14 @@ void usage()
exit(1);
}
void show_plugins(int level)
bool show_plugins(int level)
{
plugin::Manager::plugin_list plugins = plugin_mgr->ActivePlugins();
if ( ! plugins.size() )
{
printf("No plugins registered, not even any built-ins. This is probably a bug.\n");
return;
return false;
}
ODesc d;
@ -265,29 +266,39 @@ void show_plugins(int level)
if ( level == 1 )
d.SetShort();
int count = 0;
for ( plugin::Manager::plugin_list::const_iterator i = plugins.begin(); i != plugins.end(); i++ )
{
if ( requested_plugins.size()
&& requested_plugins.find((*i)->Name()) == requested_plugins.end() )
continue;
(*i)->Describe(&d);
if ( ! d.IsShort() )
d.Add("\n");
++count;
}
printf("%s", d.Description());
plugin::Manager::inactive_plugin_list inactives = plugin_mgr->InactivePlugins();
if ( ! inactives.size() )
return;
printf("\nInactive dynamic plugins:\n");
for ( plugin::Manager::inactive_plugin_list::const_iterator i = inactives.begin(); i != inactives.end(); i++ )
if ( inactives.size() && ! requested_plugins.size() )
{
string name = (*i).first;
string path = (*i).second;
printf(" %s (%s)\n", name.c_str(), path.c_str());
printf("\nInactive dynamic plugins:\n");
for ( plugin::Manager::inactive_plugin_list::const_iterator i = inactives.begin(); i != inactives.end(); i++ )
{
string name = (*i).first;
string path = (*i).second;
printf(" %s (%s)\n", name.c_str(), path.c_str());
}
}
return count != 0;
}
void done_with_network()
@ -851,6 +862,8 @@ int main(int argc, char** argv)
{
if ( strchr(argv[optind], '=') )
params.push_back(argv[optind++]);
else if ( print_plugins && strstr(argv[optind], "::") )
requested_plugins.insert(argv[optind++]);
else
add_input_file(argv[optind++]);
}
@ -921,8 +934,8 @@ int main(int argc, char** argv)
if ( print_plugins )
{
show_plugins(print_plugins);
exit(1);
bool success = show_plugins(print_plugins);
exit(success ? 0 : 1);
}
analyzer_mgr->InitPostScript();