Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

File system layout

Robin Sommer edited this page Jul 7, 2021 · 2 revisions

The Spicy plugin for Zeek needs to support a few different deployment options: dynamic and static builds, running outside the installation and build directories, and installation through zkg. The following summarizes where files are located and searched in each of these models.

Dynamic plugin (default)

Layout of the installation directory under <prefix>/

<prefix>/
	bin/spicyz
	lib/zeek-spicy/			        [Plugin path]
	    __bro_plugin__
		cmake/...
		include/zeek-spicy/...		[Module path]
		lib/
			_Zeek-Spicy.<arch>.so
			bif/
		modules/...
		scripts/...
		spicy/...
		tests/...
		scripts/...

Layout of the build/ directory

<build directory>/				[Plugin path]
	__bro_plugin__
	bin/spicyz
	cmake/...
	include/zeek-spicy/...
	lib/
		_Zeek-Spicy.<arch>.so
		bif/...
	scripts/... (link to source)
	spicy/... 
	tests/...

<prefix>/
	lib/zeek-spicy/modules/...		[Module path]

Layout inside the zkg state directory

%(package_base)s/spicy-plugin/build/	        [Plugin path]
	 __bro_plugin__
	bin/spicyz
	cmake/...
	include/zeek-spicy/...
	lib/
		_Zeek-Spicy.<arch>.so
		bif/...
	scripts/... (link to source)
	spicy/... 
	tests/...

</usr/local/lib/prefix>/
	lib/zeek-spicy/modules/...		[Module path]

Notes:

  • This is same layout out the normal build/ tree.
    • The plugin also searches Zeek's plugin path for *.hlto files, in addition to the standard module path. That's how it’ll find analyzers installed by other zkg packages.
    • The actual module path here is of questionable use because there’s no way to pass in a different prefix that than standard /usr/local.

Static plugin inside Zeek (--include-plugin)

Layout of the installation directory under <prefix>/

<Zeek prefix>
	bin/spicyz
	lib/zeek-spicy					[Plugin path]
   		cmake/...
		include/zeek-spicy/...
		modules/...				[Module path]
		spicy/...
		tests/...

	include/zeek/builtin-plugins/spicy-plugin 	(Spicy's BiF *.h includes; managed by Zeek)
	share/zeek/builtin-plugins/_Zeek_Spicy/...	(Spicy's *.zeek scripts; managed by Zeek)
	share/zeek/base/bif/plugins/			(Spicy's BiF *.zeek scripts; managed by Zeek)

Layout of the build/ directory

TODO: Confirm this layout and that it works.

<Zeek build directory>
	src/builtin-plugins/spicy-plugin	        [Plugin path]
		bin/spicyz
		cmake/...					
		include/zeek-spicy/...
		lib/
			bif/...
		scripts/... (link to source)
		spicy/... 
		tests/...	

<prefix>/
	lib/zeek-spicy/modules/...			[Module path]

Search paths

Options to query spicyz

	--print-prefix-path  	->  <prefix>
  	--print-module-path	->  <prefix>/lib/zeek-spicy/modules
  	--print-plugin-path     ->  (test -e $(dirname $0)/../__bro_plugin__ 
					? $(dirname $0)/..   		       # Inside <build>
					: $(dirname $0)/../lib/zeek-spicy      # Inside <prefix>
  	--print-scripts-path    ->  <plugin-path>/scripts

Compilation

spicyz

CXX includes	    ${SPICY_CXX_INCLUDE_PATH}:$(dirname .$0)/../lib/include
Spicy HLTOs         ${SPICY_MODULE_PATH}:<prefix>/lib/zeek-spicy/modules
Spicy libraries	    ${SPICY_PATH}:$(dirname $0)/../lib/spicy

Plugin

CXX includes	    ${SPICY_CXX_INCLUDE_PATH}:$(dirname .so)/../include
Spicy libraries	    ${SPICY_PATH}:$(dirname .so)/../spicy
Spicy HLTOs         ${SPICY_MODULE_PATH}:<prefix>/lib/zeek-spicy/modules
Zeek scripts        $(dirname .so)/../lib/zeek-spicy/scripts