// 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 prompt_for_help(const char* prog) { fprintf(stderr, "Try '%s --help' for more information.\n", prog); } void usage(const char* prog) { printf("zeek version %s\n", zeek_version()); printf("usage: %s [options] [file ...]\n", prog); printf("usage: %s --test [doctest-options] -- [options] [file ...]\n", prog); printf(" | Zeek script file, or read stdin\n"); printf(" -a|--parse-only | exit immediately after parsing scripts\n"); printf(" -b|--bare-mode | don't load scripts from the base/ directory\n"); printf(" -c|--capture-unprocessed | write unprocessed packets to a tcpdump file\n"); printf(" -d|--debug-script | activate Zeek script debugging\n"); printf(" -e|--exec | augment loaded scripts by given code\n"); printf(" -f|--filter | tcpdump filter\n"); printf(" -h|--help | command line help\n"); printf(" -i|--iface | read from given interface (only one allowed)\n"); printf(" -p|--prefix | add given prefix to Zeek script file resolution\n"); printf( " -r|--readfile | read from given tcpdump file (only one " "allowed, pass '-' as the filename to read from stdin)\n"); printf(" -s|--rulefile | read rules from given file\n"); printf(" -t|--tracefile | activate execution tracing\n"); printf(" -u|--usage-issues | find variable usage issues and exit\n"); printf( " --no-unused-warnings | suppress warnings of unused " "functions/hooks/events\n"); printf(" -v|--version | print version and exit\n"); printf(" -V|--build-info | print build information and exit\n"); printf(" -w|--writefile | write to given tcpdump file\n"); #ifdef DEBUG printf( " -B|--debug | Enable debugging output for selected " "streams ('-B help' for help)\n"); #endif printf(" -C|--no-checksums | ignore checksums\n"); printf(" -D|--deterministic | initialize random seeds to zero\n"); printf( " -E|--event-trace | generate a replayable event trace to " "the given file\n"); printf(" -F|--force-dns | force DNS\n"); printf(" -G|--load-seeds | load seeds from given file\n"); printf(" -H|--save-seeds | save seeds to given file\n"); printf(" -I|--print-id | print out given ID\n"); printf( " -N|--print-plugins | print available plugins and exit (-NN " "for verbose)\n"); printf( " -O|--optimize