Reimplementation of the @prefixes statement.

Any added prefixes are now used *after* all input files have been
parsed to look for a prefixed, flattened version of the input file
somewhere in BROPATH and, if found, load it.

For example, if "lcl" is in @prefixes, and site.bro is loaded, then
a file named "lcl.site.bro" that's in BROPATH would end up being
automatically loaded as well.  Packages work similarly, e.g. loading
"protocols/http" means a file named "lcl.protocols.http.bro" in BROPATH
gets loaded automatically.
This commit is contained in:
Jon Siwek 2011-07-14 21:32:02 -05:00
parent e39a49833f
commit d97003892b
6 changed files with 245 additions and 114 deletions

View file

@ -96,9 +96,12 @@ struct ScannedFile {
ino_t inode;
int include_level;
string name;
string subpath; // path in BROPATH's policy/ containing the file
bool skipped; // This ScannedFile was @unload'd
bool prefixes_checked; // if loading prefixes for this file has been tried
ScannedFile(ino_t arg_inode, int arg_include_level, string arg_name)
: inode(arg_inode), include_level(arg_include_level), name(arg_name)
ScannedFile(ino_t arg_inode, int arg_include_level, string arg_name, string arg_subpath = "", bool arg_skipped = false, bool arg_prefixes_checked = false)
: inode(arg_inode), include_level(arg_include_level), name(arg_name), subpath(arg_subpath), skipped(arg_skipped), prefixes_checked(arg_prefixes_checked)
{ }
};