utils: Introduce packages.zeek with can_load() helper

This commit is contained in:
Arne Welzel 2024-02-22 09:53:12 +01:00
parent 704f75a214
commit 947294efab
5 changed files with 54 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) != "";
}