// See the file "COPYING" in the main distribution directory for copyright. #include "zeek/Options.h" #include "zeek/zeek-config.h" #if defined(HAVE_GETOPT_H) && ! defined(_MSC_VER) #include #endif #include #include #include #include #include #include "zeek/3rdparty/bsd-getopt-long.h" #include "zeek/ScriptProfile.h" #include "zeek/logging/writers/ascii/Ascii.h" #include "zeek/script_opt/ScriptOpt.h" namespace zeek { void Options::filter_supervisor_options() { pcap_filter = {}; signature_files = {}; pcap_output_file = {}; } void Options::filter_supervised_node_options() { auto og = *this; *this = {}; debug_log_streams = og.debug_log_streams; debug_script_tracing_file = og.debug_script_tracing_file; script_code_to_exec = og.script_code_to_exec; script_prefixes = og.script_prefixes; signature_re_level = og.signature_re_level; ignore_checksums = og.ignore_checksums; use_watchdog = og.use_watchdog; pseudo_realtime = og.pseudo_realtime; dns_mode = og.dns_mode; bare_mode = og.bare_mode; perftools_check_leaks = og.perftools_check_leaks; perftools_profile = og.perftools_profile; deterministic_mode = og.deterministic_mode; abort_on_scripting_errors = og.abort_on_scripting_errors; pcap_filter = og.pcap_filter; signature_files = og.signature_files; // TODO: These are likely to be handled in a node-specific or // use-case-specific way. e.g. interfaces is already handled for the // "cluster" use-case, but don't have supervised-pcap-reading // functionality yet. /* interface = og.interface; */ /* pcap_file = og.pcap_file; */ pcap_output_file = og.pcap_output_file; random_seed_input_file = og.random_seed_input_file; random_seed_output_file = og.random_seed_output_file; process_status_file = og.process_status_file; plugins_to_load = og.plugins_to_load; scripts_to_load = og.scripts_to_load; script_options_to_set = og.script_options_to_set; } bool fake_dns() { return getenv("ZEEK_DNS_FAKE"); } extern const char* zeek_version(); void usage(const char* prog, int code) { fprintf(stderr, "zeek version %s\n", zeek_version()); fprintf(stderr, "usage: %s [options] [file ...]\n", prog); fprintf(stderr, "usage: %s --test [doctest-options] -- [options] [file ...]\n", prog); fprintf(stderr, " | Zeek script file, or read stdin\n"); fprintf(stderr, " -a|--parse-only | exit immediately after parsing scripts\n"); fprintf(stderr, " -b|--bare-mode | don't load scripts from the base/ directory\n"); fprintf(stderr, " -c|--capture-unprocessed | write unprocessed packets to a tcpdump file\n"); fprintf(stderr, " -d|--debug-script | activate Zeek script debugging\n"); fprintf(stderr, " -e|--exec | augment loaded scripts by given code\n"); fprintf(stderr, " -f|--filter | tcpdump filter\n"); fprintf(stderr, " -h|--help | command line help\n"); fprintf(stderr, " -i|--iface | read from given interface (only one allowed)\n"); fprintf(stderr, " -p|--prefix | add given prefix to Zeek script file resolution\n"); fprintf(stderr, " -r|--readfile | read from given tcpdump file (only one " "allowed, pass '-' as the filename to read from stdin)\n"); fprintf(stderr, " -s|--rulefile | read rules from given file\n"); fprintf(stderr, " -t|--tracefile | activate execution tracing\n"); fprintf(stderr, " -u|--usage-issues | find variable usage issues and exit\n"); fprintf(stderr, " --no-unused-warnings | suppress warnings of unused " "functions/hooks/events\n"); fprintf(stderr, " -v|--version | print version and exit\n"); fprintf(stderr, " -V|--build-info | print build information and exit\n"); fprintf(stderr, " -w|--writefile | write to given tcpdump file\n"); #ifdef DEBUG fprintf(stderr, " -B|--debug | Enable debugging output for selected " "streams ('-B help' for help)\n"); #endif fprintf(stderr, " -C|--no-checksums | ignore checksums\n"); fprintf(stderr, " -D|--deterministic | initialize random seeds to zero\n"); fprintf(stderr, " -E|--event-trace | generate a replayable event trace to " "the given file\n"); fprintf(stderr, " -F|--force-dns | force DNS\n"); fprintf(stderr, " -G|--load-seeds | load seeds from given file\n"); fprintf(stderr, " -H|--save-seeds | save seeds to given file\n"); fprintf(stderr, " -I|--print-id | print out given ID\n"); fprintf(stderr, " -N|--print-plugins | print available plugins and exit (-NN " "for verbose)\n"); fprintf(stderr, " -O|--optimize