zeek icon indicating copy to clipboard operation
zeek copied to clipboard

zeek.bif: Add find_in_zeekpath() helper

Open awelzel opened this issue 6 months ago • 4 comments

Relates to #3594. This helper can be used to determine the path that will be used by @load, if at all. Usage example:

@if ( find_in_zeekpath("my-package") != "" )
@load my-package
@endif

Replaces #3615, renaming and adding error on absolute and relative paths.

awelzel avatar Feb 21 '24 16:02 awelzel

I still like the idea of

@if ( can_load("the-package") )
@load the-package
@endif

Comparing the return value to "" seems a bit awkward. Is there a use case where the resulting path is useful?

JustinAzoff avatar Feb 22 '24 01:02 JustinAzoff

It's just needs a BiF - why not support both?

vpax avatar Feb 22 '24 02:02 vpax

Comparing the return value to "" seems a bit awkward. Is there a use case where the resulting path is useful?

Yeah, it would look better. It mostly came from the angle that @load also works for relative paths, too and a can_load() being over-promising here. As for the return value, my thought was the next possibly question would be what the actual path ended up being (could be interesting if your ZEEKPATH became very complex, or want to determine installation directories based on init-bare.zeek's location or some such tricks), so why not yield that instead.

I do agree that the new helper doesn't make the can_load() use-case obvious, but that also seemed relatively niche/advanced enough to allow for the != "" awkwardness. If you/anyone feels much stronger, I'll add it.

It's just needs a BiF - why not support both?

Given find_in_zeekpath(), can_load() seemed small enough to be provided by an external script. Though, not sure I understand your comment fully.

awelzel avatar Feb 22 '24 08:02 awelzel

I do agree that the new helper doesn't make the can_load() use-case obvious, but that also seemed relatively niche/advanced enough to allow for the != "" awkwardness. If you/anyone feels much stronger, I'll add it.

I've added can_load() :-)

awelzel avatar Feb 22 '24 10:02 awelzel