zeek/scripts/policy/misc/loaded-scripts.bro
Jon Siwek 186e67ec1d Allow logging filters to inherit default path from stream.
This allows the path for the default filter to be specified explicitly
when creating a stream and reduces the need to rely on the default path
function to magically supply the path.

The default path function is now only used if, when a filter is added to
a stream, it has neither a path nor a path function already.

Adapted the existing Log::create_stream calls to explicitly specify a
path value.

Addresses BIT-1324
2015-03-19 14:49:55 -05:00

39 lines
879 B
Text

##! Log the loaded scripts.
@load base/utils/paths
module LoadedScripts;
export {
redef enum Log::ID += { LOG };
type Info: record {
## Name of the script loaded potentially with spaces included
## before the file name to indicate load depth. The convention
## is two spaces per level of depth.
name: string &log;
};
}
const depth: table[count] of string = {
[0] = "",
[1] = " ",
[2] = " ",
[3] = " ",
[4] = " ",
[5] = " ",
[6] = " ",
[7] = " ",
[8] = " ",
[9] = " ",
[10] = " ",
};
event bro_init() &priority=5
{
Log::create_stream(LoadedScripts::LOG, [$columns=Info, $path="loaded_scripts"]);
}
event bro_script_loaded(path: string, level: count)
{
Log::write(LoadedScripts::LOG, [$name=cat(depth[level], compress_path(path))]);
}