A Zeek script formatter and analyzer
Project description
A toolchain to parse, analyze, and format Zeek scripts
zeekscript
is a Python package that provides tooling to operate on Zeek
scripts. zeekscript
comes with command line tools that make common tasks accessible,
but its functionality is just an import zeekscript
away in your own Python tools.
zeekscript
is powered by Tree-Sitter,
its Python bindings, and our
tree-sitter-zeek grammar. When
working from source, make sure to clone this repository recursively in order
to pull in the right version of the grammar and parser.
Supported platforms and Python versions
zeekscript
supports Python 3.7+ on Linux, MacOS, and Windows.
Installation
$ pip install zeekscript
For local installation, say pip install .
in a (recursive!) clone of the
repository. Please report any hiccups during the installation as bugs. There's a
lot going on behind the scene in this package, since the tree_sitter
Python
package compiles the language parser into a native-code shared library on the
fly.
Usage
zeek-format
Most significantly, the package includes zeek-format
, a tool that formats Zeek
scripts. Our philosophy is similar to gofmt
and the opposite of
clang-format
: there is only one way to layout Zeek scripts, and this tool
provides it. Accordingly, it features zero options for tweaking the formatting:
$ zeek-format --help
usage: zeek-format [-h] [--inplace] [FILES ...]
A Zeek script formatter
positional arguments:
FILES Zeek script(s) to process. Use "-" to specify stdin as a filename. Omitting filenames entirely implies reading from stdin.
options:
-h, --help show this help message and exit
--inplace, -i change provided files instead of writing to stdout
In case of processing error, zeek-format
exits with a non-zero exit code,
reports the trouble it encountered to stderr, and reports its input unchanged.
$ echo 'event foo( a:count ) {print("hi"); }' | zeek-format
event foo(a: count) {
print ("hi");
}
zeek-script
The zeek-script
command is the Swiss army knife in the toolbox: it provides
access to a range of script-processing tools (including formatting) via
subcommands. (Okay, so far "range" == two, but expect that to grow in the future.)
$ zeek-script --help
usage: zeek-script [-h] {format,parse} ...
A Zeek script analyzer
options:
-h, --help show this help message and exit
commands:
{format,parse} See `zeek-script <command> -h` for per-command usage info.
format Format/indent Zeek scripts
parse Show Zeek script parse tree
The parse
command renders its script input as a parse tree. It resembles
tree-sitter parse
, but shows more context about the relevant snippets of
content, including parsing errors.
$ echo 'event zeek_init() { }' | zeek-script parse
source_file (0.0,1.0) 'event zeek_init() { }\n'
decl (0.0,0.21) 'event zeek_init() { }'
func_decl (0.0,0.21) 'event zeek_init() { }'
func_hdr (0.0,0.17) 'event zeek_init()'
event (0.0,0.17) 'event zeek_init()'
event (0.0,0.5)
id (0.6,0.15) 'zeek_init'
func_params (0.15,0.17) '()'
( (0.15,0.16)
) (0.16,0.17)
func_body (0.18,0.21) '{ }'
{ (0.18,0.19)
} (0.20,0.21)
See zeek-script parse --help
for more information.
Integration into text editors
You can integrate zeekscript
into any editor that supports the execution of
shell commands on the currently edited files. The relevant zeekscript
commands
support reading from stdin or filename.
Emacs
We offer an Emacs mode with support for script formatting and parse tree inspection via keyboard shortcuts.
vim
The following snippet hooks up zeek-format
to format the current script:
function RunZeekScript()
" Create a new undo block for reverting formatting without changing cursor
" position. https://github.com/rhysd/vim-clang-format/pull/55
silent execute "noautocmd normal! ii\<esc>\"_x"
let l:save = winsaveview()
execute "%!zeek-format"
call winrestview(l:save)
endfunction
nnoremap <silent><buffer> <leader>cf :call RunZeekScript()<CR>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for zeekscript-1.1.0-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 354415163a446dbdf87a630ed2d443e4f0426d5d5a9616967711f8c134af1325 |
|
MD5 | 01180deebf3c18b2a28b6787b0c8fdc3 |
|
BLAKE2b-256 | 06c0f452d20edc481ccb189c3b3a339daa9e35d34ff9b1d2d36f3d250b656e89 |
Hashes for zeekscript-1.1.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34888b6502d7b29b0ea786763d45454d59f11bd7503fe0be9d476d376f02d128 |
|
MD5 | 6f8592e56ec9c6df8c4cad6c2deaef5b |
|
BLAKE2b-256 | 09c61643e11ec4d1ad92ba77b5a4e1aa08b4d21dc1c2a994a09bc134b7ab36f7 |
Hashes for zeekscript-1.1.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eb683252f1271f846560625a948612d7dce866d8bcde553ca75f179c324783b |
|
MD5 | 1bb1497e1579fe3a82e6830652e75064 |
|
BLAKE2b-256 | fb273210396a642ce046d703f0495eff142ad7255ececd077956389e46cbd18e |
Hashes for zeekscript-1.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 210a2dfd9e34163e497edc9b526aad42c6e0d4e7412efef6fec23d19c0371235 |
|
MD5 | 0d6f0de8e821b73d2670fbeefe8ce1bb |
|
BLAKE2b-256 | 0d56c54c86891d3d35b4c3b173189c21db68c144bf082e957db33ba8324bbed0 |
Hashes for zeekscript-1.1.0-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad3699e8adf5abe3fdabf634df9323c115a3575269b899cb641387d53143b613 |
|
MD5 | ccb4cf0b2d997c468de675de7fdda6e2 |
|
BLAKE2b-256 | 01503cc652f584554de4a0b5d5b0dda564b62a193deab254e9d7750c89e3ba03 |
Hashes for zeekscript-1.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb8d50e5cd8d72d1aa595c85ab3ef2313d8eb6a360b0a3b7f530654faa0eb2a0 |
|
MD5 | 0edb18f4b01117112234df33c45e4615 |
|
BLAKE2b-256 | 1b166b7024c9332abd20c0304845304dfe3808905e281508675745d945388cac |
Hashes for zeekscript-1.1.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98a0b518640efc25eb9c244777703316cc77b83db646a7c4ad4da5aca3166d2b |
|
MD5 | 53f828e89bbb388b96d179bfd21f660d |
|
BLAKE2b-256 | 15bc96e2eaed03e335c897e5aefe299291c841313128dfd208930a20dae94816 |
Hashes for zeekscript-1.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 826d0ca357311d5c30e6785b0ea8356dd1b5b59a2c5ed1cf09d79ac6eef05dc9 |
|
MD5 | b4d048050747fd89824a18b13523d18f |
|
BLAKE2b-256 | 57db123ada9e47f4e7ed5bb083dccb265a72f7b43145cbf525ae7a61bfecd3ee |
Hashes for zeekscript-1.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfffd367051da3162f2b74e33493877e606e50fc24baebe95512e04e808853dd |
|
MD5 | 1b54b55605bb4c08e8dbeb08848d77e5 |
|
BLAKE2b-256 | 5132b20fb6879d1396ae7d8a739d11237fa6e5bfe214041ccea4a32cc98711d0 |
Hashes for zeekscript-1.1.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a64ede41d52dcecf525415225bca0dc89f2d71de100c2a2b7f097be1e4fe5d9 |
|
MD5 | 397dd8172e5da6513bab127b49591ce5 |
|
BLAKE2b-256 | 6087e13d9592d6bacd4797b3b39716cbe7bb851b13e6877e16a632ba0d96f6bb |
Hashes for zeekscript-1.1.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 952c22d9b60d8b12e2f80e793f549bfb3fef714dcd52fb8033a2f8d9f0047579 |
|
MD5 | 29c293acae2007e0a87a1f723f73306b |
|
BLAKE2b-256 | 1e59156afb8840d051e26edafe029205f2dac0b5776835693ea01ea419eaa327 |
Hashes for zeekscript-1.1.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08b2ae0cadf7c7221ca993bf336071eb504509c18d81c118236bb8e9002d9880 |
|
MD5 | 28409c671cb327297a8ae88cf3d96403 |
|
BLAKE2b-256 | b7a22d9c3cceb90e78ea7f2a406c539128f8d1c90b122082c77a00e656e9474a |
Hashes for zeekscript-1.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4835de6bf0e6828fb643472a6c0fcc40be615a0a1785eb200d55c0685d67ddfb |
|
MD5 | 8b915a7c6e0246ee93a5350a73724b58 |
|
BLAKE2b-256 | 2652d41db092fe88fde2b72aed2b323b03e86f6bceb7f1a91f36555150d784b7 |
Hashes for zeekscript-1.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e16da1fa94d25ad33af5f4de880a95be174ae2781a5fff48f2c976af6393ec |
|
MD5 | 020ca5b1eeaeed25855a77ff00e74885 |
|
BLAKE2b-256 | 8f9b415d266c8707525fbaf60fe0319100a39efde584934822d4591cb5573cfd |
Hashes for zeekscript-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ec350ea4e980e089a449a34a44c377e0cb34b39cd0a0b526ce4b857297ee0a6 |
|
MD5 | 491b0a7cd84ce33256d7c5715ce440be |
|
BLAKE2b-256 | d92bb18423277a54a1017cd2375e79754d687d85927adc33954f18943cc5fd7e |
Hashes for zeekscript-1.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9b959bb05478bd95da2eebc7280d6fd6dec4d60bcb03c8e4d5b50f0cda3b719 |
|
MD5 | 2c9e664ea6369b70d9c54f97c5486346 |
|
BLAKE2b-256 | 2d5051895ecd7c1905e0084ee98972e5829739e421870b927c7fa745badb3505 |
Hashes for zeekscript-1.1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4e4234105c705a256feba55d8bab67b8ebc6f193c8ce32e22705d3df069cb9a |
|
MD5 | eaf336c43a79f7fffda946dbc41e0c1b |
|
BLAKE2b-256 | 3b334dd096bb4b4808670799e278bb331be14713ee3b27cdab77403c1a240bb7 |
Hashes for zeekscript-1.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e573d7e70b4df761d641117e337b00694e76eac0665d9a738841c8e0f6f284 |
|
MD5 | 88c8c0b8851e78b0cfeafd446bf2b492 |
|
BLAKE2b-256 | 50969a758ca306c9d28009c11561c8c8d7748a654759e6547d1962a7b5d063ca |
Hashes for zeekscript-1.1.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f6d81935d620431a297e76d90227e8b9fef49f69e9af334a133ff0368cdbfe2 |
|
MD5 | 00bc5bd25cdfa7c7b11f207bb3953565 |
|
BLAKE2b-256 | 44f3f4ee458b9b7d56b6e773dc7f7de79591ab347939117a8d119ecf0360a2db |
Hashes for zeekscript-1.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8c36d6833617649ef3425447461b7b20ab4832c8b0b9bf1c909aa6e0b364451 |
|
MD5 | e42bd594a24c74b991b88a4b2f8267fc |
|
BLAKE2b-256 | b11a54e406f67368ff71706682ecfcaa3342013edde554765bb1ac33a0db3686 |
Hashes for zeekscript-1.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff391161c2a6bc961973f37f3f1419d4422d6d12c9765c1364c083c8b4f2538 |
|
MD5 | 886e54ca02952565cdf26fcd3cf56323 |
|
BLAKE2b-256 | 99152bbc01dc3d5f0b25720c9029435ab1af0ab64c8458f6a13d412f0108e260 |
Hashes for zeekscript-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4283300c18009a7b00c4952a7fcbd8f4c026c62f3165d2dc8c54196302fcdfd |
|
MD5 | e8ad76bc0b03749bf1ecd883e8051869 |
|
BLAKE2b-256 | 1d3b629f49f56e14e407ea60805270bb1077de75012fb2bc562cd7d5b5e1fbb3 |
Hashes for zeekscript-1.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf583f7591153cbd19dbffa75dfad8f15cb4163548e85322d84f5aa3aba65014 |
|
MD5 | a979939b0a74ade5738e2cb6d1be6308 |
|
BLAKE2b-256 | 63f0d52e8eff2fd3511740ab0b0d978637b0c555a0add527f96836f7918c1379 |
Hashes for zeekscript-1.1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aebd67a3c4bab2362aea2890034992964fd823bc9d6f0be5d08916c1f2afbe89 |
|
MD5 | 82f76995f099ab61ba5f464994854f6c |
|
BLAKE2b-256 | 15c70457bca0f357e10665dd34dc13ea856cc58280c61bf2f3e9049cd973f87b |
Hashes for zeekscript-1.1.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89744e633aad2f33b255043792676e3f4c0d461927289523550be2ce762a8370 |
|
MD5 | 2c80131f78677905c2c272faf5e1492e |
|
BLAKE2b-256 | a6c56760f66d5f128a0a75ce500f797cd19a3c3ed5fcf0810d4e25ae03aed828 |
Hashes for zeekscript-1.1.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea192fd5f284d61bc36fcc9d460332170e39e60cd617c0cb377ded7a756e9bf |
|
MD5 | 1d0ccf5c47296313248ee98db29b35a8 |
|
BLAKE2b-256 | 95dcc47a71b28d2cd2fc665932b8188a54f19112f8a87e8ce0ddc9ae70604ea0 |
Hashes for zeekscript-1.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db98293fdbc6cadabce054406fbf7b93471da7ee6f15ffeff5914041bf9ee2c0 |
|
MD5 | 7d7181f0dbcdd5f5e7927f07df660358 |
|
BLAKE2b-256 | e7e522b43183689aaaa7914296cf6aaedf72ae701ade4fa548ad357980498872 |
Hashes for zeekscript-1.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3242f968d15679d95f78103283f46410ee96febe4a1a94bf4bd2762d3ef3506c |
|
MD5 | 647861338781fe53ee0adfddf4dac9cc |
|
BLAKE2b-256 | f33a4a70cbba543217937a375c1bdd6cb1cd60100d664b8972c0b650ae4689ca |
Hashes for zeekscript-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5bc7cdc04908c16275a9c7d6e3b0f6d3d1a1b4318397b4baebe912d7b19940b |
|
MD5 | a83ba2a786dcf23819f6c64f14304d0e |
|
BLAKE2b-256 | 7bf8d9e4a3418f1d23d24719bf83fec29571568ca5be4ba9da0d68f35bfb48cd |
Hashes for zeekscript-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5324f0461aed41cf1927ec7a4ae09f3beba46443abf8f06746fe9c742140c9c0 |
|
MD5 | 993d810905081801ef33e3ab98ab87c9 |
|
BLAKE2b-256 | 7c97037f4474c6e5ff239a54e2895e4ffa5efd4a9eb0eb5ac60bfaa828b39f2b |
Hashes for zeekscript-1.1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72fa692e7e98e7983ee30dd36af8f8a09ae0e3d87c9ca611573a3340da718419 |
|
MD5 | 31a86eccda62f2e3b0e800d7112914fe |
|
BLAKE2b-256 | 847b2b0f1e956b90122fa600bb0eeed71652673ddc5ead7ec3ed4403e205a9e9 |
Hashes for zeekscript-1.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0725b703b7cef3c1c63eeff66dcc1073c0f4986d4be5832be7bf7b494fa46a78 |
|
MD5 | b8c34b9db942bfd94c82484174e1898e |
|
BLAKE2b-256 | a64b9d151071f217032a35d16ad9d7c19e7041fbdd158566f2b034e936b8ac07 |
Hashes for zeekscript-1.1.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ef30b84ee82b2f589a86879c3bdb906b454ea11524bb6fdbfb9434e079b383 |
|
MD5 | 83d37f71ed117e27fbc6521d707901c3 |
|
BLAKE2b-256 | 6bcfb7cb3cdf0ebe9d0f8f89e3bfe4bf17420bbe4e2abf84f1058cfa60c1b525 |
Hashes for zeekscript-1.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a09f3331d8a20460f64513f4ba4bc83db6bbb94841ae5b2b0e99a4f3305a4e81 |
|
MD5 | c9fc502d615091877d8a7a0d0685c6a0 |
|
BLAKE2b-256 | 6e52787010022c281402fd16ac3945907a74177b7fdf288878127494dbb31f3b |
Hashes for zeekscript-1.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50a8188b860adba49f2d142fe204a08385e6485706414a5a54adfada3cf6d06d |
|
MD5 | a99ca65030f34402ad01a68a811ab4de |
|
BLAKE2b-256 | 2c7e4315afe12be2c2372bd51ce9984137ca581a9a8afea78f093335268647f0 |
Hashes for zeekscript-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f7ee12fca3aa5292db7a4d5cf12db6f2d488ed38a8b45257d4f3a8f5cf0d8a9 |
|
MD5 | 522e1330d51d4e5998ebcc7eb303750a |
|
BLAKE2b-256 | d42790fecce7a7c421faa1d3300b5ef3d0059474d4e1ff768d4a650ad4dde1a5 |