This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The script (mac/linux) or executable (windows) that runs Zeek, including creating required environment variables & command line options, is now zeekrunner or zeekrunner.exe . The command line options used to run Zeek are now in this repo instead of in the zqd source. The job object based process termination for windows is removed, as it is moved into zqd; this will make it easier to eventually replace the windows zeek runner with a script or batch file.
- Loading branch information
1 parent
1286800
commit 4fc8af0
Showing
10 changed files
with
106 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zeekrunner.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/brimsec/zeek/brim/windows/zeekrunner | ||
|
||
go 1.13 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// +build windows | ||
|
||
// This tool executes zeek on windows, constructing the cygwin compatible ZEEK* | ||
// environment variables required. It embeds knowledge of the locations of the | ||
// zeek executable and zeek script locations in the expanded 'zdeps/zeek' | ||
// directory inside a Brim installation. | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// These paths are relative to the zdeps/zeek directory. | ||
var ( | ||
zeekExecRelPath = "bin/zeek.exe" | ||
zeekPathRelPaths = []string{ | ||
"share/zeek", | ||
"share/zeek/policy", | ||
"share/zeek/site", | ||
} | ||
zeekPluginRelPaths = []string{ | ||
"lib/zeek/plugins", | ||
} | ||
) | ||
|
||
func cygPathEnvVar(name, topDir string, subdirs []string) string { | ||
var s []string | ||
for _, l := range subdirs { | ||
p := filepath.Join(topDir, filepath.FromSlash(l)) | ||
vol := filepath.VolumeName(p) | ||
cyg := "/cygdrive/" + vol[0:1] + filepath.ToSlash(p[len(vol):]) | ||
s = append(s, cyg) | ||
} | ||
val := strings.Join(s, ":") | ||
return name + "=" + val | ||
} | ||
|
||
var ExecScript = ` | ||
event zeek_init() { | ||
Log::disable_stream(PacketFilter::LOG); | ||
Log::disable_stream(LoadedScripts::LOG); | ||
}` | ||
|
||
func launchZeek(zdepsZeekDir, zeekExecPath string) error { | ||
zeekPath := cygPathEnvVar("ZEEKPATH", zdepsZeekDir, zeekPathRelPaths) | ||
zeekPlugin := cygPathEnvVar("ZEEK_PLUGIN_PATH", zdepsZeekDir, zeekPluginRelPaths) | ||
|
||
cmd := exec.Command(zeekExecPath, "-C", "-r", "-", "--exec", ExecScript, "local") | ||
cmd.Stdin = os.Stdin | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
cmd.Env = append(os.Environ(), zeekPath, zeekPlugin) | ||
|
||
return cmd.Run() | ||
} | ||
|
||
// zdepsZeekDirectory returns the absolute path of the zdeps/zeek directory, | ||
// based on the assumption that this executable is located directly in it. | ||
func zdepsZeekDirectory() (string, error) { | ||
execFile, err := os.Executable() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return filepath.Dir(execFile), nil | ||
} | ||
|
||
func main() { | ||
zdepsZeekDir, err := zdepsZeekDirectory() | ||
if err != nil { | ||
log.Fatalln("zdepsZeekDirectory failed:", err) | ||
} | ||
|
||
zeekExecPath := filepath.Join(zdepsZeekDir, filepath.FromSlash(zeekExecRelPath)) | ||
if _, err := os.Stat(zeekExecPath); err != nil { | ||
log.Fatalln("zeek executable not found at", zeekExecPath) | ||
} | ||
|
||
err = launchZeek(zdepsZeekDir, zeekExecPath) | ||
if err != nil { | ||
log.Fatalln("launchZeek failed", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
|
||
export ZEEKPATH=$dir/share/zeek:$dir/share/zeek/policy:$dir/share/zeek/site | ||
export ZEEK_PLUGIN_PATH=$dir/lib/zeek/plugins | ||
|
||
# The packet filter and loaded scripts are disabled because they emit either | ||
# timeless logs or logs with timestamp set to execution time rather than time | ||
# of capture. | ||
exec "$dir/bin/zeek" \ | ||
-C -r - \ | ||
--exec "event zeek_init() { Log::disable_stream(PacketFilter::LOG); Log::disable_stream(LoadedScripts::LOG); }" \ | ||
local |