mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
GH-700: add zeek_args() BIF
Provides access to all zeek command-line arguments ("argv").
This commit is contained in:
parent
c4a086bdcc
commit
57c7cbdb92
3 changed files with 16 additions and 0 deletions
13
src/zeek.bif
13
src/zeek.bif
|
@ -23,6 +23,7 @@
|
||||||
#include "file_analysis/Manager.h"
|
#include "file_analysis/Manager.h"
|
||||||
#include "iosource/Manager.h"
|
#include "iosource/Manager.h"
|
||||||
#include "iosource/Packet.h"
|
#include "iosource/Packet.h"
|
||||||
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1877,6 +1878,18 @@ function type_name%(t: any%): string
|
||||||
return new StringVal(s);
|
return new StringVal(s);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
## Returns: list of command-line arguments (``argv``) used to run Zeek.
|
||||||
|
function zeek_args%(%): string_vec
|
||||||
|
%{
|
||||||
|
auto sv = internal_type("string_vec")->AsVectorType();
|
||||||
|
auto rval = make_intrusive<VectorVal>(sv);
|
||||||
|
|
||||||
|
for ( auto i = 0; i < bro_argc; ++i )
|
||||||
|
rval->Assign(rval->Size(), new StringVal(bro_argv[i]));
|
||||||
|
|
||||||
|
return rval.detach();
|
||||||
|
%}
|
||||||
|
|
||||||
## Checks whether Zeek reads traffic from one or more network interfaces (as
|
## Checks whether Zeek reads traffic from one or more network interfaces (as
|
||||||
## opposed to from a network trace in a file). Note that this function returns
|
## opposed to from a network trace in a file). Note that this function returns
|
||||||
## true even after Zeek has stopped reading network traffic, for example due to
|
## true even after Zeek has stopped reading network traffic, for example due to
|
||||||
|
|
1
testing/btest/Baseline/bifs.zeek_args/out
Normal file
1
testing/btest/Baseline/bifs.zeek_args/out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[zeek, -b, -r, /Users/jsiwek/pro/zeek/zeek/testing/btest/Traces/http/get.trace, -e, print zeek_args()]
|
2
testing/btest/bifs/zeek_args.zeek
Normal file
2
testing/btest/bifs/zeek_args.zeek
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# @TEST-EXEC: zeek -b -r $TRACES/http/get.trace -e 'print zeek_args()' >out
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
Loading…
Add table
Add a link
Reference in a new issue