mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00

The new hooks works similar to the existing `HookLoadFile` but, additionally, allows the plugin to return a string that contains the code to be used for the file being loaded. If the plugin does so, the content of any actual file on disk will be ignored (in fact, there doesn't even need to be a file on disk in that case). This works for both Zeek scripts and signatures. There's a new test that covers the new functionality, testing loading both scripts and signatures from memory. I also manually tested that the debugger integration works, but I don't see much of a way to add a regression test for that part. We keep the existing hook as well for backwards compatibility. We could decide to deprecate it, but not sure that buys us much, so left that out. Closes #1757.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#pragma once
|
|
|
|
// Functions for displaying the contents of policy files.
|
|
// Mostly useful for debugging code that wants to show context.
|
|
//
|
|
// Summary:
|
|
// All files that are going to be accessed should be passed to LoadFile
|
|
// (probably in the lexer). Then later any function that so desires
|
|
// can call a relevant function. Note that since it caches the contents,
|
|
// changes to the policy files will not be reflected until restart,
|
|
// which is probably good since it'll always display the code that Bro
|
|
// is actually using.
|
|
|
|
// policy_filename arguments should be absolute or relative paths;
|
|
// no expansion is done.
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace zeek::detail
|
|
{
|
|
|
|
int how_many_lines_in(const char* policy_filename);
|
|
|
|
bool LoadPolicyFileText(const char* policy_filename,
|
|
const std::optional<std::string>& preloaded_content = {});
|
|
|
|
// start_line is 1-based (the intuitive way)
|
|
bool PrintLines(const char* policy_filename, unsigned int start_line, unsigned int how_many_lines,
|
|
bool show_numbers);
|
|
|
|
} // namespace zeek::detail
|