mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Re-instantiate providing location information to LoadFile
hooks.
#1835 subtly changed the semantics of the `LoadFile` plugin hook to no longer have the current script location available for signature files being loaded through `@load-sigs`. This was undocumented behavior, so it's technically not a regression, but since at least one external plugin is depending on it, this change restores the old behavior.
This commit is contained in:
parent
d29160e9de
commit
fccb9ccab0
8 changed files with 66 additions and 11 deletions
|
@ -266,6 +266,13 @@ bool RuleMatcher::ReadFiles(const std::vector<SignatureFile>& files)
|
|||
if ( ! f.full_path )
|
||||
f.full_path = util::find_file(f.file, util::zeek_path(), ".sig");
|
||||
|
||||
// We mimic previous Zeek versions by temporarily setting the current
|
||||
// script location to the place where the loading happened. This
|
||||
// behavior was never documented, but seems worth not breaking as some
|
||||
// plugins ended up relying on it.
|
||||
Location orig_location = detail::GetCurrentLocation();
|
||||
detail::SetCurrentLocation(f.load_location);
|
||||
|
||||
std::pair<int, std::optional<std::string>> rc = {-1, std::nullopt};
|
||||
rc.first = PLUGIN_HOOK_WITH_RESULT(
|
||||
HOOK_LOAD_FILE, HookLoadFile(zeek::plugin::Plugin::SIGNATURES, f.file, *f.full_path),
|
||||
|
@ -277,6 +284,9 @@ bool RuleMatcher::ReadFiles(const std::vector<SignatureFile>& files)
|
|||
HookLoadFileExtended(zeek::plugin::Plugin::SIGNATURES, f.file, *f.full_path),
|
||||
std::make_pair(-1, std::nullopt));
|
||||
|
||||
// Restore original location information.
|
||||
detail::SetCurrentLocation(orig_location);
|
||||
|
||||
switch ( rc.first )
|
||||
{
|
||||
case -1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue