Merge remote-tracking branch 'origin/topic/awelzel/find-in-zeekpath'

* origin/topic/awelzel/find-in-zeekpath:
  NEWS: Mention can_load() and find_in_zeekpath()
  utils: Introduce packages.zeek with can_load() helper
  zeek.bif: Add find_in_zeekpath() helper
This commit is contained in:
Arne Welzel 2024-02-26 21:14:59 +01:00
commit 77d57fccfd
12 changed files with 171 additions and 0 deletions

View file

@ -17,6 +17,7 @@
@load base/utils/geoip-distance
@load base/utils/hash_hrw
@load base/utils/numbers
@load base/utils/packages
@load base/utils/paths
@load base/utils/patterns
@load base/utils/queue

View file

@ -0,0 +1,16 @@
##! Rudimentary functions for helping with Zeek packages.
## Checks whether @load of a given package name could
## be successful.
##
## This tests for the existence of corresponding script files
## in ZEEKPATH. It does not attempt to parse and validate
## any actual Zeek script code.
##
## path: The filename, package or path to test.
##
## Returns: T if the given filename, package or path may load.
function can_load(p: string): bool
{
return find_in_zeekpath(p) != "";
}