diff --git a/CHANGES b/CHANGES index 2ead245154..7ac58d9f4a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,37 @@ +2.6-264 | 2019-05-03 11:16:38 -0700 + + * Fix sporadic openflow/broker test failure (Jon Siwek, Corelight) + +2.6-263 | 2019-05-02 22:49:40 -0700 + + * Install local.zeek as symlink to pre-existing local.bro (Jon Siwek, Corelight) + + This a convenience for those that are upgrading. If we didn't do + this, then deployments can silently break until the user intervenes + since BroControl now prefers to load the initially-vanilla local.zeek + instead of the formerly-customized local.bro. + +2.6-262 | 2019-05-02 21:39:01 -0700 + + * Rename Zeexygen to Zeekygen (Jon Siwek, Corelight) + +2.6-261 | 2019-05-02 20:49:23 -0700 + + * Remove previously deprecated policy/protocols/smb/__load__ (Jon Siwek, Corelight) + +2.6-260 | 2019-05-02 19:16:48 -0700 + + * GH-243: Remove deprecated functions/events from 2.6 and earlier (Johanna Amann, Corelight) + +2.6-258 | 2019-05-02 12:26:54 -0700 + + * GH-340: Improve IPv4/IPv6 regexes, extraction, and validity functions. + + is_valid_ip() is not a BIF, the IP regular expressions are improved and + extract_ip_addresses should give better results due to this. + (Jon Siwek, Corelight) + 2.6-255 | 2019-05-01 08:38:49 -0700 * Add methods to queue events without handler existence check diff --git a/NEWS b/NEWS index bd3cb601c0..d0d92f77b0 100644 --- a/NEWS +++ b/NEWS @@ -80,10 +80,13 @@ Changed Functionality --------------------- - ``$prefix/share/bro/site/local.bro`` has been renamed to - ``local.zeek``. If you have made customizations to that file, it - will no longer be loaded by default by BroControl (ZeekControl), - but you can simply copy it to ``local.zeek`. You may also want to - remove old ``local.bro`` files to avoid potential confusion. + ``local.zeek``. If you have a ``local.bro`` file from a previous + installation, possibly with customizations made to it, the new + version of Zeek will install a ``local.zeek`` file that is a symlink + to the pre-existing ``local.bro``. In that case, you may want to + just copy ``local.bro`` into the new ``local.zeek`` location to + avoid confusion, but things are otherwise meant to work properly + without intervention. - All scripts ending in ``.bro`` that ship with the Zeek source tree have been renamed to ``.zeek``. @@ -180,10 +183,10 @@ Changed Functionality and aren't counted as true gaps. - The Broxygen component, which is used to generate our Doxygen-like - scripting API documentation has been renamed to Zeexygen. This likely has + scripting API documentation has been renamed to Zeekygen. This likely has no breaking or visible changes for most users, except in the case one used it to generate their own documentation via the ``--broxygen`` flag, - which is now named ``--zeexygen``. Besides that, the various documentation + which is now named ``--zeekygen``. Besides that, the various documentation in scripts has also been updated to replace Sphinx cross-referencing roles and directives like ":bro:see:" with ":zeek:zee:". @@ -247,6 +250,10 @@ Removed Functionality - ``remote_log`` - ``finished_send_state`` - ``remote_pong`` + - ``finished_send_state`` + +- The deprecated script ``policy/protocols/smb/__load__.bro`` was removed. + Instead of ``@load policy/protocols/smb`` use ``@load base/protocols/smb``. Deprecated Functionality ------------------------ diff --git a/VERSION b/VERSION index 7e392f5f08..70f4699737 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-255 +2.6-264 diff --git a/doc b/doc index 5915e8d7e2..8aa690e20d 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 5915e8d7e24a77bb9bc2a7061790f8efbe871458 +Subproject commit 8aa690e20d19f79805d7f680e454e4ea10231add diff --git a/man/bro.8 b/man/bro.8 index a4c54d48f6..37c20bf0c5 100644 --- a/man/bro.8 +++ b/man/bro.8 @@ -99,7 +99,7 @@ Record process status in file \fB\-W\fR,\ \-\-watchdog activate watchdog timer .TP -\fB\-X\fR,\ \-\-zeexygen +\fB\-X\fR,\ \-\-zeekygen generate documentation based on config file .TP \fB\-\-pseudo\-realtime[=\fR] @@ -150,7 +150,7 @@ ASCII log file extension Output file for script execution statistics .TP .B BRO_DISABLE_BROXYGEN -Disable Zeexygen (Broxygen) documentation support +Disable Zeekygen (Broxygen) documentation support .SH AUTHOR .B bro was written by The Bro Project . diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 189c9b9df8..9a3f596add 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -8,8 +8,27 @@ install(DIRECTORY ./ DESTINATION ${BRO_SCRIPT_INSTALL_PATH} FILES_MATCHING PATTERN "*.fp" ) -# Install all local* scripts as config files since they are meant to be -# user modify-able. +if ( NOT BINARY_PACKAGING_MODE ) + # If the user has a local.bro file from a previous installation, prefer to + # symlink local.zeek to it to avoid breaking their custom configuration -- + # because BroControl will now prefer to load local.zeek rather than local.bro + # and we're about to install a default version of local.zeek. + + set(_local_bro_dst ${BRO_SCRIPT_INSTALL_PATH}/site/local.bro) + set(_local_zeek_dst ${BRO_SCRIPT_INSTALL_PATH}/site/local.zeek) + + install(CODE " + if ( \"\$ENV{DESTDIR}\" STREQUAL \"\" ) + if ( EXISTS \"${_local_bro_dst}\" AND NOT EXISTS \"${_local_zeek_dst}\" ) + message(STATUS \"WARNING: installed ${_local_zeek_dst} as symlink to ${_local_bro_dst}\") + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink + \"${_local_bro_dst}\" \"${_local_zeek_dst}\") + endif () + endif () + ") +endif () + +# Install local script as a config file since it's meant to be modified directly. InstallPackageConfigFile( ${CMAKE_CURRENT_SOURCE_DIR}/site/local.zeek ${BRO_SCRIPT_INSTALL_PATH}/site diff --git a/scripts/base/utils/addrs.zeek b/scripts/base/utils/addrs.zeek index be4c0c94c1..a4a4ef98e2 100644 --- a/scripts/base/utils/addrs.zeek +++ b/scripts/base/utils/addrs.zeek @@ -1,31 +1,67 @@ ##! Functions for parsing and manipulating IP and MAC addresses. # Regular expressions for matching IP addresses in strings. -const ipv4_addr_regex = /[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/; -const ipv6_8hex_regex = /([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}/; -const ipv6_compressed_hex_regex = /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)/; -const ipv6_hex4dec_regex = /(([0-9A-Fa-f]{1,4}:){6,6})([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/; -const ipv6_compressed_hex4dec_regex = /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}:)*)([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/; -# These are commented out until patterns can be constructed this way at init time. -#const ipv6_addr_regex = ipv6_8hex_regex | -# ipv6_compressed_hex_regex | -# ipv6_hex4dec_regex | -# ipv6_compressed_hex4dec_regex; -#const ip_addr_regex = ipv4_addr_regex | ipv6_addr_regex; +const ipv4_decim = /[0-9]{1}|[0-9]{2}|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]/; -const ipv6_addr_regex = - /([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}/ | - /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)/ | # IPv6 Compressed Hex - /(([0-9A-Fa-f]{1,4}:){6,6})([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/ | # 6Hex4Dec - /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}:)*)([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/; # CompressedHex4Dec +const ipv4_addr_regex = ipv4_decim & /\./ & ipv4_decim & /\./ & ipv4_decim & /\./ & ipv4_decim; -const ip_addr_regex = - /[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/ | - /([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}/ | - /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)/ | # IPv6 Compressed Hex - /(([0-9A-Fa-f]{1,4}:){6,6})([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/ | # 6Hex4Dec - /(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}:)*)([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/; # CompressedHex4Dec +const ipv6_hextet = /[0-9A-Fa-f]{1,4}/; + +const ipv6_8hex_regex = /([0-9A-Fa-f]{1,4}:){7}/ & ipv6_hextet; + +const ipv6_hex4dec_regex = /([0-9A-Fa-f]{1,4}:){6}/ & ipv4_addr_regex; + +const ipv6_compressed_lead_hextets0 = /::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,6})?/; + +const ipv6_compressed_lead_hextets1 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?/; + +const ipv6_compressed_lead_hextets2 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){1}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})?/; + +const ipv6_compressed_lead_hextets3 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){2}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})?/; + +const ipv6_compressed_lead_hextets4 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){3}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})?/; + +const ipv6_compressed_lead_hextets5 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){4}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})?/; + +const ipv6_compressed_lead_hextets6 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){5}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,0})?/; + +const ipv6_compressed_lead_hextets7 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){6}::/; + +const ipv6_compressed_hex_regex = ipv6_compressed_lead_hextets0 | + ipv6_compressed_lead_hextets1 | + ipv6_compressed_lead_hextets2 | + ipv6_compressed_lead_hextets3 | + ipv6_compressed_lead_hextets4 | + ipv6_compressed_lead_hextets5 | + ipv6_compressed_lead_hextets6 | + ipv6_compressed_lead_hextets7; + +const ipv6_compressed_hext4dec_lead_hextets0 = /::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})?/ & ipv4_addr_regex; + +const ipv6_compressed_hext4dec_lead_hextets1 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})?/ & ipv4_addr_regex; + +const ipv6_compressed_hext4dec_lead_hextets2 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){1}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})?/ & ipv4_addr_regex; + +const ipv6_compressed_hext4dec_lead_hextets3 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){2}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})?/ & ipv4_addr_regex; + +const ipv6_compressed_hext4dec_lead_hextets4 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){3}::([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,0})?/ & ipv4_addr_regex; + +const ipv6_compressed_hext4dec_lead_hextets5 = /[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){4}::/ & ipv4_addr_regex; + +const ipv6_compressed_hex4dec_regex = ipv6_compressed_hext4dec_lead_hextets0 | + ipv6_compressed_hext4dec_lead_hextets1 | + ipv6_compressed_hext4dec_lead_hextets2 | + ipv6_compressed_hext4dec_lead_hextets3 | + ipv6_compressed_hext4dec_lead_hextets4 | + ipv6_compressed_hext4dec_lead_hextets5; + +const ipv6_addr_regex = ipv6_8hex_regex | + ipv6_compressed_hex_regex | + ipv6_hex4dec_regex | + ipv6_compressed_hex4dec_regex; + +const ip_addr_regex = ipv4_addr_regex | ipv6_addr_regex; ## Checks if all elements of a string array are a valid octet value. ## @@ -44,49 +80,6 @@ function has_valid_octets(octets: string_vec): bool return T; } -## Checks if a string appears to be a valid IPv4 or IPv6 address. -## -## ip_str: the string to check for valid IP formatting. -## -## Returns: T if the string is a valid IPv4 or IPv6 address format. -function is_valid_ip(ip_str: string): bool - { - local octets: string_vec; - if ( ip_str == ipv4_addr_regex ) - { - octets = split_string(ip_str, /\./); - if ( |octets| != 4 ) - return F; - - return has_valid_octets(octets); - } - else if ( ip_str == ipv6_addr_regex ) - { - if ( ip_str == ipv6_hex4dec_regex || - ip_str == ipv6_compressed_hex4dec_regex ) - { - # the regexes for hybrid IPv6-IPv4 address formats don't for valid - # octets within the IPv4 part, so do that now - octets = split_string(ip_str, /\./); - if ( |octets| != 4 ) - return F; - - # get rid of remaining IPv6 stuff in first octet - local tmp = split_string(octets[0], /:/); - octets[0] = tmp[|tmp| - 1]; - - return has_valid_octets(octets); - } - else - { - # pure IPv6 address formats that only use hex digits don't need - # any additional checks -- the regexes should be complete - return T; - } - } - return F; - } - ## Extracts all IP (v4 or v6) address strings from a given string. ## ## input: a string that may contain an IP address anywhere within it. diff --git a/scripts/policy/protocols/smb/__load__.zeek b/scripts/policy/protocols/smb/__load__.zeek deleted file mode 100644 index 9e826f7fd6..0000000000 --- a/scripts/policy/protocols/smb/__load__.zeek +++ /dev/null @@ -1,3 +0,0 @@ -@deprecated "Use '@load base/protocols/smb' instead" - -@load base/protocols/smb diff --git a/scripts/test-all-policy.zeek b/scripts/test-all-policy.zeek index 0968c038ee..0eadf0ff57 100644 --- a/scripts/test-all-policy.zeek +++ b/scripts/test-all-policy.zeek @@ -83,7 +83,6 @@ @load protocols/modbus/track-memmap.zeek @load protocols/mysql/software.zeek @load protocols/rdp/indicate_ssl.zeek -#@load protocols/smb/__load__.zeek @load protocols/smb/log-cmds.zeek @load protocols/smtp/blocklists.zeek @load protocols/smtp/detect-suspicious-orig.zeek diff --git a/scripts/zeexygen/README b/scripts/zeekygen/README similarity index 77% rename from scripts/zeexygen/README rename to scripts/zeekygen/README index f099b09833..94982b0730 100644 --- a/scripts/zeexygen/README +++ b/scripts/zeekygen/README @@ -1,4 +1,4 @@ This package is loaded during the process which automatically generates -reference documentation for all Zeek scripts (i.e. "Zeexygen"). Its only +reference documentation for all Zeek scripts (i.e. "Zeekygen"). Its only purpose is to provide an easy way to load all known Zeek scripts plus any extra scripts needed or used by the documentation process. diff --git a/scripts/zeexygen/__load__.zeek b/scripts/zeekygen/__load__.zeek similarity index 89% rename from scripts/zeexygen/__load__.zeek rename to scripts/zeekygen/__load__.zeek index d074fe3660..00555c57bd 100644 --- a/scripts/zeexygen/__load__.zeek +++ b/scripts/zeekygen/__load__.zeek @@ -6,7 +6,6 @@ @load frameworks/control/controller.zeek @load frameworks/files/extract-all-files.zeek @load policy/misc/dump-events.zeek -@load policy/protocols/smb/__load__.zeek @load ./example.zeek diff --git a/scripts/zeexygen/example.zeek b/scripts/zeekygen/example.zeek similarity index 90% rename from scripts/zeexygen/example.zeek rename to scripts/zeekygen/example.zeek index 69affed96a..1fcdd8390b 100644 --- a/scripts/zeexygen/example.zeek +++ b/scripts/zeekygen/example.zeek @@ -1,4 +1,4 @@ -##! This is an example script that demonstrates Zeexygen-style +##! This is an example script that demonstrates Zeekygen-style ##! documentation. It generally will make most sense when viewing ##! the script's raw source code and comparing to the HTML-rendered ##! version. @@ -13,12 +13,12 @@ ##! There's also a custom role to reference any identifier node in ##! the Zeek Sphinx domain that's good for "see alsos", e.g. ##! -##! See also: :zeek:see:`ZeexygenExample::a_var`, -##! :zeek:see:`ZeexygenExample::ONE`, :zeek:see:`SSH::Info` +##! See also: :zeek:see:`ZeekygenExample::a_var`, +##! :zeek:see:`ZeekygenExample::ONE`, :zeek:see:`SSH::Info` ##! ##! And a custom directive does the equivalent references: ##! -##! .. zeek:see:: ZeexygenExample::a_var ZeexygenExample::ONE SSH::Info +##! .. zeek:see:: ZeekygenExample::a_var ZeekygenExample::ONE SSH::Info # Comments that use a single pound sign (#) are not significant to # a script's auto-generated documentation, but ones that use a @@ -30,7 +30,7 @@ # variable declarations to associate with the last-declared identifier. # # Generally, the auto-doc comments (##) are associated with the -# next declaration/identifier found in the script, but Zeexygen +# next declaration/identifier found in the script, but Zeekygen # will track/render identifiers regardless of whether they have any # of these special comments associated with them. # @@ -49,19 +49,19 @@ # "module" statements are self-documenting, don't use any ``##`` style # comments with them. -module ZeexygenExample; +module ZeekygenExample; # Redefinitions of "Notice::Type" are self-documenting, but # more information can be supplied in two different ways. redef enum Notice::Type += { ## Any number of this type of comment - ## will document "Zeexygen_One". - Zeexygen_One, - Zeexygen_Two, ##< Any number of this type of comment - ##< will document "ZEEXYGEN_TWO". - Zeexygen_Three, + ## will document "Zeekygen_One". + Zeekygen_One, + Zeekygen_Two, ##< Any number of this type of comment + ##< will document "ZEEKYGEN_TWO". + Zeekygen_Three, ## Omitting comments is fine, and so is mixing ``##`` and ``##<``, but - Zeexygen_Four, ##< it's probably best to use only one style consistently. + Zeekygen_Four, ##< it's probably best to use only one style consistently. }; # All redefs are automatically tracked. Comments of the "##" form can be use @@ -110,7 +110,7 @@ export { type ComplexRecord: record { field1: count; ##< Counts something. field2: bool; ##< Toggles something. - field3: SimpleRecord; ##< Zeexygen automatically tracks types + field3: SimpleRecord; ##< Zeekygen automatically tracks types ##< and cross-references are automatically ##< inserted in to generated docs. msg: string &default="blah"; ##< Attributes are self-documenting. @@ -163,9 +163,9 @@ export { ## Summarize "an_event" here. ## Give more details about "an_event" here. ## - ## ZeexygenExample::a_function should not be confused as a parameter + ## ZeekygenExample::a_function should not be confused as a parameter ## in the generated docs, but it also doesn't generate a cross-reference - ## link. Use the see role instead: :zeek:see:`ZeexygenExample::a_function`. + ## link. Use the see role instead: :zeek:see:`ZeekygenExample::a_function`. ## ## name: Describe the argument here. global an_event: event(name: string); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b15bc1fd36..f09d0d224e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -143,7 +143,7 @@ set(bro_PLUGIN_LIBS CACHE INTERNAL "plugin libraries" FORCE) add_subdirectory(analyzer) add_subdirectory(broker) -add_subdirectory(zeexygen) +add_subdirectory(zeekygen) add_subdirectory(file_analysis) add_subdirectory(input) add_subdirectory(iosource) diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index baddd2bdd8..8df6a5ef55 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -18,7 +18,7 @@ DebugLogger::Stream DebugLogger::streams[NUM_DBGS] = { { "dpd", 0, false }, { "tm", 0, false }, { "logging", 0, false }, {"input", 0, false }, { "threading", 0, false }, { "file_analysis", 0, false }, - { "plugins", 0, false }, { "zeexygen", 0, false }, + { "plugins", 0, false }, { "zeekygen", 0, false }, { "pktio", 0, false }, { "broker", 0, false }, { "scripts", 0, false} }; diff --git a/src/DebugLogger.h b/src/DebugLogger.h index 8026e8ba3c..dab9fd9758 100644 --- a/src/DebugLogger.h +++ b/src/DebugLogger.h @@ -30,7 +30,7 @@ enum DebugStream { DBG_THREADING, // Threading system DBG_FILE_ANALYSIS, // File analysis DBG_PLUGINS, // Plugin system - DBG_ZEEXYGEN, // Zeexygen + DBG_ZEEKYGEN, // Zeekygen DBG_PKTIO, // Packet sources and dumpers. DBG_BROKER, // Broker communication DBG_SCRIPTS, // Script initialization diff --git a/src/ID.cc b/src/ID.cc index 71f7d5f008..b9b0a5a624 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -12,7 +12,7 @@ #include "Serializer.h" #include "Scope.h" #include "Traverse.h" -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export) { @@ -632,7 +632,7 @@ void ID::DescribeReSTShort(ODesc* d) const if ( is_type ) d->Add(type_name(t)); else - d->Add(zeexygen_mgr->GetEnumTypeName(Name()).c_str()); + d->Add(zeekygen_mgr->GetEnumTypeName(Name()).c_str()); break; default: diff --git a/src/IPAddr.cc b/src/IPAddr.cc index 7917e82c29..c215b463b9 100644 --- a/src/IPAddr.cc +++ b/src/IPAddr.cc @@ -101,38 +101,44 @@ void IPAddr::ReverseMask(int top_bits_to_chop) p[i] &= mask_bits[i]; } -void IPAddr::Init(const std::string& s) +bool IPAddr::ConvertString(const char* s, in6_addr* result) { - if ( s.find(':') == std::string::npos ) // IPv4. + for ( auto p = s; *p; ++p ) + if ( *p == ':' ) + // IPv6 + return (inet_pton(AF_INET6, s, result->s6_addr) == 1); + + // IPv4 + // Parse the address directly instead of using inet_pton since + // some platforms have more sensitive implementations than others + // that can't e.g. handle leading zeroes. + int a[4]; + int n = 0; + int match_count = sscanf(s, "%d.%d.%d.%d%n", a+0, a+1, a+2, a+3, &n); + + if ( match_count != 4 ) + return false; + + if ( s[n] != '\0' ) + return false; + + for ( auto i = 0; i < 4; ++i ) + if ( a[i] < 0 || a[i] > 255 ) + return false; + + uint32_t addr = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; + addr = htonl(addr); + memcpy(result->s6_addr, v4_mapped_prefix, sizeof(v4_mapped_prefix)); + memcpy(&result->s6_addr[12], &addr, sizeof(uint32_t)); + return true; + } + +void IPAddr::Init(const char* s) + { + if ( ! ConvertString(s, &in6) ) { - memcpy(in6.s6_addr, v4_mapped_prefix, sizeof(v4_mapped_prefix)); - - // Parse the address directly instead of using inet_pton since - // some platforms have more sensitive implementations than others - // that can't e.g. handle leading zeroes. - int a[4]; - int n = sscanf(s.c_str(), "%d.%d.%d.%d", a+0, a+1, a+2, a+3); - - if ( n != 4 || a[0] < 0 || a[1] < 0 || a[2] < 0 || a[3] < 0 || - a[0] > 255 || a[1] > 255 || a[2] > 255 || a[3] > 255 ) - { - reporter->Error("Bad IP address: %s", s.c_str()); - memset(in6.s6_addr, 0, sizeof(in6.s6_addr)); - return; - } - - uint32_t addr = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; - addr = htonl(addr); - memcpy(&in6.s6_addr[12], &addr, sizeof(uint32_t)); - } - - else - { - if ( inet_pton(AF_INET6, s.c_str(), in6.s6_addr) <=0 ) - { - reporter->Error("Bad IP address: %s", s.c_str()); - memset(in6.s6_addr, 0, sizeof(in6.s6_addr)); - } + reporter->Error("Bad IP address: %s", s); + memset(in6.s6_addr, 0, sizeof(in6.s6_addr)); } } diff --git a/src/IPAddr.h b/src/IPAddr.h index 8ff258a860..1fdff9d979 100644 --- a/src/IPAddr.h +++ b/src/IPAddr.h @@ -68,7 +68,7 @@ public: */ IPAddr(const std::string& s) { - Init(s); + Init(s.data()); } /** @@ -366,6 +366,29 @@ public: unsigned int MemoryAllocation() const { return padded_sizeof(*this); } + /** + * Converts an IPv4 or IPv6 string into a network address structure + * (IPv6 or v4-to-v6-mapping in network bytes order). + * + * @param s the IPv4 or IPv6 string to convert (ASCII, NUL-terminated). + * + * @param result buffer that the caller supplies to store the result. + * + * @return whether the conversion was successful. + */ + static bool ConvertString(const char* s, in6_addr* result); + + /** + * @param s the IPv4 or IPv6 string to convert (ASCII, NUL-terminated). + * + * @return whether the string is a valid IP address + */ + static bool IsValid(const char* s) + { + in6_addr tmp; + return ConvertString(s, &tmp); + } + private: friend class IPPrefix; @@ -373,9 +396,9 @@ private: * Initializes an address instance from a string representation. * * @param s String containing an IP address as either a dotted IPv4 - * address or a hex IPv6 address. + * address or a hex IPv6 address (ASCII, NUL-terminated). */ - void Init(const std::string& s); + void Init(const char* s); in6_addr in6; // IPv6 or v4-to-v6-mapped address diff --git a/src/Type.cc b/src/Type.cc index 78c75a12df..19bed81412 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -8,8 +8,8 @@ #include "Scope.h" #include "Serializer.h" #include "Reporter.h" -#include "zeexygen/Manager.h" -#include "zeexygen/utils.h" +#include "zeekygen/Manager.h" +#include "zeekygen/utils.h" #include #include @@ -1197,8 +1197,8 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const if ( func_args ) continue; - using zeexygen::IdentifierInfo; - IdentifierInfo* doc = zeexygen_mgr->GetIdentifierInfo(GetName()); + using zeekygen::IdentifierInfo; + IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(GetName()); if ( ! doc ) { @@ -1217,7 +1217,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const field_from_script != type_from_script ) { d->PushIndent(); - d->Add(zeexygen::redef_indication(field_from_script).c_str()); + d->Add(zeekygen::redef_indication(field_from_script).c_str()); d->PopIndent(); } @@ -1237,7 +1237,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const { string s = cmnts[i]; - if ( zeexygen::prettify_params(s) ) + if ( zeekygen::prettify_params(s) ) d->NL(); d->Add(s.c_str()); @@ -1505,7 +1505,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, if ( deprecated ) id->MakeDeprecated(); - zeexygen_mgr->Identifier(id); + zeekygen_mgr->Identifier(id); } else { @@ -1618,8 +1618,8 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const else d->Add(fmt(".. zeek:enum:: %s %s", it->second.c_str(), GetName().c_str())); - using zeexygen::IdentifierInfo; - IdentifierInfo* doc = zeexygen_mgr->GetIdentifierInfo(it->second); + using zeekygen::IdentifierInfo; + IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(it->second); if ( ! doc ) { @@ -1634,7 +1634,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const if ( doc->GetDeclaringScript() ) enum_from_script = doc->GetDeclaringScript()->Name(); - IdentifierInfo* type_doc = zeexygen_mgr->GetIdentifierInfo(GetName()); + IdentifierInfo* type_doc = zeekygen_mgr->GetIdentifierInfo(GetName()); if ( type_doc && type_doc->GetDeclaringScript() ) type_from_script = type_doc->GetDeclaringScript()->Name(); @@ -1644,7 +1644,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const { d->NL(); d->PushIndent(); - d->Add(zeexygen::redef_indication(enum_from_script).c_str()); + d->Add(zeekygen::redef_indication(enum_from_script).c_str()); d->PopIndent(); } diff --git a/src/bro.bif b/src/bro.bif index a4afb44577..c3a9f13d56 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -2409,6 +2409,19 @@ function to_addr%(ip: string%): addr return ret; %} +## Checks if a string is a valid IPv4 or IPv6 address. +## +## ip: the string to check for valid IP formatting. +## +## Returns: T if the string is a valid IPv4 or IPv6 address format. +function is_valid_ip%(ip: string%): bool + %{ + char* s = ip->AsString()->Render(); + auto rval = IPAddr::IsValid(s); + delete [] s; + return val_mgr->GetBool(rval); + %} + ## Converts a :zeek:type:`string` to a :zeek:type:`subnet`. ## ## sn: The subnet to convert. @@ -3293,7 +3306,7 @@ const char* conn_id_string(Val* c) ## ## Returns: True on success. ## -## .. zeek:see:: dump_packet get_current_packet send_current_packet +## .. zeek:see:: dump_packet get_current_packet function dump_current_packet%(file_name: string%) : bool %{ const Packet* pkt; @@ -3324,7 +3337,7 @@ function dump_current_packet%(file_name: string%) : bool ## Returns: The currently processed packet, which is a record ## containing the timestamp, ``snaplen``, and packet data. ## -## .. zeek:see:: dump_current_packet dump_packet send_current_packet +## .. zeek:see:: dump_current_packet dump_packet function get_current_packet%(%) : pcap_packet %{ const Packet* p; @@ -3380,7 +3393,7 @@ function get_current_packet_header%(%) : raw_pkt_hdr ## ## Returns: True on success ## -## .. zeek:see:: get_current_packet dump_current_packet send_current_packet +## .. zeek:see:: get_current_packet dump_current_packet function dump_packet%(pkt: pcap_packet, file_name: string%) : bool %{ if ( addl_pkt_dumper && addl_pkt_dumper->Path() != file_name->CheckString()) diff --git a/src/main.cc b/src/main.cc index 450e242b3c..c9e32ab4b4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -53,7 +53,7 @@ extern "C" { #include "analyzer/Tag.h" #include "plugin/Manager.h" #include "file_analysis/Manager.h" -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" #include "iosource/Manager.h" #include "broker/Manager.h" @@ -89,7 +89,7 @@ input::Manager* input_mgr = 0; plugin::Manager* plugin_mgr = 0; analyzer::Manager* analyzer_mgr = 0; file_analysis::Manager* file_mgr = 0; -zeexygen::Manager* zeexygen_mgr = 0; +zeekygen::Manager* zeekygen_mgr = 0; iosource::Manager* iosource_mgr = 0; bro_broker::Manager* broker_mgr = 0; @@ -188,7 +188,7 @@ void usage(int code = 1) fprintf(stderr, " -T|--re-level | set 'RE_level' for rules\n"); fprintf(stderr, " -U|--status-file | Record process status in file\n"); fprintf(stderr, " -W|--watchdog | activate watchdog timer\n"); - fprintf(stderr, " -X|--zeexygen | generate documentation based on config file\n"); + fprintf(stderr, " -X|--zeekygen | generate documentation based on config file\n"); #ifdef USE_PERFTOOLS_DEBUG fprintf(stderr, " -m|--mem-leaks | show leaks [perftools]\n"); @@ -208,7 +208,7 @@ void usage(int code = 1) fprintf(stderr, " $BRO_SEED_FILE | file to load seeds from (not set)\n"); fprintf(stderr, " $BRO_LOG_SUFFIX | ASCII log file extension (.%s)\n", logging::writer::Ascii::LogExt().c_str()); fprintf(stderr, " $BRO_PROFILER_FILE | Output file for script execution statistics (not set)\n"); - fprintf(stderr, " $BRO_DISABLE_BROXYGEN | Disable Zeexygen documentation support (%s)\n", getenv("BRO_DISABLE_BROXYGEN") ? "set" : "not set"); + fprintf(stderr, " $BRO_DISABLE_BROXYGEN | Disable Zeekygen documentation support (%s)\n", getenv("BRO_DISABLE_BROXYGEN") ? "set" : "not set"); fprintf(stderr, " $ZEEK_DNS_RESOLVER | IPv4/IPv6 address of DNS resolver to use (%s)\n", getenv("ZEEK_DNS_RESOLVER") ? getenv("ZEEK_DNS_RESOLVER") : "not set, will use first IPv4 address from /etc/resolv.conf"); fprintf(stderr, "\n"); @@ -351,7 +351,7 @@ void terminate_bro() plugin_mgr->FinishPlugins(); - delete zeexygen_mgr; + delete zeekygen_mgr; delete timer_mgr; delete event_serializer; delete state_serializer; @@ -448,7 +448,7 @@ int main(int argc, char** argv) {"filter", required_argument, 0, 'f'}, {"help", no_argument, 0, 'h'}, {"iface", required_argument, 0, 'i'}, - {"zeexygen", required_argument, 0, 'X'}, + {"zeekygen", required_argument, 0, 'X'}, {"prefix", required_argument, 0, 'p'}, {"readfile", required_argument, 0, 'r'}, {"rulefile", required_argument, 0, 's'}, @@ -500,7 +500,7 @@ int main(int argc, char** argv) if ( p ) add_to_name_list(p, ':', prefixes); - string zeexygen_config; + string zeekygen_config; #ifdef USE_IDMEF string libidmef_dtd_path = "idmef-message.dtd"; @@ -649,7 +649,7 @@ int main(int argc, char** argv) break; case 'X': - zeexygen_config = optarg; + zeekygen_config = optarg; break; #ifdef USE_PERFTOOLS_DEBUG @@ -731,7 +731,7 @@ int main(int argc, char** argv) timer_mgr = new PQ_TimerMgr(""); // timer_mgr = new CQ_TimerMgr(); - zeexygen_mgr = new zeexygen::Manager(zeexygen_config, bro_argv[0]); + zeekygen_mgr = new zeekygen::Manager(zeekygen_config, bro_argv[0]); add_essential_input_file("base/init-bare.zeek"); add_essential_input_file("base/init-frameworks-and-bifs.zeek"); @@ -780,7 +780,7 @@ int main(int argc, char** argv) plugin_mgr->InitPreScript(); analyzer_mgr->InitPreScript(); file_mgr->InitPreScript(); - zeexygen_mgr->InitPreScript(); + zeekygen_mgr->InitPreScript(); bool missing_plugin = false; @@ -849,7 +849,7 @@ int main(int argc, char** argv) exit(1); plugin_mgr->InitPostScript(); - zeexygen_mgr->InitPostScript(); + zeekygen_mgr->InitPostScript(); broker_mgr->InitPostScript(); if ( print_plugins ) @@ -879,7 +879,7 @@ int main(int argc, char** argv) } reporter->InitOptions(); - zeexygen_mgr->GenerateDocs(); + zeekygen_mgr->GenerateDocs(); if ( user_pcap_filter ) { diff --git a/src/parse.y b/src/parse.y index e53f2a3054..13c15cad8f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -87,7 +87,7 @@ #include "Scope.h" #include "Reporter.h" #include "Brofiler.h" -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" #include #include @@ -1038,7 +1038,7 @@ type_decl: $$ = new TypeDecl($3, $1, $4, (in_record > 0)); if ( in_record > 0 && cur_decl_type_id ) - zeexygen_mgr->RecordField(cur_decl_type_id, $$, ::filename); + zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename); } ; @@ -1072,7 +1072,7 @@ decl: TOK_MODULE TOK_ID ';' { current_module = $2; - zeexygen_mgr->ModuleUsage(::filename, current_module); + zeekygen_mgr->ModuleUsage(::filename, current_module); } | TOK_EXPORT '{' { is_export = true; } decl_list '}' @@ -1081,36 +1081,36 @@ decl: | TOK_GLOBAL def_global_id opt_type init_class opt_init opt_attr ';' { add_global($2, $3, $4, $5, $6, VAR_REGULAR); - zeexygen_mgr->Identifier($2); + zeekygen_mgr->Identifier($2); } | TOK_OPTION def_global_id opt_type init_class opt_init opt_attr ';' { add_global($2, $3, $4, $5, $6, VAR_OPTION); - zeexygen_mgr->Identifier($2); + zeekygen_mgr->Identifier($2); } | TOK_CONST def_global_id opt_type init_class opt_init opt_attr ';' { add_global($2, $3, $4, $5, $6, VAR_CONST); - zeexygen_mgr->Identifier($2); + zeekygen_mgr->Identifier($2); } | TOK_REDEF global_id opt_type init_class opt_init opt_attr ';' { add_global($2, $3, $4, $5, $6, VAR_REDEF); - zeexygen_mgr->Redef($2, ::filename); + zeekygen_mgr->Redef($2, ::filename); } | TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{' - { parser_redef_enum($3); zeexygen_mgr->Redef($3, ::filename); } + { parser_redef_enum($3); zeekygen_mgr->Redef($3, ::filename); } enum_body '}' ';' { - // Zeexygen already grabbed new enum IDs as the type created them. + // Zeekygen already grabbed new enum IDs as the type created them. } | TOK_REDEF TOK_RECORD global_id - { cur_decl_type_id = $3; zeexygen_mgr->Redef($3, ::filename); } + { cur_decl_type_id = $3; zeekygen_mgr->Redef($3, ::filename); } TOK_ADD_TO '{' { ++in_record; } type_decl_list @@ -1126,12 +1126,12 @@ decl: } | TOK_TYPE global_id ':' - { cur_decl_type_id = $2; zeexygen_mgr->StartType($2); } + { cur_decl_type_id = $2; zeekygen_mgr->StartType($2); } type opt_attr ';' { cur_decl_type_id = 0; add_type($2, $5, $6); - zeexygen_mgr->Identifier($2); + zeekygen_mgr->Identifier($2); } | func_hdr func_body @@ -1166,7 +1166,7 @@ func_hdr: begin_func($2, current_module.c_str(), FUNC_FLAVOR_FUNCTION, 0, $3, $4); $$ = $3; - zeexygen_mgr->Identifier($2); + zeekygen_mgr->Identifier($2); } | TOK_EVENT event_id func_params opt_attr { diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index 22bd2dd302..399c704551 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -10,7 +10,7 @@ #include "Var.h" #include "Val.h" #include "Reporter.h" -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" namespace plugin { @@ -134,7 +134,7 @@ ComponentManager::ComponentManager(const string& arg_module, const string& tag_enum_type = new EnumType(module + "::" + local_id); ::ID* id = install_ID(local_id.c_str(), module.c_str(), true, true); add_type(id, tag_enum_type, 0); - zeexygen_mgr->Identifier(id); + zeekygen_mgr->Identifier(id); } template diff --git a/src/scan.l b/src/scan.l index 40ca523daf..21b3e0dcf4 100644 --- a/src/scan.l +++ b/src/scan.l @@ -29,7 +29,7 @@ #include "Traverse.h" #include "analyzer/Analyzer.h" -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" #include "plugin/Manager.h" @@ -162,19 +162,19 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+)) %% ##!.* { - zeexygen_mgr->SummaryComment(::filename, yytext + 3); + zeekygen_mgr->SummaryComment(::filename, yytext + 3); } ##<.* { string hint(cur_enum_type && last_id_tok ? make_full_var_name(current_module.c_str(), last_id_tok) : ""); - zeexygen_mgr->PostComment(yytext + 3, hint); + zeekygen_mgr->PostComment(yytext + 3, hint); } ##.* { if ( yytext[2] != '#' ) - zeexygen_mgr->PreComment(yytext + 2); + zeekygen_mgr->PreComment(yytext + 2); } #{OWS}@no-test.* return TOK_NO_TEST; @@ -365,7 +365,7 @@ when return TOK_WHEN; string loader = ::filename; // load_files may change ::filename, save copy string loading = find_relative_script_file(new_file); (void) load_files(new_file); - zeexygen_mgr->ScriptDependency(loader, loading); + zeekygen_mgr->ScriptDependency(loader, loading); } @load-sigs{WS}{FILE} { @@ -709,7 +709,7 @@ static int load_files(const char* orig_file) else file_stack.append(new FileInfo); - zeexygen_mgr->Script(file_path); + zeekygen_mgr->Script(file_path); DBG_LOG(DBG_SCRIPTS, "Loading %s", file_path.c_str()); diff --git a/src/util.cc b/src/util.cc index 0367700ffb..8a8f733223 100644 --- a/src/util.cc +++ b/src/util.cc @@ -53,11 +53,13 @@ #include "iosource/Manager.h" /** - * Return IP address without enclosing brackets and any leading 0x. + * Return IP address without enclosing brackets and any leading 0x. Also + * trims leading/trailing whitespace. */ std::string extract_ip(const std::string& i) { - std::string s(skip_whitespace(i.c_str())); + std::string s(strstrip(i)); + if ( s.size() > 0 && s[0] == '[' ) s.erase(0, 1); diff --git a/src/zeexygen/CMakeLists.txt b/src/zeekygen/CMakeLists.txt similarity index 73% rename from src/zeexygen/CMakeLists.txt rename to src/zeekygen/CMakeLists.txt index 43060866a9..de50378f5a 100644 --- a/src/zeexygen/CMakeLists.txt +++ b/src/zeekygen/CMakeLists.txt @@ -7,7 +7,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} ) -set(zeexygen_SRCS +set(zeekygen_SRCS Manager.cc Info.h PackageInfo.cc @@ -19,7 +19,7 @@ set(zeexygen_SRCS utils.cc ) -bif_target(zeexygen.bif) -bro_add_subdir_library(zeexygen ${zeexygen_SRCS}) +bif_target(zeekygen.bif) +bro_add_subdir_library(zeekygen ${zeekygen_SRCS}) -add_dependencies(bro_zeexygen generate_outputs) +add_dependencies(bro_zeekygen generate_outputs) diff --git a/src/zeexygen/Configuration.cc b/src/zeekygen/Configuration.cc similarity index 87% rename from src/zeexygen/Configuration.cc rename to src/zeekygen/Configuration.cc index 7b1f5e35fd..dbbbebf578 100644 --- a/src/zeexygen/Configuration.cc +++ b/src/zeekygen/Configuration.cc @@ -11,7 +11,7 @@ #include #include -using namespace zeexygen; +using namespace zeekygen; using namespace std; static TargetFactory create_target_factory() @@ -37,7 +37,7 @@ Config::Config(const string& arg_file, const string& delim) ifstream f(file.c_str()); if ( ! f.is_open() ) - reporter->FatalError("failed to open Zeexygen config file '%s': %s", + reporter->FatalError("failed to open Zeekygen config file '%s': %s", file.c_str(), strerror(errno)); string line; @@ -59,20 +59,20 @@ Config::Config(const string& arg_file, const string& delim) continue; if ( tokens.size() != 3 ) - reporter->FatalError("malformed Zeexygen target in %s:%u: %s", + reporter->FatalError("malformed Zeekygen target in %s:%u: %s", file.c_str(), line_number, line.c_str()); Target* target = target_factory.Create(tokens[0], tokens[2], tokens[1]); if ( ! target ) - reporter->FatalError("unknown Zeexygen target type: %s", + reporter->FatalError("unknown Zeekygen target type: %s", tokens[0].c_str()); targets.push_back(target); } if ( f.bad() ) - reporter->InternalError("error reading Zeexygen config file '%s': %s", + reporter->InternalError("error reading Zeekygen config file '%s': %s", file.c_str(), strerror(errno)); } @@ -99,5 +99,5 @@ time_t Config::GetModificationTime() const if ( file.empty() ) return 0; - return zeexygen::get_mtime(file); + return zeekygen::get_mtime(file); } diff --git a/src/zeexygen/Configuration.h b/src/zeekygen/Configuration.h similarity index 80% rename from src/zeexygen/Configuration.h rename to src/zeekygen/Configuration.h index a0da9761bc..97ca125275 100644 --- a/src/zeexygen/Configuration.h +++ b/src/zeekygen/Configuration.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_CONFIGURATION_H -#define ZEEXYGEN_CONFIGURATION_H +#ifndef ZEEKYGEN_CONFIGURATION_H +#define ZEEKYGEN_CONFIGURATION_H #include "Info.h" #include "Target.h" @@ -9,7 +9,7 @@ #include #include -namespace zeexygen { +namespace zeekygen { /** * Manages the generation of reStructuredText documents corresponding to @@ -22,8 +22,8 @@ class Config { public: /** - * Read a Zeexygen configuration file, parsing all targets in it. - * @param file The file containing a list of Zeexygen targets. If it's + * Read a Zeekygen configuration file, parsing all targets in it. + * @param file The file containing a list of Zeekygen targets. If it's * an empty string most methods are a no-op. * @param delim The delimiter between target fields. */ @@ -41,7 +41,7 @@ public: void FindDependencies(const std::vector& infos); /** - * Build each Zeexygen target (i.e. write out the reST documents to disk). + * Build each Zeekygen target (i.e. write out the reST documents to disk). */ void GenerateDocs() const; @@ -58,6 +58,6 @@ private: TargetFactory target_factory; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/IdentifierInfo.cc b/src/zeekygen/IdentifierInfo.cc similarity index 97% rename from src/zeexygen/IdentifierInfo.cc rename to src/zeekygen/IdentifierInfo.cc index ebb15373bf..5c494799b4 100644 --- a/src/zeexygen/IdentifierInfo.cc +++ b/src/zeekygen/IdentifierInfo.cc @@ -7,7 +7,7 @@ #include "Val.h" using namespace std; -using namespace zeexygen; +using namespace zeekygen; IdentifierInfo::IdentifierInfo(ID* arg_id, ScriptInfo* script) : Info(), @@ -128,7 +128,7 @@ string IdentifierInfo::DoReStructuredText(bool roles_only) const { string s = comments[i]; - if ( zeexygen::prettify_params(s) ) + if ( zeekygen::prettify_params(s) ) d.NL(); d.Add(s.c_str()); diff --git a/src/zeexygen/IdentifierInfo.h b/src/zeekygen/IdentifierInfo.h similarity index 92% rename from src/zeexygen/IdentifierInfo.h rename to src/zeekygen/IdentifierInfo.h index a930f67feb..868dd3781b 100644 --- a/src/zeexygen/IdentifierInfo.h +++ b/src/zeekygen/IdentifierInfo.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_IDENTIFIERINFO_H -#define ZEEXYGEN_IDENTIFIERINFO_H +#ifndef ZEEKYGEN_IDENTIFIERINFO_H +#define ZEEKYGEN_IDENTIFIERINFO_H #include "Info.h" #include "ScriptInfo.h" @@ -14,7 +14,7 @@ #include #include -namespace zeexygen { +namespace zeekygen { class ScriptInfo; @@ -42,7 +42,7 @@ public: * Add a comment associated with the identifier. If the identifier is a * record type and it's in the middle of parsing fields, the comment is * associated with the last field that was parsed. - * @param comment A string extracted from Zeexygen-style comment. + * @param comment A string extracted from Zeekygen-style comment. */ void AddComment(const std::string& comment) { last_field_seen ? last_field_seen->comments.push_back(comment) @@ -102,13 +102,13 @@ public: std::string GetDeclaringScriptForField(const std::string& field) const; /** - * @return All Zeexygen comments associated with the identifier. + * @return All Zeekygen comments associated with the identifier. */ std::vector GetComments() const; /** * @param field A record field name. - * @return All Zeexygen comments associated with the record field. + * @return All Zeekygen comments associated with the record field. */ std::vector GetFieldComments(const std::string& field) const; @@ -118,7 +118,7 @@ public: struct Redefinition { std::string from_script; /**< Name of script doing the redef. */ std::string new_val_desc; /**< Description of new value bound to ID. */ - std::vector comments; /**< Zeexygen comments on redef. */ + std::vector comments; /**< Zeekygen comments on redef. */ }; /** @@ -159,6 +159,6 @@ private: ScriptInfo* declaring_script; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/Info.h b/src/zeekygen/Info.h similarity index 89% rename from src/zeexygen/Info.h rename to src/zeekygen/Info.h index 46fba7b7b6..f6e09cb498 100644 --- a/src/zeexygen/Info.h +++ b/src/zeekygen/Info.h @@ -1,15 +1,15 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_INFO_H -#define ZEEXYGEN_INFO_H +#ifndef ZEEKYGEN_INFO_H +#define ZEEKYGEN_INFO_H #include #include -namespace zeexygen { +namespace zeekygen { /** - * Abstract base class for any thing that Zeexygen can document. + * Abstract base class for any thing that Zeekygen can document. */ class Info { @@ -68,6 +68,6 @@ private: { } }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/Manager.cc b/src/zeekygen/Manager.cc similarity index 87% rename from src/zeexygen/Manager.cc rename to src/zeekygen/Manager.cc index d638705d8b..5cddac0901 100644 --- a/src/zeexygen/Manager.cc +++ b/src/zeekygen/Manager.cc @@ -7,7 +7,7 @@ #include #include -using namespace zeexygen; +using namespace zeekygen; using namespace std; static void DbgAndWarn(const char* msg) @@ -19,7 +19,7 @@ static void DbgAndWarn(const char* msg) return; reporter->Warning("%s", msg); - DBG_LOG(DBG_ZEEXYGEN, "%s", msg); + DBG_LOG(DBG_ZEEKYGEN, "%s", msg); } static void WarnMissingScript(const char* type, const ID* id, @@ -28,7 +28,7 @@ static void WarnMissingScript(const char* type, const ID* id, if ( script == "" ) return; - DbgAndWarn(fmt("Can't generate Zeexygen doumentation for %s %s, " + DbgAndWarn(fmt("Can't generate Zeekygen doumentation for %s %s, " "lookup of %s failed", type, id->Name(), script.c_str())); } @@ -83,7 +83,7 @@ Manager::Manager(const string& arg_config, const string& bro_command) // a PATH component that starts with a tilde (such as "~/bin"). A simple // workaround is to just run bro with a relative or absolute path. if ( path_to_bro.empty() || stat(path_to_bro.c_str(), &s) < 0 ) - reporter->InternalError("Zeexygen can't get mtime of bro binary %s (try again by specifying the absolute or relative path to Bro): %s", + reporter->InternalError("Zeekygen can't get mtime of bro binary %s (try again by specifying the absolute or relative path to Bro): %s", path_to_bro.c_str(), strerror(errno)); bro_mtime = s.st_mtime; @@ -129,7 +129,7 @@ void Manager::Script(const string& path) if ( scripts.GetInfo(name) ) { - DbgAndWarn(fmt("Duplicate Zeexygen script documentation: %s", + DbgAndWarn(fmt("Duplicate Zeekygen script documentation: %s", name.c_str())); return; } @@ -137,7 +137,7 @@ void Manager::Script(const string& path) ScriptInfo* info = new ScriptInfo(name, path); scripts.map[name] = info; all_info.push_back(info); - DBG_LOG(DBG_ZEEXYGEN, "Made ScriptInfo %s", name.c_str()); + DBG_LOG(DBG_ZEEKYGEN, "Made ScriptInfo %s", name.c_str()); if ( ! info->IsPkgLoader() ) return; @@ -146,7 +146,7 @@ void Manager::Script(const string& path) if ( packages.GetInfo(name) ) { - DbgAndWarn(fmt("Duplicate Zeexygen package documentation: %s", + DbgAndWarn(fmt("Duplicate Zeekygen package documentation: %s", name.c_str())); return; } @@ -154,7 +154,7 @@ void Manager::Script(const string& path) PackageInfo* pkginfo = new PackageInfo(name); packages.map[name] = pkginfo; all_info.push_back(pkginfo); - DBG_LOG(DBG_ZEEXYGEN, "Made PackageInfo %s", name.c_str()); + DBG_LOG(DBG_ZEEKYGEN, "Made PackageInfo %s", name.c_str()); } void Manager::ScriptDependency(const string& path, const string& dep) @@ -164,7 +164,7 @@ void Manager::ScriptDependency(const string& path, const string& dep) if ( dep.empty() ) { - DbgAndWarn(fmt("Empty Zeexygen script doc dependency: %s", + DbgAndWarn(fmt("Empty Zeekygen script doc dependency: %s", path.c_str())); return; } @@ -175,17 +175,17 @@ void Manager::ScriptDependency(const string& path, const string& dep) if ( ! script_info ) { - DbgAndWarn(fmt("Failed to add Zeexygen script doc dependency %s " + DbgAndWarn(fmt("Failed to add Zeekygen script doc dependency %s " "for %s", depname.c_str(), name.c_str())); return; } script_info->AddDependency(depname); - DBG_LOG(DBG_ZEEXYGEN, "Added script dependency %s for %s", + DBG_LOG(DBG_ZEEKYGEN, "Added script dependency %s for %s", depname.c_str(), name.c_str()); for ( size_t i = 0; i < comment_buffer.size(); ++i ) - DbgAndWarn(fmt("Discarded extraneous Zeexygen comment: %s", + DbgAndWarn(fmt("Discarded extraneous Zeekygen comment: %s", comment_buffer[i].c_str())); } @@ -199,13 +199,13 @@ void Manager::ModuleUsage(const string& path, const string& module) if ( ! script_info ) { - DbgAndWarn(fmt("Failed to add Zeexygen module usage %s in %s", + DbgAndWarn(fmt("Failed to add Zeekygen module usage %s in %s", module.c_str(), name.c_str())); return; } script_info->AddModule(module); - DBG_LOG(DBG_ZEEXYGEN, "Added module usage %s in %s", + DBG_LOG(DBG_ZEEKYGEN, "Added module usage %s in %s", module.c_str(), name.c_str()); } @@ -246,7 +246,7 @@ void Manager::StartType(ID* id) if ( id->GetLocationInfo() == &no_location ) { - DbgAndWarn(fmt("Can't generate zeexygen doumentation for %s, " + DbgAndWarn(fmt("Can't generate zeekygen doumentation for %s, " "no location available", id->Name())); return; } @@ -261,7 +261,7 @@ void Manager::StartType(ID* id) } incomplete_type = CreateIdentifierInfo(id, script_info); - DBG_LOG(DBG_ZEEXYGEN, "Made IdentifierInfo (incomplete) %s, in %s", + DBG_LOG(DBG_ZEEKYGEN, "Made IdentifierInfo (incomplete) %s, in %s", id->Name(), script.c_str()); } @@ -279,7 +279,7 @@ void Manager::Identifier(ID* id) { if ( incomplete_type->Name() == id->Name() ) { - DBG_LOG(DBG_ZEEXYGEN, "Finished document for type %s", id->Name()); + DBG_LOG(DBG_ZEEKYGEN, "Finished document for type %s", id->Name()); incomplete_type->CompletedTypeDecl(); incomplete_type = 0; return; @@ -309,7 +309,7 @@ void Manager::Identifier(ID* id) { // Internally-created identifier (e.g. file/proto analyzer enum tags). // Handled specially since they don't have a script location. - DBG_LOG(DBG_ZEEXYGEN, "Made internal IdentifierInfo %s", + DBG_LOG(DBG_ZEEKYGEN, "Made internal IdentifierInfo %s", id->Name()); CreateIdentifierInfo(id, 0); return; @@ -325,7 +325,7 @@ void Manager::Identifier(ID* id) } CreateIdentifierInfo(id, script_info); - DBG_LOG(DBG_ZEEXYGEN, "Made IdentifierInfo %s, in script %s", + DBG_LOG(DBG_ZEEKYGEN, "Made IdentifierInfo %s, in script %s", id->Name(), script.c_str()); } @@ -339,7 +339,7 @@ void Manager::RecordField(const ID* id, const TypeDecl* field, if ( ! idd ) { - DbgAndWarn(fmt("Can't generate zeexygen doumentation for " + DbgAndWarn(fmt("Can't generate zeekygen doumentation for " "record field %s, unknown record: %s", field->id, id->Name())); return; @@ -348,7 +348,7 @@ void Manager::RecordField(const ID* id, const TypeDecl* field, string script = NormalizeScriptPath(path); idd->AddRecordField(field, script, comment_buffer); comment_buffer.clear(); - DBG_LOG(DBG_ZEEXYGEN, "Document record field %s, identifier %s, script %s", + DBG_LOG(DBG_ZEEKYGEN, "Document record field %s, identifier %s, script %s", field->id, id->Name(), script.c_str()); } @@ -365,7 +365,7 @@ void Manager::Redef(const ID* id, const string& path) if ( ! id_info ) { - DbgAndWarn(fmt("Can't generate zeexygen doumentation for " + DbgAndWarn(fmt("Can't generate zeekygen doumentation for " "redef of %s, identifier lookup failed", id->Name())); return; @@ -384,7 +384,7 @@ void Manager::Redef(const ID* id, const string& path) script_info->AddRedef(id_info); comment_buffer.clear(); last_identifier_seen = id_info; - DBG_LOG(DBG_ZEEXYGEN, "Added redef of %s from %s", + DBG_LOG(DBG_ZEEKYGEN, "Added redef of %s from %s", id->Name(), from_script.c_str()); } @@ -421,7 +421,7 @@ void Manager::PostComment(const string& comment, const string& id_hint) if ( last_identifier_seen ) last_identifier_seen->AddComment(RemoveLeadingSpace(comment)); else - DbgAndWarn(fmt("Discarded unassociated Zeexygen comment %s", + DbgAndWarn(fmt("Discarded unassociated Zeekygen comment %s", comment.c_str())); return; diff --git a/src/zeexygen/Manager.h b/src/zeekygen/Manager.h similarity index 89% rename from src/zeexygen/Manager.h rename to src/zeekygen/Manager.h index 5b2142e047..ad4d98f668 100644 --- a/src/zeexygen/Manager.h +++ b/src/zeekygen/Manager.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_MANAGER_H -#define ZEEXYGEN_MANAGER_H +#ifndef ZEEKYGEN_MANAGER_H +#define ZEEKYGEN_MANAGER_H #include "Configuration.h" #include "Info.h" @@ -21,7 +21,7 @@ #include #include -namespace zeexygen { +namespace zeekygen { /** * Map of info objects. Just a wrapper around std::map to improve code @@ -54,7 +54,7 @@ public: /** * Ctor. - * @param config Path to a Zeexygen config file if documentation is to be + * @param config Path to a Zeekygen config file if documentation is to be * written to disk. * @param bro_command The command used to invoke the bro process. * It's used when checking for out-of-date targets. If the bro binary is @@ -80,7 +80,7 @@ public: void InitPostScript(); /** - * Builds all Zeexygen targets specified by config file and write out + * Builds all Zeekygen targets specified by config file and write out * documentation to disk. */ void GenerateDocs() const; @@ -140,24 +140,24 @@ public: void Redef(const ID* id, const std::string& path); /** - * Register Zeexygen script summary content. + * Register Zeekygen script summary content. * @param path Absolute path to a Bro script. - * @param comment Zeexygen-style summary comment ("##!") to associate with + * @param comment Zeekygen-style summary comment ("##!") to associate with * script given by \a path. */ void SummaryComment(const std::string& path, const std::string& comment); /** - * Register a Zeexygen comment ("##") for an upcoming identifier (i.e. + * Register a Zeekygen comment ("##") for an upcoming identifier (i.e. * this content is buffered and consumed by next identifier/field * declaration. - * @param comment Content of the Zeexygen comment. + * @param comment Content of the Zeekygen comment. */ void PreComment(const std::string& comment); /** - * Register a Zeexygen comment ("##<") for the last identifier seen. - * @param comment Content of the Zeexygen comment. + * Register a Zeekygen comment ("##<") for the last identifier seen. + * @param comment Content of the Zeekygen comment. * @param identifier_hint Expected name of identifier with which to * associate \a comment. */ @@ -197,11 +197,11 @@ public: { return packages.GetInfo(name); } /** - * Check if a Zeexygen target is up-to-date. - * @param target_file output file of a Zeexygen target. + * Check if a Zeekygen target is up-to-date. + * @param target_file output file of a Zeekygen target. * @param dependencies all dependencies of the target. * @return true if modification time of \a target_file is newer than - * modification time of Bro binary, Zeexygen config file, and all + * modification time of Bro binary, Zeekygen config file, and all * dependencies, else false. */ template @@ -241,7 +241,7 @@ bool Manager::IsUpToDate(const string& target_file, // Doesn't exist. return false; - reporter->InternalError("Zeexygen failed to stat target file '%s': %s", + reporter->InternalError("Zeekygen failed to stat target file '%s': %s", target_file.c_str(), strerror(errno)); } @@ -258,8 +258,8 @@ bool Manager::IsUpToDate(const string& target_file, return true; } -} // namespace zeexygen +} // namespace zeekygen -extern zeexygen::Manager* zeexygen_mgr; +extern zeekygen::Manager* zeekygen_mgr; #endif diff --git a/src/zeexygen/PackageInfo.cc b/src/zeekygen/PackageInfo.cc similarity index 85% rename from src/zeexygen/PackageInfo.cc rename to src/zeekygen/PackageInfo.cc index 1fd607fd08..4fe1ba8ad9 100644 --- a/src/zeexygen/PackageInfo.cc +++ b/src/zeekygen/PackageInfo.cc @@ -9,7 +9,7 @@ #include using namespace std; -using namespace zeexygen; +using namespace zeekygen; PackageInfo::PackageInfo(const string& arg_name) : Info(), @@ -23,7 +23,7 @@ PackageInfo::PackageInfo(const string& arg_name) ifstream f(readme_file.c_str()); if ( ! f.is_open() ) - reporter->InternalWarning("Zeexygen failed to open '%s': %s", + reporter->InternalWarning("Zeekygen failed to open '%s': %s", readme_file.c_str(), strerror(errno)); string line; @@ -32,7 +32,7 @@ PackageInfo::PackageInfo(const string& arg_name) readme.push_back(line); if ( f.bad() ) - reporter->InternalWarning("Zeexygen error reading '%s': %s", + reporter->InternalWarning("Zeekygen error reading '%s': %s", readme_file.c_str(), strerror(errno)); } @@ -54,5 +54,5 @@ time_t PackageInfo::DoGetModificationTime() const if ( readme_file.empty() ) return 0; - return zeexygen::get_mtime(readme_file); + return zeekygen::get_mtime(readme_file); } diff --git a/src/zeexygen/PackageInfo.h b/src/zeekygen/PackageInfo.h similarity index 89% rename from src/zeexygen/PackageInfo.h rename to src/zeekygen/PackageInfo.h index 977f31fece..4db2718944 100644 --- a/src/zeexygen/PackageInfo.h +++ b/src/zeekygen/PackageInfo.h @@ -1,14 +1,14 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_PACKAGEINFO_H -#define ZEEXYGEN_PACKAGEINFO_H +#ifndef ZEEKYGEN_PACKAGEINFO_H +#define ZEEKYGEN_PACKAGEINFO_H #include "Info.h" #include #include -namespace zeexygen { +namespace zeekygen { /** * Information about a Bro script package. @@ -45,6 +45,6 @@ private: std::vector readme; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/ReStructuredTextTable.cc b/src/zeekygen/ReStructuredTextTable.cc similarity index 98% rename from src/zeexygen/ReStructuredTextTable.cc rename to src/zeekygen/ReStructuredTextTable.cc index c8306313e5..55c576a2a4 100644 --- a/src/zeexygen/ReStructuredTextTable.cc +++ b/src/zeekygen/ReStructuredTextTable.cc @@ -5,7 +5,7 @@ #include using namespace std; -using namespace zeexygen; +using namespace zeekygen; ReStructuredTextTable::ReStructuredTextTable(size_t arg_num_cols) : num_cols(arg_num_cols), rows(), longest_row_in_column() diff --git a/src/zeexygen/ReStructuredTextTable.h b/src/zeekygen/ReStructuredTextTable.h similarity index 92% rename from src/zeexygen/ReStructuredTextTable.h rename to src/zeekygen/ReStructuredTextTable.h index 9a4059ca83..aefa8aaa26 100644 --- a/src/zeexygen/ReStructuredTextTable.h +++ b/src/zeekygen/ReStructuredTextTable.h @@ -1,12 +1,12 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_RESTTABLE_H -#define ZEEXYGEN_RESTTABLE_H +#ifndef ZEEKYGEN_RESTTABLE_H +#define ZEEKYGEN_RESTTABLE_H #include #include -namespace zeexygen { +namespace zeekygen { /** * A reST table with arbitrary number of columns. @@ -48,6 +48,6 @@ private: std::vector longest_row_in_column; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc similarity index 86% rename from src/zeexygen/ScriptInfo.cc rename to src/zeekygen/ScriptInfo.cc index 47769c615a..d55b42b7bc 100644 --- a/src/zeexygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -10,7 +10,7 @@ #include "Desc.h" using namespace std; -using namespace zeexygen; +using namespace zeekygen; bool IdInfoComp::operator ()(const IdentifierInfo* lhs, const IdentifierInfo* rhs) const @@ -24,11 +24,11 @@ static vector summary_comment(const vector& cmnts) for ( size_t i = 0; i < cmnts.size(); ++i ) { - size_t end = zeexygen::end_of_first_sentence(cmnts[i]); + size_t end = zeekygen::end_of_first_sentence(cmnts[i]); if ( end == string::npos ) { - if ( zeexygen::is_all_whitespace(cmnts[i]) ) + if ( zeekygen::is_all_whitespace(cmnts[i]) ) break; rval.push_back(cmnts[i]); @@ -86,7 +86,7 @@ static string make_summary(const string& heading, char underline, char border, add_summary_rows(d, summary_comment((*it)->GetComments()), &table); } - return zeexygen::make_heading(heading, underline) + table.AsString(border) + return zeekygen::make_heading(heading, underline) + table.AsString(border) + "\n"; } @@ -115,7 +115,7 @@ static string make_redef_summary(const string& heading, char underline, add_summary_rows(d, summary_comment(iit->comments), &table); } - return zeexygen::make_heading(heading, underline) + table.AsString(border) + return zeekygen::make_heading(heading, underline) + table.AsString(border) + "\n"; } @@ -125,7 +125,7 @@ static string make_details(const string& heading, char underline, if ( id_list.empty() ) return ""; - string rval = zeexygen::make_heading(heading, underline); + string rval = zeekygen::make_heading(heading, underline); for ( id_info_list::const_iterator it = id_list.begin(); it != id_list.end(); ++it ) @@ -143,7 +143,7 @@ static string make_redef_details(const string& heading, char underline, if ( id_set.empty() ) return ""; - string rval = zeexygen::make_heading(heading, underline); + string rval = zeekygen::make_heading(heading, underline); for ( id_info_set::const_iterator it = id_set.begin(); it != id_set.end(); ++it ) @@ -178,13 +178,13 @@ void ScriptInfo::DoInitPostScript() IdentifierInfo* info = it->second; ID* id = info->GetID(); - if ( ! zeexygen::is_public_api(id) ) + if ( ! zeekygen::is_public_api(id) ) continue; if ( id->AsType() ) { types.push_back(info); - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a type", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a type", id->Name(), name.c_str()); continue; } @@ -193,17 +193,17 @@ void ScriptInfo::DoInitPostScript() { switch ( id->Type()->AsFuncType()->Flavor() ) { case FUNC_FLAVOR_HOOK: - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a hook", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a hook", id->Name(), name.c_str()); hooks.push_back(info); break; case FUNC_FLAVOR_EVENT: - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a event", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a event", id->Name(), name.c_str()); events.push_back(info); break; case FUNC_FLAVOR_FUNCTION: - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a function", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a function", id->Name(), name.c_str()); functions.push_back(info); break; @@ -219,13 +219,13 @@ void ScriptInfo::DoInitPostScript() { if ( id->FindAttr(ATTR_REDEF) ) { - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a redef_option", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option", id->Name(), name.c_str()); redef_options.push_back(info); } else { - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a constant", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a constant", id->Name(), name.c_str()); constants.push_back(info); } @@ -234,7 +234,7 @@ void ScriptInfo::DoInitPostScript() } else if ( id->IsOption() ) { - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as an runtime option", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as an runtime option", id->Name(), name.c_str()); options.push_back(info); @@ -246,7 +246,7 @@ void ScriptInfo::DoInitPostScript() // documentation. continue; - DBG_LOG(DBG_ZEEXYGEN, "Filter id '%s' in '%s' as a state variable", + DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a state variable", id->Name(), name.c_str()); state_vars.push_back(info); } @@ -275,7 +275,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const string rval; rval += ":tocdepth: 3\n\n"; - rval += zeexygen::make_heading(name, '='); + rval += zeekygen::make_heading(name, '='); for ( string_set::const_iterator it = module_usages.begin(); it != module_usages.end(); ++it ) @@ -329,7 +329,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const //rval += fmt(":Source File: :download:`/scripts/%s`\n", name.c_str()); rval += "\n"; - rval += zeexygen::make_heading("Summary", '~'); + rval += zeekygen::make_heading("Summary", '~'); rval += make_summary("Runtime Options", '#', '=', options); rval += make_summary("Redefinable Options", '#', '=', redef_options); rval += make_summary("Constants", '#', '=', constants); @@ -340,7 +340,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const rval += make_summary("Hooks", '#', '=', hooks); rval += make_summary("Functions", '#', '=', functions); rval += "\n"; - rval += zeexygen::make_heading("Detailed Interface", '~'); + rval += zeekygen::make_heading("Detailed Interface", '~'); rval += make_details("Runtime Options", '#', options); rval += make_details("Redefinable Options", '#', redef_options); rval += make_details("Constants", '#', constants); @@ -356,25 +356,25 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const time_t ScriptInfo::DoGetModificationTime() const { - time_t most_recent = zeexygen::get_mtime(path); + time_t most_recent = zeekygen::get_mtime(path); for ( string_set::const_iterator it = dependencies.begin(); it != dependencies.end(); ++it ) { - Info* info = zeexygen_mgr->GetScriptInfo(*it); + Info* info = zeekygen_mgr->GetScriptInfo(*it); if ( ! info ) { for (const string& ext : script_extensions) { string pkg_name = *it + "/__load__" + ext; - info = zeexygen_mgr->GetScriptInfo(pkg_name); + info = zeekygen_mgr->GetScriptInfo(pkg_name); if ( info ) break; } if ( ! info ) - reporter->InternalWarning("Zeexygen failed to get mtime of %s", + reporter->InternalWarning("Zeekygen failed to get mtime of %s", it->c_str()); continue; } diff --git a/src/zeexygen/ScriptInfo.h b/src/zeekygen/ScriptInfo.h similarity index 92% rename from src/zeexygen/ScriptInfo.h rename to src/zeekygen/ScriptInfo.h index fb0f0c15ae..dde7560544 100644 --- a/src/zeexygen/ScriptInfo.h +++ b/src/zeekygen/ScriptInfo.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_SCRIPTINFO_H -#define ZEEXYGEN_SCRIPTINFO_H +#ifndef ZEEKYGEN_SCRIPTINFO_H +#define ZEEKYGEN_SCRIPTINFO_H #include "Info.h" #include "IdentifierInfo.h" @@ -12,7 +12,7 @@ #include #include -namespace zeexygen { +namespace zeekygen { class IdentifierInfo; @@ -39,7 +39,7 @@ public: ScriptInfo(const std::string& name, const std::string& path); /** - * Associate a Zeexygen summary comment ("##!") with the script. + * Associate a Zeekygen summary comment ("##!") with the script. * @param comment String extracted from the comment. */ void AddComment(const std::string& comment) @@ -83,7 +83,7 @@ public: { return is_pkg_loader; } /** - * @return All the scripts Zeexygen summary comments. + * @return All the scripts Zeekygen summary comments. */ std::vector GetComments() const; @@ -119,6 +119,6 @@ private: id_info_set redefs; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/Target.cc b/src/zeekygen/Target.cc similarity index 90% rename from src/zeexygen/Target.cc rename to src/zeekygen/Target.cc index 406f6ffe4d..0e40defee3 100644 --- a/src/zeexygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -16,7 +16,7 @@ #include using namespace std; -using namespace zeexygen; +using namespace zeekygen; static void write_plugin_section_heading(FILE* f, const plugin::Plugin* p) { @@ -123,13 +123,13 @@ static void write_plugin_bif_items(FILE* f, const plugin::Plugin* p, for ( it = bifitems.begin(); it != bifitems.end(); ++it ) { - zeexygen::IdentifierInfo* doc = zeexygen_mgr->GetIdentifierInfo( + zeekygen::IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo( it->GetID()); if ( doc ) fprintf(f, "%s\n\n", doc->ReStructuredText().c_str()); else - reporter->InternalWarning("Zeexygen ID lookup failed: %s\n", + reporter->InternalWarning("Zeekygen ID lookup failed: %s\n", it->GetID().c_str()); } } @@ -138,10 +138,10 @@ static void WriteAnalyzerTagDefn(FILE* f, const string& module) { string tag_id = module + "::Tag"; - zeexygen::IdentifierInfo* doc = zeexygen_mgr->GetIdentifierInfo(tag_id); + zeekygen::IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(tag_id); if ( ! doc ) - reporter->InternalError("Zeexygen failed analyzer tag lookup: %s", + reporter->InternalError("Zeekygen failed analyzer tag lookup: %s", tag_id.c_str()); fprintf(f, "%s\n", doc->ReStructuredText().c_str()); @@ -177,7 +177,7 @@ static vector filter_matches(const vector& from, Target* t) if ( t->MatchesPattern(d) ) { - DBG_LOG(DBG_ZEEXYGEN, "'%s' matched pattern for target '%s'", + DBG_LOG(DBG_ZEEKYGEN, "'%s' matched pattern for target '%s'", d->Name().c_str(), t->Name().c_str()); rval.push_back(d); } @@ -194,14 +194,14 @@ TargetFile::TargetFile(const string& arg_name) string dir = SafeDirname(name).result; if ( ! ensure_intermediate_dirs(dir.c_str()) ) - reporter->FatalError("Zeexygen failed to make dir %s", + reporter->FatalError("Zeekygen failed to make dir %s", dir.c_str()); } f = fopen(name.c_str(), "w"); if ( ! f ) - reporter->FatalError("Zeexygen failed to open '%s' for writing: %s", + reporter->FatalError("Zeekygen failed to open '%s' for writing: %s", name.c_str(), strerror(errno)); } @@ -210,7 +210,7 @@ TargetFile::~TargetFile() if ( f ) fclose(f); - DBG_LOG(DBG_ZEEXYGEN, "Wrote out-of-date target '%s'", name.c_str()); + DBG_LOG(DBG_ZEEKYGEN, "Wrote out-of-date target '%s'", name.c_str()); } @@ -245,11 +245,11 @@ void AnalyzerTarget::DoFindDependencies(const std::vector& infos) void AnalyzerTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), vector()) ) + if ( zeekygen_mgr->IsUpToDate(Name(), vector()) ) return; if ( Pattern() != "*" ) - reporter->InternalWarning("Zeexygen only implements analyzer target" + reporter->InternalWarning("Zeekygen only implements analyzer target" " pattern '*'"); TargetFile file(Name()); @@ -313,7 +313,7 @@ void PackageTarget::DoFindDependencies(const vector& infos) pkg_deps = filter_matches(infos, this); if ( pkg_deps.empty() ) - reporter->FatalError("No match for Zeexygen target '%s' pattern '%s'", + reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", Name().c_str(), Pattern().c_str()); for ( size_t i = 0; i < infos.size(); ++i ) @@ -329,7 +329,7 @@ void PackageTarget::DoFindDependencies(const vector& infos) pkg_deps[j]->Name().size())) continue; - DBG_LOG(DBG_ZEEXYGEN, "Script %s associated with package %s", + DBG_LOG(DBG_ZEEKYGEN, "Script %s associated with package %s", script->Name().c_str(), pkg_deps[j]->Name().c_str()); pkg_manifest[pkg_deps[j]].push_back(script); script_deps.push_back(script); @@ -339,8 +339,8 @@ void PackageTarget::DoFindDependencies(const vector& infos) void PackageTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), script_deps) && - zeexygen_mgr->IsUpToDate(Name(), pkg_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) && + zeekygen_mgr->IsUpToDate(Name(), pkg_deps) ) return; TargetFile file(Name()); @@ -382,13 +382,13 @@ void PackageIndexTarget::DoFindDependencies(const vector& infos) pkg_deps = filter_matches(infos, this); if ( pkg_deps.empty() ) - reporter->FatalError("No match for Zeexygen target '%s' pattern '%s'", + reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", Name().c_str(), Pattern().c_str()); } void PackageIndexTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), pkg_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), pkg_deps) ) return; TargetFile file(Name()); @@ -402,7 +402,7 @@ void ScriptTarget::DoFindDependencies(const vector& infos) script_deps = filter_matches(infos, this); if ( script_deps.empty() ) - reporter->FatalError("No match for Zeexygen target '%s' pattern '%s'", + reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", Name().c_str(), Pattern().c_str()); if ( ! IsDir() ) @@ -483,7 +483,7 @@ void ScriptTarget::DoGenerate() const vector dep; dep.push_back(script_deps[i]); - if ( zeexygen_mgr->IsUpToDate(target_filename, dep) ) + if ( zeekygen_mgr->IsUpToDate(target_filename, dep) ) continue; TargetFile file(target_filename); @@ -508,7 +508,7 @@ void ScriptTarget::DoGenerate() const reporter->Warning("Failed to unlink %s: %s", f.c_str(), strerror(errno)); - DBG_LOG(DBG_ZEEXYGEN, "Delete stale script file %s", f.c_str()); + DBG_LOG(DBG_ZEEKYGEN, "Delete stale script file %s", f.c_str()); } return; @@ -516,7 +516,7 @@ void ScriptTarget::DoGenerate() const // Target is a single file, all matching scripts get written there. - if ( zeexygen_mgr->IsUpToDate(Name(), script_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) ) return; TargetFile file(Name()); @@ -527,7 +527,7 @@ void ScriptTarget::DoGenerate() const void ScriptSummaryTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), script_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) ) return; TargetFile file(Name()); @@ -552,7 +552,7 @@ void ScriptSummaryTarget::DoGenerate() const void ScriptIndexTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), script_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) ) return; TargetFile file(Name()); @@ -577,13 +577,13 @@ void IdentifierTarget::DoFindDependencies(const vector& infos) id_deps = filter_matches(infos, this); if ( id_deps.empty() ) - reporter->FatalError("No match for Zeexygen target '%s' pattern '%s'", + reporter->FatalError("No match for Zeekygen target '%s' pattern '%s'", Name().c_str(), Pattern().c_str()); } void IdentifierTarget::DoGenerate() const { - if ( zeexygen_mgr->IsUpToDate(Name(), id_deps) ) + if ( zeekygen_mgr->IsUpToDate(Name(), id_deps) ) return; TargetFile file(Name()); diff --git a/src/zeexygen/Target.h b/src/zeekygen/Target.h similarity index 97% rename from src/zeexygen/Target.h rename to src/zeekygen/Target.h index ef3c8b2e00..1129fe42ed 100644 --- a/src/zeexygen/Target.h +++ b/src/zeekygen/Target.h @@ -1,7 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_TARGET_H -#define ZEEXYGEN_TARGET_H +#ifndef ZEEKYGEN_TARGET_H +#define ZEEKYGEN_TARGET_H #include "Info.h" #include "PackageInfo.h" @@ -13,7 +13,7 @@ #include #include -namespace zeexygen { +namespace zeekygen { /** * Helper class to create files in arbitrary file paths and automatically @@ -39,7 +39,7 @@ struct TargetFile { }; /** - * A Zeexygen target abstract base class. A target is generally any portion of + * A Zeekygen target abstract base class. A target is generally any portion of * documentation that Bro can build. It's identified by a type (e.g. script, * identifier, package), a pattern (e.g. "example.zeek", "HTTP::Info"), and * a path to an output file. @@ -125,7 +125,7 @@ public: /** * Register a new target type. - * @param type_name The target type name as it will appear in Zeexygen + * @param type_name The target type name as it will appear in Zeekygen * config files. */ template @@ -136,7 +136,7 @@ public: /** * Instantiate a target. - * @param type_name The target type name as it appears in Zeexygen config + * @param type_name The target type name as it appears in Zeekygen config * files. * @param name The output file name of the target. * @param pattern The dependency pattern of the target. @@ -384,6 +384,6 @@ private: std::vector id_deps; }; -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/utils.cc b/src/zeekygen/utils.cc similarity index 83% rename from src/zeexygen/utils.cc rename to src/zeekygen/utils.cc index 5cf76c1af6..b04790ee92 100644 --- a/src/zeexygen/utils.cc +++ b/src/zeekygen/utils.cc @@ -7,10 +7,10 @@ #include #include -using namespace zeexygen; +using namespace zeekygen; using namespace std; -bool zeexygen::prettify_params(string& s) +bool zeekygen::prettify_params(string& s) { size_t identifier_start_pos = 0; bool in_identifier = false; @@ -76,29 +76,29 @@ bool zeexygen::prettify_params(string& s) return false; } -bool zeexygen::is_public_api(const ID* id) +bool zeekygen::is_public_api(const ID* id) { return (id->Scope() == SCOPE_GLOBAL) || (id->Scope() == SCOPE_MODULE && id->IsExport()); } -time_t zeexygen::get_mtime(const string& filename) +time_t zeekygen::get_mtime(const string& filename) { struct stat s; if ( stat(filename.c_str(), &s) < 0 ) - reporter->InternalError("Zeexygen failed to stat file '%s': %s", + reporter->InternalError("Zeekygen failed to stat file '%s': %s", filename.c_str(), strerror(errno)); return s.st_mtime; } -string zeexygen::make_heading(const string& heading, char underline) +string zeekygen::make_heading(const string& heading, char underline) { return heading + "\n" + string(heading.size(), underline) + "\n"; } -size_t zeexygen::end_of_first_sentence(const string& s) +size_t zeekygen::end_of_first_sentence(const string& s) { size_t rval = 0; @@ -119,7 +119,7 @@ size_t zeexygen::end_of_first_sentence(const string& s) return rval; } -bool zeexygen::is_all_whitespace(const string& s) +bool zeekygen::is_all_whitespace(const string& s) { for ( size_t i = 0; i < s.size(); ++i ) if ( ! isspace(s[i]) ) @@ -128,7 +128,7 @@ bool zeexygen::is_all_whitespace(const string& s) return true; } -string zeexygen::redef_indication(const string& from_script) +string zeekygen::redef_indication(const string& from_script) { return fmt("(present if :doc:`/scripts/%s` is loaded)", from_script.c_str()); diff --git a/src/zeexygen/utils.h b/src/zeekygen/utils.h similarity index 88% rename from src/zeexygen/utils.h rename to src/zeekygen/utils.h index b9a99a71f7..07430f66ba 100644 --- a/src/zeexygen/utils.h +++ b/src/zeekygen/utils.h @@ -1,18 +1,18 @@ // See the file "COPYING" in the main distribution directory for copyright. -#ifndef ZEEXYGEN_UTILS_H -#define ZEEXYGEN_UTILS_H +#ifndef ZEEKYGEN_UTILS_H +#define ZEEKYGEN_UTILS_H #include "ID.h" #include -namespace zeexygen { +namespace zeekygen { /** - * Transform content of a Zeexygen comment which may contain function + * Transform content of a Zeekygen comment which may contain function * parameter or return value documentation to a prettier reST format. - * @param s Content from a Zeexygen comment to transform. "id: ..." and + * @param s Content from a Zeekygen comment to transform. "id: ..." and * "Returns: ..." change to ":id: ..." and ":returns: ...". * @return Whether any content in \a s was transformed. */ @@ -62,6 +62,6 @@ bool is_all_whitespace(const std::string& s); */ std::string redef_indication(const std::string& from_script); -} // namespace zeexygen +} // namespace zeekygen #endif diff --git a/src/zeexygen/zeexygen.bif b/src/zeekygen/zeekygen.bif similarity index 81% rename from src/zeexygen/zeexygen.bif rename to src/zeekygen/zeekygen.bif index f7ce04d292..e10ee9f3ec 100644 --- a/src/zeexygen/zeexygen.bif +++ b/src/zeekygen/zeekygen.bif @@ -3,7 +3,7 @@ ##! Functions for querying script, package, or variable documentation. %%{ -#include "zeexygen/Manager.h" +#include "zeekygen/Manager.h" #include "util.h" static StringVal* comments_to_val(const vector& comments) @@ -12,7 +12,7 @@ static StringVal* comments_to_val(const vector& comments) } %%} -## Retrieve the Zeexygen-style comments (``##``) associated with an identifier +## Retrieve the Zeekygen-style comments (``##``) associated with an identifier ## (e.g. a variable or type). ## ## name: a script-level identifier for which to retrieve comments. @@ -21,8 +21,8 @@ static StringVal* comments_to_val(const vector& comments) ## identifier, an empty string is returned. function get_identifier_comments%(name: string%): string %{ - using namespace zeexygen; - IdentifierInfo* d = zeexygen_mgr->GetIdentifierInfo(name->CheckString()); + using namespace zeekygen; + IdentifierInfo* d = zeekygen_mgr->GetIdentifierInfo(name->CheckString()); if ( ! d ) return val_mgr->GetEmptyString(); @@ -30,7 +30,7 @@ function get_identifier_comments%(name: string%): string return comments_to_val(d->GetComments()); %} -## Retrieve the Zeexygen-style summary comments (``##!``) associated with +## Retrieve the Zeekygen-style summary comments (``##!``) associated with ## a Bro script. ## ## name: the name of a Bro script. It must be a relative path to where @@ -41,8 +41,8 @@ function get_identifier_comments%(name: string%): string ## *name* is not a known script, an empty string is returned. function get_script_comments%(name: string%): string %{ - using namespace zeexygen; - ScriptInfo* d = zeexygen_mgr->GetScriptInfo(name->CheckString()); + using namespace zeekygen; + ScriptInfo* d = zeekygen_mgr->GetScriptInfo(name->CheckString()); if ( ! d ) return val_mgr->GetEmptyString(); @@ -59,8 +59,8 @@ function get_script_comments%(name: string%): string ## package, an empty string is returned. function get_package_readme%(name: string%): string %{ - using namespace zeexygen; - PackageInfo* d = zeexygen_mgr->GetPackageInfo(name->CheckString()); + using namespace zeekygen; + PackageInfo* d = zeekygen_mgr->GetPackageInfo(name->CheckString()); if ( ! d ) return val_mgr->GetEmptyString(); @@ -68,7 +68,7 @@ function get_package_readme%(name: string%): string return comments_to_val(d->GetReadme()); %} -## Retrieve the Zeexygen-style comments (``##``) associated with a record field. +## Retrieve the Zeekygen-style comments (``##``) associated with a record field. ## ## name: the name of a record type and a field within it formatted like ## a typical record field access: "$". @@ -78,7 +78,7 @@ function get_package_readme%(name: string%): string ## type, an empty string is returned. function get_record_field_comments%(name: string%): string %{ - using namespace zeexygen; + using namespace zeekygen; string accessor = name->CheckString(); size_t i = accessor.find('$'); @@ -87,7 +87,7 @@ function get_record_field_comments%(name: string%): string string id = accessor.substr(0, i); - IdentifierInfo* d = zeexygen_mgr->GetIdentifierInfo(id); + IdentifierInfo* d = zeekygen_mgr->GetIdentifierInfo(id); if ( ! d ) return val_mgr->GetEmptyString(); diff --git a/testing/btest/Baseline/core.plugins.hooks/output b/testing/btest/Baseline/core.plugins.hooks/output index 2725e48507..138d019b34 100644 --- a/testing/btest/Baseline/core.plugins.hooks/output +++ b/testing/btest/Baseline/core.plugins.hooks/output @@ -275,7 +275,7 @@ 0.000000 MetaHookPost LoadFile(./average) -> -1 0.000000 MetaHookPost LoadFile(./bloom-filter.bif.bro) -> -1 0.000000 MetaHookPost LoadFile(./bro.bif.bro) -> -1 -0.000000 MetaHookPost LoadFile(./zeexygen.bif.bro) -> -1 +0.000000 MetaHookPost LoadFile(./zeekygen.bif.bro) -> -1 0.000000 MetaHookPost LoadFile(./cardinality-counter.bif.bro) -> -1 0.000000 MetaHookPost LoadFile(./const.bif.bro) -> -1 0.000000 MetaHookPost LoadFile(./consts) -> -1 @@ -855,7 +855,7 @@ 0.000000 MetaHookPre LoadFile(./average) 0.000000 MetaHookPre LoadFile(./bloom-filter.bif.bro) 0.000000 MetaHookPre LoadFile(./bro.bif.bro) -0.000000 MetaHookPre LoadFile(./zeexygen.bif.bro) +0.000000 MetaHookPre LoadFile(./zeekygen.bif.bro) 0.000000 MetaHookPre LoadFile(./cardinality-counter.bif.bro) 0.000000 MetaHookPre LoadFile(./const.bif.bro) 0.000000 MetaHookPre LoadFile(./consts) @@ -1435,7 +1435,7 @@ 0.000000 | HookLoadFile ./average.bro/bro 0.000000 | HookLoadFile ./bloom-filter.bif.bro/bro 0.000000 | HookLoadFile ./bro.bif.bro/bro -0.000000 | HookLoadFile ./zeexygen.bif.bro/bro +0.000000 | HookLoadFile ./zeekygen.bif.bro/bro 0.000000 | HookLoadFile ./cardinality-counter.bif.bro/bro 0.000000 | HookLoadFile ./const.bif.bro/bro 0.000000 | HookLoadFile ./consts.bif.bro/bro diff --git a/testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log b/testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log index 1976784e41..a4caf4f6be 100644 --- a/testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log +++ b/testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log @@ -55,7 +55,7 @@ scripts/base/init-frameworks-and-bifs.zeek scripts/base/utils/patterns.zeek scripts/base/frameworks/files/magic/__load__.zeek build/scripts/base/bif/__load__.zeek - build/scripts/base/bif/zeexygen.bif.zeek + build/scripts/base/bif/zeekygen.bif.zeek build/scripts/base/bif/pcap.bif.zeek build/scripts/base/bif/bloom-filter.bif.zeek build/scripts/base/bif/cardinality-counter.bif.zeek diff --git a/testing/btest/Baseline/coverage.bare-mode-errors/errors b/testing/btest/Baseline/coverage.bare-mode-errors/errors index 359ae2c616..a13c8849a1 100644 --- a/testing/btest/Baseline/coverage.bare-mode-errors/errors +++ b/testing/btest/Baseline/coverage.bare-mode-errors/errors @@ -1,6 +1,4 @@ warning in /Users/johanna/bro/master/scripts/policy/misc/trim-trace-file.zeek, line 25: deprecated (rotate_file_by_name) warning in /Users/johanna/bro/master/scripts/policy/misc/trim-trace-file.zeek, line 25: deprecated (rotate_file_by_name) -warning in /Users/johanna/bro/master/scripts/policy/protocols/smb/__load__.zeek, line 1: deprecated script loaded from /Users/johanna/bro/master/testing/btest/../../scripts//zeexygen/__load__.zeek:9 "Use '@load base/protocols/smb' instead" warning in /Users/johanna/bro/master/scripts/policy/misc/trim-trace-file.zeek, line 25: deprecated (rotate_file_by_name) warning in /Users/johanna/bro/master/testing/btest/../../scripts//policy/misc/trim-trace-file.zeek, line 25: deprecated (rotate_file_by_name) -warning in /Users/johanna/bro/master/testing/btest/../../scripts//policy/protocols/smb/__load__.zeek, line 1: deprecated script loaded from command line arguments "Use '@load base/protocols/smb' instead" diff --git a/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log b/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log index 7951d68e2b..4c33718ad2 100644 --- a/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log +++ b/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log @@ -55,7 +55,7 @@ scripts/base/init-frameworks-and-bifs.zeek scripts/base/utils/patterns.zeek scripts/base/frameworks/files/magic/__load__.zeek build/scripts/base/bif/__load__.zeek - build/scripts/base/bif/zeexygen.bif.zeek + build/scripts/base/bif/zeekygen.bif.zeek build/scripts/base/bif/pcap.bif.zeek build/scripts/base/bif/bloom-filter.bif.zeek build/scripts/base/bif/cardinality-counter.bif.zeek diff --git a/testing/btest/Baseline/doc.zeexygen.all_scripts/.stderr b/testing/btest/Baseline/doc.zeekygen.all_scripts/.stderr similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.all_scripts/.stderr rename to testing/btest/Baseline/doc.zeekygen.all_scripts/.stderr diff --git a/testing/btest/Baseline/doc.zeexygen.all_scripts/.stdout b/testing/btest/Baseline/doc.zeekygen.all_scripts/.stdout similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.all_scripts/.stdout rename to testing/btest/Baseline/doc.zeekygen.all_scripts/.stdout diff --git a/testing/btest/Baseline/doc.zeexygen.command_line/output b/testing/btest/Baseline/doc.zeekygen.command_line/output similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.command_line/output rename to testing/btest/Baseline/doc.zeekygen.command_line/output diff --git a/testing/btest/Baseline/doc.zeexygen.comment_retrieval_bifs/out b/testing/btest/Baseline/doc.zeekygen.comment_retrieval_bifs/out similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.comment_retrieval_bifs/out rename to testing/btest/Baseline/doc.zeekygen.comment_retrieval_bifs/out diff --git a/testing/btest/Baseline/doc.zeexygen.enums/autogen-reST-enums.rst b/testing/btest/Baseline/doc.zeekygen.enums/autogen-reST-enums.rst similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.enums/autogen-reST-enums.rst rename to testing/btest/Baseline/doc.zeekygen.enums/autogen-reST-enums.rst diff --git a/testing/btest/Baseline/doc.zeexygen.example/example.rst b/testing/btest/Baseline/doc.zeekygen.example/example.rst similarity index 77% rename from testing/btest/Baseline/doc.zeexygen.example/example.rst rename to testing/btest/Baseline/doc.zeekygen.example/example.rst index 4ea8dfe0c3..141a06cc2a 100644 --- a/testing/btest/Baseline/doc.zeexygen.example/example.rst +++ b/testing/btest/Baseline/doc.zeekygen.example/example.rst @@ -1,10 +1,10 @@ :tocdepth: 3 -zeexygen/example.zeek +zeekygen/example.zeek ===================== -.. zeek:namespace:: ZeexygenExample +.. zeek:namespace:: ZeekygenExample -This is an example script that demonstrates Zeexygen-style +This is an example script that demonstrates Zeekygen-style documentation. It generally will make most sense when viewing the script's raw source code and comparing to the HTML-rendered version. @@ -19,14 +19,14 @@ purpose. They are transferred directly in to the generated There's also a custom role to reference any identifier node in the Zeek Sphinx domain that's good for "see alsos", e.g. -See also: :zeek:see:`ZeexygenExample::a_var`, -:zeek:see:`ZeexygenExample::ONE`, :zeek:see:`SSH::Info` +See also: :zeek:see:`ZeekygenExample::a_var`, +:zeek:see:`ZeekygenExample::ONE`, :zeek:see:`SSH::Info` And a custom directive does the equivalent references: -.. zeek:see:: ZeexygenExample::a_var ZeexygenExample::ONE SSH::Info +.. zeek:see:: ZeekygenExample::a_var ZeekygenExample::ONE SSH::Info -:Namespace: ZeexygenExample +:Namespace: ZeekygenExample :Imports: :doc:`base/frameworks/notice `, :doc:`base/protocols/http `, :doc:`policy/frameworks/software/vulnerable.zeek ` Summary @@ -34,25 +34,25 @@ Summary Redefinable Options ################### ======================================================================================= ======================================================= -:zeek:id:`ZeexygenExample::an_option`: :zeek:type:`set` :zeek:attr:`&redef` Add documentation for "an_option" here. -:zeek:id:`ZeexygenExample::option_with_init`: :zeek:type:`interval` :zeek:attr:`&redef` Default initialization will be generated automatically. +:zeek:id:`ZeekygenExample::an_option`: :zeek:type:`set` :zeek:attr:`&redef` Add documentation for "an_option" here. +:zeek:id:`ZeekygenExample::option_with_init`: :zeek:type:`interval` :zeek:attr:`&redef` Default initialization will be generated automatically. ======================================================================================= ======================================================= State Variables ############### ========================================================================== ======================================================================== -:zeek:id:`ZeexygenExample::a_var`: :zeek:type:`bool` Put some documentation for "a_var" here. -:zeek:id:`ZeexygenExample::summary_test`: :zeek:type:`string` The first sentence for a particular identifier's summary text ends here. -:zeek:id:`ZeexygenExample::var_without_explicit_type`: :zeek:type:`string` Types are inferred, that information is self-documenting. +:zeek:id:`ZeekygenExample::a_var`: :zeek:type:`bool` Put some documentation for "a_var" here. +:zeek:id:`ZeekygenExample::summary_test`: :zeek:type:`string` The first sentence for a particular identifier's summary text ends here. +:zeek:id:`ZeekygenExample::var_without_explicit_type`: :zeek:type:`string` Types are inferred, that information is self-documenting. ========================================================================== ======================================================================== Types ##### ==================================================================================== =========================================================== -:zeek:type:`ZeexygenExample::ComplexRecord`: :zeek:type:`record` :zeek:attr:`&redef` General documentation for a type "ComplexRecord" goes here. -:zeek:type:`ZeexygenExample::Info`: :zeek:type:`record` An example record to be used with a logging stream. -:zeek:type:`ZeexygenExample::SimpleEnum`: :zeek:type:`enum` Documentation for the "SimpleEnum" type goes here. -:zeek:type:`ZeexygenExample::SimpleRecord`: :zeek:type:`record` General documentation for a type "SimpleRecord" goes here. +:zeek:type:`ZeekygenExample::ComplexRecord`: :zeek:type:`record` :zeek:attr:`&redef` General documentation for a type "ComplexRecord" goes here. +:zeek:type:`ZeekygenExample::Info`: :zeek:type:`record` An example record to be used with a logging stream. +:zeek:type:`ZeekygenExample::SimpleEnum`: :zeek:type:`enum` Documentation for the "SimpleEnum" type goes here. +:zeek:type:`ZeekygenExample::SimpleRecord`: :zeek:type:`record` General documentation for a type "SimpleRecord" goes here. ==================================================================================== =========================================================== Redefinitions @@ -60,21 +60,21 @@ Redefinitions =============================================================== ==================================================================== :zeek:type:`Log::ID`: :zeek:type:`enum` :zeek:type:`Notice::Type`: :zeek:type:`enum` -:zeek:type:`ZeexygenExample::SimpleEnum`: :zeek:type:`enum` Document the "SimpleEnum" redef here with any special info regarding +:zeek:type:`ZeekygenExample::SimpleEnum`: :zeek:type:`enum` Document the "SimpleEnum" redef here with any special info regarding the *redef* itself. -:zeek:type:`ZeexygenExample::SimpleRecord`: :zeek:type:`record` Document the record extension *redef* itself here. +:zeek:type:`ZeekygenExample::SimpleRecord`: :zeek:type:`record` Document the record extension *redef* itself here. =============================================================== ==================================================================== Events ###### ======================================================== ========================== -:zeek:id:`ZeexygenExample::an_event`: :zeek:type:`event` Summarize "an_event" here. +:zeek:id:`ZeekygenExample::an_event`: :zeek:type:`event` Summarize "an_event" here. ======================================================== ========================== Functions ######### ============================================================= ======================================= -:zeek:id:`ZeexygenExample::a_function`: :zeek:type:`function` Summarize purpose of "a_function" here. +:zeek:id:`ZeekygenExample::a_function`: :zeek:type:`function` Summarize purpose of "a_function" here. ============================================================= ======================================= @@ -82,7 +82,7 @@ Detailed Interface ~~~~~~~~~~~~~~~~~~ Redefinable Options ################### -.. zeek:id:: ZeexygenExample::an_option +.. zeek:id:: ZeekygenExample::an_option :Type: :zeek:type:`set` [:zeek:type:`addr`, :zeek:type:`addr`, :zeek:type:`string`] :Attributes: :zeek:attr:`&redef` @@ -91,7 +91,7 @@ Redefinable Options Add documentation for "an_option" here. The type/attribute information is all generated automatically. -.. zeek:id:: ZeexygenExample::option_with_init +.. zeek:id:: ZeekygenExample::option_with_init :Type: :zeek:type:`interval` :Attributes: :zeek:attr:`&redef` @@ -102,7 +102,7 @@ Redefinable Options State Variables ############### -.. zeek:id:: ZeexygenExample::a_var +.. zeek:id:: ZeekygenExample::a_var :Type: :zeek:type:`bool` @@ -110,7 +110,7 @@ State Variables isn't a function/event/hook is classified as a "state variable" in the generated docs. -.. zeek:id:: ZeexygenExample::summary_test +.. zeek:id:: ZeekygenExample::summary_test :Type: :zeek:type:`string` @@ -118,7 +118,7 @@ State Variables And this second sentence doesn't show in the short description provided by the table of all identifiers declared by this script. -.. zeek:id:: ZeexygenExample::var_without_explicit_type +.. zeek:id:: ZeekygenExample::var_without_explicit_type :Type: :zeek:type:`string` :Default: ``"this works"`` @@ -127,7 +127,7 @@ State Variables Types ##### -.. zeek:type:: ZeexygenExample::ComplexRecord +.. zeek:type:: ZeekygenExample::ComplexRecord :Type: :zeek:type:`record` @@ -137,8 +137,8 @@ Types field2: :zeek:type:`bool` Toggles something. - field3: :zeek:type:`ZeexygenExample::SimpleRecord` - Zeexygen automatically tracks types + field3: :zeek:type:`ZeekygenExample::SimpleRecord` + Zeekygen automatically tracks types and cross-references are automatically inserted in to generated docs. @@ -148,7 +148,7 @@ Types General documentation for a type "ComplexRecord" goes here. -.. zeek:type:: ZeexygenExample::Info +.. zeek:type:: ZeekygenExample::Info :Type: :zeek:type:`record` @@ -164,33 +164,33 @@ Types fields plus the extensions and the scripts which contributed to it (provided they are also @load'ed). -.. zeek:type:: ZeexygenExample::SimpleEnum +.. zeek:type:: ZeekygenExample::SimpleEnum :Type: :zeek:type:`enum` - .. zeek:enum:: ZeexygenExample::ONE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::ONE ZeekygenExample::SimpleEnum Documentation for particular enum values is added like this. And can also span multiple lines. - .. zeek:enum:: ZeexygenExample::TWO ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::TWO ZeekygenExample::SimpleEnum Or this style is valid to document the preceding enum value. - .. zeek:enum:: ZeexygenExample::THREE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::THREE ZeekygenExample::SimpleEnum - .. zeek:enum:: ZeexygenExample::FOUR ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::FOUR ZeekygenExample::SimpleEnum And some documentation for "FOUR". - .. zeek:enum:: ZeexygenExample::FIVE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::FIVE ZeekygenExample::SimpleEnum Also "FIVE". Documentation for the "SimpleEnum" type goes here. It can span multiple lines. -.. zeek:type:: ZeexygenExample::SimpleRecord +.. zeek:type:: ZeekygenExample::SimpleRecord :Type: :zeek:type:`record` @@ -210,23 +210,23 @@ Types Events ###### -.. zeek:id:: ZeexygenExample::an_event +.. zeek:id:: ZeekygenExample::an_event :Type: :zeek:type:`event` (name: :zeek:type:`string`) Summarize "an_event" here. Give more details about "an_event" here. - ZeexygenExample::a_function should not be confused as a parameter + ZeekygenExample::a_function should not be confused as a parameter in the generated docs, but it also doesn't generate a cross-reference - link. Use the see role instead: :zeek:see:`ZeexygenExample::a_function`. + link. Use the see role instead: :zeek:see:`ZeekygenExample::a_function`. :name: Describe the argument here. Functions ######### -.. zeek:id:: ZeexygenExample::a_function +.. zeek:id:: ZeekygenExample::a_function :Type: :zeek:type:`function` (tag: :zeek:type:`string`, msg: :zeek:type:`string`) : :zeek:type:`string` diff --git a/testing/btest/Baseline/doc.zeexygen.func-params/autogen-reST-func-params.rst b/testing/btest/Baseline/doc.zeekygen.func-params/autogen-reST-func-params.rst similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.func-params/autogen-reST-func-params.rst rename to testing/btest/Baseline/doc.zeekygen.func-params/autogen-reST-func-params.rst diff --git a/testing/btest/Baseline/doc.zeexygen.identifier/test.rst b/testing/btest/Baseline/doc.zeekygen.identifier/test.rst similarity index 70% rename from testing/btest/Baseline/doc.zeexygen.identifier/test.rst rename to testing/btest/Baseline/doc.zeekygen.identifier/test.rst index 128e1c6a5f..34c4ae71a6 100644 --- a/testing/btest/Baseline/doc.zeexygen.identifier/test.rst +++ b/testing/btest/Baseline/doc.zeekygen.identifier/test.rst @@ -1,91 +1,91 @@ -.. zeek:id:: ZeexygenExample::Zeexygen_One +.. zeek:id:: ZeekygenExample::Zeekygen_One :Type: :zeek:type:`Notice::Type` Any number of this type of comment - will document "Zeexygen_One". + will document "Zeekygen_One". -.. zeek:id:: ZeexygenExample::Zeexygen_Two +.. zeek:id:: ZeekygenExample::Zeekygen_Two :Type: :zeek:type:`Notice::Type` Any number of this type of comment - will document "ZEEXYGEN_TWO". + will document "ZEEKYGEN_TWO". -.. zeek:id:: ZeexygenExample::Zeexygen_Three +.. zeek:id:: ZeekygenExample::Zeekygen_Three :Type: :zeek:type:`Notice::Type` -.. zeek:id:: ZeexygenExample::Zeexygen_Four +.. zeek:id:: ZeekygenExample::Zeekygen_Four :Type: :zeek:type:`Notice::Type` Omitting comments is fine, and so is mixing ``##`` and ``##<``, but it's probably best to use only one style consistently. -.. zeek:id:: ZeexygenExample::LOG +.. zeek:id:: ZeekygenExample::LOG :Type: :zeek:type:`Log::ID` -.. zeek:type:: ZeexygenExample::SimpleEnum +.. zeek:type:: ZeekygenExample::SimpleEnum :Type: :zeek:type:`enum` - .. zeek:enum:: ZeexygenExample::ONE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::ONE ZeekygenExample::SimpleEnum Documentation for particular enum values is added like this. And can also span multiple lines. - .. zeek:enum:: ZeexygenExample::TWO ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::TWO ZeekygenExample::SimpleEnum Or this style is valid to document the preceding enum value. - .. zeek:enum:: ZeexygenExample::THREE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::THREE ZeekygenExample::SimpleEnum - .. zeek:enum:: ZeexygenExample::FOUR ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::FOUR ZeekygenExample::SimpleEnum And some documentation for "FOUR". - .. zeek:enum:: ZeexygenExample::FIVE ZeexygenExample::SimpleEnum + .. zeek:enum:: ZeekygenExample::FIVE ZeekygenExample::SimpleEnum Also "FIVE". Documentation for the "SimpleEnum" type goes here. It can span multiple lines. -.. zeek:id:: ZeexygenExample::ONE +.. zeek:id:: ZeekygenExample::ONE - :Type: :zeek:type:`ZeexygenExample::SimpleEnum` + :Type: :zeek:type:`ZeekygenExample::SimpleEnum` Documentation for particular enum values is added like this. And can also span multiple lines. -.. zeek:id:: ZeexygenExample::TWO +.. zeek:id:: ZeekygenExample::TWO - :Type: :zeek:type:`ZeexygenExample::SimpleEnum` + :Type: :zeek:type:`ZeekygenExample::SimpleEnum` Or this style is valid to document the preceding enum value. -.. zeek:id:: ZeexygenExample::THREE +.. zeek:id:: ZeekygenExample::THREE - :Type: :zeek:type:`ZeexygenExample::SimpleEnum` + :Type: :zeek:type:`ZeekygenExample::SimpleEnum` -.. zeek:id:: ZeexygenExample::FOUR +.. zeek:id:: ZeekygenExample::FOUR - :Type: :zeek:type:`ZeexygenExample::SimpleEnum` + :Type: :zeek:type:`ZeekygenExample::SimpleEnum` And some documentation for "FOUR". -.. zeek:id:: ZeexygenExample::FIVE +.. zeek:id:: ZeekygenExample::FIVE - :Type: :zeek:type:`ZeexygenExample::SimpleEnum` + :Type: :zeek:type:`ZeekygenExample::SimpleEnum` Also "FIVE". -.. zeek:type:: ZeexygenExample::SimpleRecord +.. zeek:type:: ZeekygenExample::SimpleRecord :Type: :zeek:type:`record` @@ -103,7 +103,7 @@ The way fields can be documented is similar to what's already seen for enums. -.. zeek:type:: ZeexygenExample::ComplexRecord +.. zeek:type:: ZeekygenExample::ComplexRecord :Type: :zeek:type:`record` @@ -113,8 +113,8 @@ field2: :zeek:type:`bool` Toggles something. - field3: :zeek:type:`ZeexygenExample::SimpleRecord` - Zeexygen automatically tracks types + field3: :zeek:type:`ZeekygenExample::SimpleRecord` + Zeekygen automatically tracks types and cross-references are automatically inserted in to generated docs. @@ -124,7 +124,7 @@ General documentation for a type "ComplexRecord" goes here. -.. zeek:type:: ZeexygenExample::Info +.. zeek:type:: ZeekygenExample::Info :Type: :zeek:type:`record` @@ -140,7 +140,7 @@ fields plus the extensions and the scripts which contributed to it (provided they are also @load'ed). -.. zeek:id:: ZeexygenExample::an_option +.. zeek:id:: ZeekygenExample::an_option :Type: :zeek:type:`set` [:zeek:type:`addr`, :zeek:type:`addr`, :zeek:type:`string`] :Attributes: :zeek:attr:`&redef` @@ -149,7 +149,7 @@ Add documentation for "an_option" here. The type/attribute information is all generated automatically. -.. zeek:id:: ZeexygenExample::option_with_init +.. zeek:id:: ZeekygenExample::option_with_init :Type: :zeek:type:`interval` :Attributes: :zeek:attr:`&redef` @@ -158,7 +158,7 @@ Default initialization will be generated automatically. More docs can be added here. -.. zeek:id:: ZeexygenExample::a_var +.. zeek:id:: ZeekygenExample::a_var :Type: :zeek:type:`bool` @@ -166,14 +166,14 @@ isn't a function/event/hook is classified as a "state variable" in the generated docs. -.. zeek:id:: ZeexygenExample::var_without_explicit_type +.. zeek:id:: ZeekygenExample::var_without_explicit_type :Type: :zeek:type:`string` :Default: ``"this works"`` Types are inferred, that information is self-documenting. -.. zeek:id:: ZeexygenExample::summary_test +.. zeek:id:: ZeekygenExample::summary_test :Type: :zeek:type:`string` @@ -181,7 +181,7 @@ And this second sentence doesn't show in the short description provided by the table of all identifiers declared by this script. -.. zeek:id:: ZeexygenExample::a_function +.. zeek:id:: ZeekygenExample::a_function :Type: :zeek:type:`function` (tag: :zeek:type:`string`, msg: :zeek:type:`string`) : :zeek:type:`string` @@ -200,26 +200,26 @@ :returns: Describe the return type here. -.. zeek:id:: ZeexygenExample::an_event +.. zeek:id:: ZeekygenExample::an_event :Type: :zeek:type:`event` (name: :zeek:type:`string`) Summarize "an_event" here. Give more details about "an_event" here. - ZeexygenExample::a_function should not be confused as a parameter + ZeekygenExample::a_function should not be confused as a parameter in the generated docs, but it also doesn't generate a cross-reference - link. Use the see role instead: :zeek:see:`ZeexygenExample::a_function`. + link. Use the see role instead: :zeek:see:`ZeekygenExample::a_function`. :name: Describe the argument here. -.. zeek:id:: ZeexygenExample::function_without_proto +.. zeek:id:: ZeekygenExample::function_without_proto :Type: :zeek:type:`function` (tag: :zeek:type:`string`) : :zeek:type:`string` -.. zeek:type:: ZeexygenExample::PrivateRecord +.. zeek:type:: ZeekygenExample::PrivateRecord :Type: :zeek:type:`record` diff --git a/testing/btest/Baseline/doc.zeexygen.package/test.rst b/testing/btest/Baseline/doc.zeekygen.package/test.rst similarity index 70% rename from testing/btest/Baseline/doc.zeexygen.package/test.rst rename to testing/btest/Baseline/doc.zeekygen.package/test.rst index 345b2b6847..6ced7b797e 100644 --- a/testing/btest/Baseline/doc.zeexygen.package/test.rst +++ b/testing/btest/Baseline/doc.zeekygen.package/test.rst @@ -1,19 +1,19 @@ :orphan: -Package: zeexygen +Package: zeekygen ================= This package is loaded during the process which automatically generates -reference documentation for all Zeek scripts (i.e. "Zeexygen"). Its only +reference documentation for all Zeek scripts (i.e. "Zeekygen"). Its only purpose is to provide an easy way to load all known Zeek scripts plus any extra scripts needed or used by the documentation process. -:doc:`/scripts/zeexygen/__load__.zeek` +:doc:`/scripts/zeekygen/__load__.zeek` -:doc:`/scripts/zeexygen/example.zeek` +:doc:`/scripts/zeekygen/example.zeek` - This is an example script that demonstrates Zeexygen-style + This is an example script that demonstrates Zeekygen-style documentation. It generally will make most sense when viewing the script's raw source code and comparing to the HTML-rendered version. @@ -28,10 +28,10 @@ extra scripts needed or used by the documentation process. There's also a custom role to reference any identifier node in the Zeek Sphinx domain that's good for "see alsos", e.g. - See also: :zeek:see:`ZeexygenExample::a_var`, - :zeek:see:`ZeexygenExample::ONE`, :zeek:see:`SSH::Info` + See also: :zeek:see:`ZeekygenExample::a_var`, + :zeek:see:`ZeekygenExample::ONE`, :zeek:see:`SSH::Info` And a custom directive does the equivalent references: - .. zeek:see:: ZeexygenExample::a_var ZeexygenExample::ONE SSH::Info + .. zeek:see:: ZeekygenExample::a_var ZeekygenExample::ONE SSH::Info diff --git a/testing/btest/Baseline/doc.zeexygen.package_index/test.rst b/testing/btest/Baseline/doc.zeekygen.package_index/test.rst similarity index 68% rename from testing/btest/Baseline/doc.zeexygen.package_index/test.rst rename to testing/btest/Baseline/doc.zeekygen.package_index/test.rst index 4a854e9736..df9907bd1b 100644 --- a/testing/btest/Baseline/doc.zeexygen.package_index/test.rst +++ b/testing/btest/Baseline/doc.zeekygen.package_index/test.rst @@ -1,7 +1,7 @@ -:doc:`zeexygen ` +:doc:`zeekygen ` This package is loaded during the process which automatically generates - reference documentation for all Zeek scripts (i.e. "Zeexygen"). Its only + reference documentation for all Zeek scripts (i.e. "Zeekygen"). Its only purpose is to provide an easy way to load all known Zeek scripts plus any extra scripts needed or used by the documentation process. diff --git a/testing/btest/Baseline/doc.zeexygen.records/autogen-reST-records.rst b/testing/btest/Baseline/doc.zeekygen.records/autogen-reST-records.rst similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.records/autogen-reST-records.rst rename to testing/btest/Baseline/doc.zeekygen.records/autogen-reST-records.rst diff --git a/testing/btest/Baseline/doc.zeekygen.script_index/test.rst b/testing/btest/Baseline/doc.zeekygen.script_index/test.rst new file mode 100644 index 0000000000..1ca04759bb --- /dev/null +++ b/testing/btest/Baseline/doc.zeekygen.script_index/test.rst @@ -0,0 +1,5 @@ +.. toctree:: + :maxdepth: 1 + + zeekygen/__load__.zeek + zeekygen/example.zeek diff --git a/testing/btest/Baseline/doc.zeexygen.script_summary/test.rst b/testing/btest/Baseline/doc.zeekygen.script_summary/test.rst similarity index 71% rename from testing/btest/Baseline/doc.zeexygen.script_summary/test.rst rename to testing/btest/Baseline/doc.zeekygen.script_summary/test.rst index 3dd189ca77..7f3885b86e 100644 --- a/testing/btest/Baseline/doc.zeexygen.script_summary/test.rst +++ b/testing/btest/Baseline/doc.zeekygen.script_summary/test.rst @@ -1,5 +1,5 @@ -:doc:`/scripts/zeexygen/example.zeek` - This is an example script that demonstrates Zeexygen-style +:doc:`/scripts/zeekygen/example.zeek` + This is an example script that demonstrates Zeekygen-style documentation. It generally will make most sense when viewing the script's raw source code and comparing to the HTML-rendered version. @@ -14,10 +14,10 @@ There's also a custom role to reference any identifier node in the Zeek Sphinx domain that's good for "see alsos", e.g. - See also: :zeek:see:`ZeexygenExample::a_var`, - :zeek:see:`ZeexygenExample::ONE`, :zeek:see:`SSH::Info` + See also: :zeek:see:`ZeekygenExample::a_var`, + :zeek:see:`ZeekygenExample::ONE`, :zeek:see:`SSH::Info` And a custom directive does the equivalent references: - .. zeek:see:: ZeexygenExample::a_var ZeexygenExample::ONE SSH::Info + .. zeek:see:: ZeekygenExample::a_var ZeekygenExample::ONE SSH::Info diff --git a/testing/btest/Baseline/doc.zeexygen.type-aliases/autogen-reST-type-aliases.rst b/testing/btest/Baseline/doc.zeekygen.type-aliases/autogen-reST-type-aliases.rst similarity index 60% rename from testing/btest/Baseline/doc.zeexygen.type-aliases/autogen-reST-type-aliases.rst rename to testing/btest/Baseline/doc.zeekygen.type-aliases/autogen-reST-type-aliases.rst index 7f60859a5a..4dfae471c4 100644 --- a/testing/btest/Baseline/doc.zeexygen.type-aliases/autogen-reST-type-aliases.rst +++ b/testing/btest/Baseline/doc.zeekygen.type-aliases/autogen-reST-type-aliases.rst @@ -1,16 +1,16 @@ -.. zeek:type:: ZeexygenTest::TypeAlias +.. zeek:type:: ZeekygenTest::TypeAlias :Type: :zeek:type:`bool` This is just an alias for a builtin type ``bool``. -.. zeek:type:: ZeexygenTest::NotTypeAlias +.. zeek:type:: ZeekygenTest::NotTypeAlias :Type: :zeek:type:`bool` This type should get its own comments, not associated w/ TypeAlias. -.. zeek:type:: ZeexygenTest::OtherTypeAlias +.. zeek:type:: ZeekygenTest::OtherTypeAlias :Type: :zeek:type:`bool` @@ -19,25 +19,25 @@ one doesn't have to click through the full type alias chain to find out what the actual type is... -.. zeek:id:: ZeexygenTest::a +.. zeek:id:: ZeekygenTest::a - :Type: :zeek:type:`ZeexygenTest::TypeAlias` + :Type: :zeek:type:`ZeekygenTest::TypeAlias` But this should reference a type of ``TypeAlias``. -.. zeek:id:: ZeexygenTest::b +.. zeek:id:: ZeekygenTest::b - :Type: :zeek:type:`ZeexygenTest::OtherTypeAlias` + :Type: :zeek:type:`ZeekygenTest::OtherTypeAlias` And this should reference a type of ``OtherTypeAlias``. -.. zeek:type:: ZeexygenTest::MyRecord +.. zeek:type:: ZeekygenTest::MyRecord :Type: :zeek:type:`record` - f1: :zeek:type:`ZeexygenTest::TypeAlias` + f1: :zeek:type:`ZeekygenTest::TypeAlias` - f2: :zeek:type:`ZeexygenTest::OtherTypeAlias` + f2: :zeek:type:`ZeekygenTest::OtherTypeAlias` f3: :zeek:type:`bool` diff --git a/testing/btest/Baseline/doc.zeexygen.vectors/autogen-reST-vectors.rst b/testing/btest/Baseline/doc.zeekygen.vectors/autogen-reST-vectors.rst similarity index 100% rename from testing/btest/Baseline/doc.zeexygen.vectors/autogen-reST-vectors.rst rename to testing/btest/Baseline/doc.zeekygen.vectors/autogen-reST-vectors.rst diff --git a/testing/btest/Baseline/doc.zeexygen.script_index/test.rst b/testing/btest/Baseline/doc.zeexygen.script_index/test.rst deleted file mode 100644 index eab6c439b2..0000000000 --- a/testing/btest/Baseline/doc.zeexygen.script_index/test.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. toctree:: - :maxdepth: 1 - - zeexygen/__load__.zeek - zeexygen/example.zeek diff --git a/testing/btest/Baseline/plugins.hooks/output b/testing/btest/Baseline/plugins.hooks/output index aa27d73819..0fea39bacc 100644 --- a/testing/btest/Baseline/plugins.hooks/output +++ b/testing/btest/Baseline/plugins.hooks/output @@ -785,7 +785,7 @@ 0.000000 MetaHookPost LoadFile(0, .<...>/utils.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, .<...>/variance.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, .<...>/weird.zeek) -> -1 -0.000000 MetaHookPost LoadFile(0, .<...>/zeexygen.bif.zeek) -> -1 +0.000000 MetaHookPost LoadFile(0, .<...>/zeekygen.bif.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, <...>/__load__.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, <...>/__preload__.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, <...>/hooks.zeek) -> -1 @@ -1688,7 +1688,7 @@ 0.000000 MetaHookPre LoadFile(0, .<...>/utils.zeek) 0.000000 MetaHookPre LoadFile(0, .<...>/variance.zeek) 0.000000 MetaHookPre LoadFile(0, .<...>/weird.zeek) -0.000000 MetaHookPre LoadFile(0, .<...>/zeexygen.bif.zeek) +0.000000 MetaHookPre LoadFile(0, .<...>/zeekygen.bif.zeek) 0.000000 MetaHookPre LoadFile(0, <...>/__load__.zeek) 0.000000 MetaHookPre LoadFile(0, <...>/__preload__.zeek) 0.000000 MetaHookPre LoadFile(0, <...>/hooks.zeek) @@ -2599,7 +2599,7 @@ 0.000000 | HookLoadFile .<...>/variance.zeek 0.000000 | HookLoadFile .<...>/video.sig 0.000000 | HookLoadFile .<...>/weird.zeek -0.000000 | HookLoadFile .<...>/zeexygen.bif.zeek +0.000000 | HookLoadFile .<...>/zeekygen.bif.zeek 0.000000 | HookLoadFile <...>/__load__.zeek 0.000000 | HookLoadFile <...>/__preload__.zeek 0.000000 | HookLoadFile <...>/hooks.zeek diff --git a/testing/btest/Baseline/scripts.base.utils.addrs/output b/testing/btest/Baseline/scripts.base.utils.addrs/output index 37afcb4719..37cd37bbb2 100644 --- a/testing/btest/Baseline/scripts.base.utils.addrs/output +++ b/testing/btest/Baseline/scripts.base.utils.addrs/output @@ -1,4 +1,4 @@ -============ test ipv4 regex +============ test ipv4 regex (good strings) T T T @@ -6,9 +6,24 @@ T T T T +T +T +T +T +T +T +T +============ bad ipv4 decimals F F F +F +F +F +============ too many ipv4 decimals +F +F +============ typical looking ipv4 T T ============ test ipv6 regex @@ -30,6 +45,9 @@ T F F F +F +F ============ test extract_ip_addresses() [1.1.1.1, 2.2.2.2, 3.3.3.3] [1.1.1.1, 0:0:0:0:0:0:0:0, 3.3.3.3] +[6:1:2::3:4:5:6] diff --git a/testing/btest/coverage/broxygen.sh b/testing/btest/coverage/broxygen.sh index 4dd12f27fe..6bc43d9c90 100644 --- a/testing/btest/coverage/broxygen.sh +++ b/testing/btest/coverage/broxygen.sh @@ -1,12 +1,12 @@ # This check piggy-backs on the test-all-policy.zeek test, assuming that every # loadable script is referenced there. The only additional check here is -# that the zeexygen package should even load scripts that are commented -# out in test-all-policy.zeek because the zeexygen package is only loaded +# that the zeekygen package should even load scripts that are commented +# out in test-all-policy.zeek because the zeekygen package is only loaded # when generated documentation and will terminate has soon as zeek_init # is handled, even if a script will e.g. put Zeek into listen mode or otherwise # cause it to not terminate after scripts are parsed. -# @TEST-EXEC: bash %INPUT $DIST/scripts/test-all-policy.zeek $DIST/scripts/zeexygen/__load__.zeek +# @TEST-EXEC: bash %INPUT $DIST/scripts/test-all-policy.zeek $DIST/scripts/zeekygen/__load__.zeek error_count=0 @@ -22,10 +22,10 @@ if [ $# -ne 2 ]; then fi all_loads=$(egrep "#[[:space:]]*@load.*" $1 | sed 's/#[[:space:]]*@load[[:space:]]*//g') -zeexygen_loads=$(egrep "@load.*" $2 | sed 's/@load[[:space:]]*//g') +zeekygen_loads=$(egrep "@load.*" $2 | sed 's/@load[[:space:]]*//g') for f in $all_loads; do - echo "$zeexygen_loads" | grep -q $f || error_msg "$f not loaded in zeexygen/__load__.zeek" + echo "$zeekygen_loads" | grep -q $f || error_msg "$f not loaded in zeekygen/__load__.zeek" done if [ $error_count -gt 0 ]; then diff --git a/testing/btest/coverage/sphinx-broxygen-docs.sh b/testing/btest/coverage/sphinx-zeekygen-docs.sh similarity index 85% rename from testing/btest/coverage/sphinx-broxygen-docs.sh rename to testing/btest/coverage/sphinx-zeekygen-docs.sh index d508a8361f..b5e3d7262c 100644 --- a/testing/btest/coverage/sphinx-broxygen-docs.sh +++ b/testing/btest/coverage/sphinx-zeekygen-docs.sh @@ -1,11 +1,11 @@ -# This script checks whether the reST docs generated by zeexygen are stale. +# This script checks whether the reST docs generated by zeekygen are stale. # If this test fails when testing the master branch, then simply run: # -# testing/scripts/gen-zeexygen-docs.sh +# testing/scripts/update-zeekygen-docs.sh # # and then commit the changes. # -# @TEST-EXEC: bash $SCRIPTS/gen-zeexygen-docs.sh ./doc +# @TEST-EXEC: bash $SCRIPTS/update-zeekygen-docs.sh ./doc # @TEST-EXEC: bash %INPUT if [ -n "$TRAVIS_PULL_REQUEST" ]; then @@ -33,7 +33,7 @@ function check_diff echo "If this fails in the master branch or when merging to master," 1>&2 echo "re-run the following command:" 1>&2 echo "" 1>&2 - echo " $SCRIPTS/gen-zeexygen-docs.sh" 1>&2 + echo " $SCRIPTS/update-zeekygen-docs.sh" 1>&2 echo "" 1>&2 echo "Then commit/push the changes in the zeek-docs repo" 1>&2 echo "(the doc/ directory in the zeek repo)." 1>&2 diff --git a/testing/btest/doc/zeexygen/command_line.zeek b/testing/btest/doc/zeekygen/command_line.zeek similarity index 100% rename from testing/btest/doc/zeexygen/command_line.zeek rename to testing/btest/doc/zeekygen/command_line.zeek diff --git a/testing/btest/doc/zeexygen/comment_retrieval_bifs.zeek b/testing/btest/doc/zeekygen/comment_retrieval_bifs.zeek similarity index 100% rename from testing/btest/doc/zeexygen/comment_retrieval_bifs.zeek rename to testing/btest/doc/zeekygen/comment_retrieval_bifs.zeek diff --git a/testing/btest/doc/zeexygen/enums.zeek b/testing/btest/doc/zeekygen/enums.zeek similarity index 89% rename from testing/btest/doc/zeexygen/enums.zeek rename to testing/btest/doc/zeekygen/enums.zeek index a385a36a6c..59115a4631 100644 --- a/testing/btest/doc/zeexygen/enums.zeek +++ b/testing/btest/doc/zeekygen/enums.zeek @@ -1,7 +1,7 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT # @TEST-EXEC: btest-diff autogen-reST-enums.rst -@TEST-START-FILE zeexygen.config +@TEST-START-FILE zeekygen.config identifier TestEnum* autogen-reST-enums.rst @TEST-END-FILE diff --git a/testing/btest/doc/zeekygen/example.zeek b/testing/btest/doc/zeekygen/example.zeek new file mode 100644 index 0000000000..b4c7c713ef --- /dev/null +++ b/testing/btest/doc/zeekygen/example.zeek @@ -0,0 +1,8 @@ +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -X zeekygen.config %INPUT +# @TEST-EXEC: btest-diff example.rst + +@TEST-START-FILE zeekygen.config +script zeekygen/example.zeek example.rst +@TEST-END-FILE + +@load zeekygen/example diff --git a/testing/btest/doc/zeexygen/func-params.zeek b/testing/btest/doc/zeekygen/func-params.zeek similarity index 83% rename from testing/btest/doc/zeexygen/func-params.zeek rename to testing/btest/doc/zeekygen/func-params.zeek index 5facba3e05..2b87aa2ea1 100644 --- a/testing/btest/doc/zeexygen/func-params.zeek +++ b/testing/btest/doc/zeekygen/func-params.zeek @@ -1,7 +1,7 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT # @TEST-EXEC: btest-diff autogen-reST-func-params.rst -@TEST-START-FILE zeexygen.config +@TEST-START-FILE zeekygen.config identifier test_func_params* autogen-reST-func-params.rst @TEST-END-FILE diff --git a/testing/btest/doc/zeekygen/identifier.zeek b/testing/btest/doc/zeekygen/identifier.zeek new file mode 100644 index 0000000000..383c43be09 --- /dev/null +++ b/testing/btest/doc/zeekygen/identifier.zeek @@ -0,0 +1,9 @@ +# @TEST-PORT: BROKER_PORT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT Broker::default_port=$BROKER_PORT +# @TEST-EXEC: btest-diff test.rst + +@TEST-START-FILE zeekygen.config +identifier ZeekygenExample::* test.rst +@TEST-END-FILE + +@load zeekygen diff --git a/testing/btest/doc/zeekygen/package.zeek b/testing/btest/doc/zeekygen/package.zeek new file mode 100644 index 0000000000..7cb30cff21 --- /dev/null +++ b/testing/btest/doc/zeekygen/package.zeek @@ -0,0 +1,9 @@ +# @TEST-PORT: BROKER_PORT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT Broker::default_port=$BROKER_PORT +# @TEST-EXEC: btest-diff test.rst + +@TEST-START-FILE zeekygen.config +package zeekygen test.rst +@TEST-END-FILE + +@load zeekygen diff --git a/testing/btest/doc/zeekygen/package_index.zeek b/testing/btest/doc/zeekygen/package_index.zeek new file mode 100644 index 0000000000..4d746509b5 --- /dev/null +++ b/testing/btest/doc/zeekygen/package_index.zeek @@ -0,0 +1,9 @@ +# @TEST-PORT: BROKER_PORT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT Broker::default_port=$BROKER_PORT +# @TEST-EXEC: btest-diff test.rst + +@TEST-START-FILE zeekygen.config +package_index zeekygen test.rst +@TEST-END-FILE + +@load zeekygen diff --git a/testing/btest/doc/zeexygen/records.zeek b/testing/btest/doc/zeekygen/records.zeek similarity index 84% rename from testing/btest/doc/zeexygen/records.zeek rename to testing/btest/doc/zeekygen/records.zeek index 0c1f668df9..67757f0c61 100644 --- a/testing/btest/doc/zeexygen/records.zeek +++ b/testing/btest/doc/zeekygen/records.zeek @@ -1,7 +1,7 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT # @TEST-EXEC: btest-diff autogen-reST-records.rst -@TEST-START-FILE zeexygen.config +@TEST-START-FILE zeekygen.config identifier TestRecord* autogen-reST-records.rst @TEST-END-FILE diff --git a/testing/btest/doc/zeekygen/script_index.zeek b/testing/btest/doc/zeekygen/script_index.zeek new file mode 100644 index 0000000000..5db6141a0b --- /dev/null +++ b/testing/btest/doc/zeekygen/script_index.zeek @@ -0,0 +1,9 @@ +# @TEST-PORT: BROKER_PORT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT Broker::default_port=$BROKER_PORT +# @TEST-EXEC: btest-diff test.rst + +@TEST-START-FILE zeekygen.config +script_index zeekygen/* test.rst +@TEST-END-FILE + +@load zeekygen diff --git a/testing/btest/doc/zeekygen/script_summary.zeek b/testing/btest/doc/zeekygen/script_summary.zeek new file mode 100644 index 0000000000..c3d647ea0c --- /dev/null +++ b/testing/btest/doc/zeekygen/script_summary.zeek @@ -0,0 +1,9 @@ +# @TEST-PORT: BROKER_PORT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT Broker::default_port=$BROKER_PORT +# @TEST-EXEC: btest-diff test.rst + +@TEST-START-FILE zeekygen.config +script_summary zeekygen/example.zeek test.rst +@TEST-END-FILE + +@load zeekygen diff --git a/testing/btest/doc/zeexygen/type-aliases.zeek b/testing/btest/doc/zeekygen/type-aliases.zeek similarity index 81% rename from testing/btest/doc/zeexygen/type-aliases.zeek rename to testing/btest/doc/zeekygen/type-aliases.zeek index 40a6e24417..e42b953d58 100644 --- a/testing/btest/doc/zeexygen/type-aliases.zeek +++ b/testing/btest/doc/zeekygen/type-aliases.zeek @@ -1,11 +1,11 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT # @TEST-EXEC: btest-diff autogen-reST-type-aliases.rst -@TEST-START-FILE zeexygen.config -identifier ZeexygenTest::* autogen-reST-type-aliases.rst +@TEST-START-FILE zeekygen.config +identifier ZeekygenTest::* autogen-reST-type-aliases.rst @TEST-END-FILE -module ZeexygenTest; +module ZeekygenTest; export { ## This is just an alias for a builtin type ``bool``. diff --git a/testing/btest/doc/zeexygen/vectors.zeek b/testing/btest/doc/zeekygen/vectors.zeek similarity index 83% rename from testing/btest/doc/zeexygen/vectors.zeek rename to testing/btest/doc/zeekygen/vectors.zeek index 8a16a58149..431413a337 100644 --- a/testing/btest/doc/zeexygen/vectors.zeek +++ b/testing/btest/doc/zeekygen/vectors.zeek @@ -1,7 +1,7 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT +# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeekygen.config %INPUT # @TEST-EXEC: btest-diff autogen-reST-vectors.rst -@TEST-START-FILE zeexygen.config +@TEST-START-FILE zeekygen.config identifier test_vector* autogen-reST-vectors.rst @TEST-END-FILE diff --git a/testing/btest/doc/zeexygen/example.zeek b/testing/btest/doc/zeexygen/example.zeek deleted file mode 100644 index 53179dac39..0000000000 --- a/testing/btest/doc/zeexygen/example.zeek +++ /dev/null @@ -1,8 +0,0 @@ -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -X zeexygen.config %INPUT -# @TEST-EXEC: btest-diff example.rst - -@TEST-START-FILE zeexygen.config -script zeexygen/example.zeek example.rst -@TEST-END-FILE - -@load zeexygen/example diff --git a/testing/btest/doc/zeexygen/identifier.zeek b/testing/btest/doc/zeexygen/identifier.zeek deleted file mode 100644 index 38a4f274ad..0000000000 --- a/testing/btest/doc/zeexygen/identifier.zeek +++ /dev/null @@ -1,9 +0,0 @@ -# @TEST-PORT: BROKER_PORT -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT Broker::default_port=$BROKER_PORT -# @TEST-EXEC: btest-diff test.rst - -@TEST-START-FILE zeexygen.config -identifier ZeexygenExample::* test.rst -@TEST-END-FILE - -@load zeexygen diff --git a/testing/btest/doc/zeexygen/package.zeek b/testing/btest/doc/zeexygen/package.zeek deleted file mode 100644 index 7038b5b50a..0000000000 --- a/testing/btest/doc/zeexygen/package.zeek +++ /dev/null @@ -1,9 +0,0 @@ -# @TEST-PORT: BROKER_PORT -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT Broker::default_port=$BROKER_PORT -# @TEST-EXEC: btest-diff test.rst - -@TEST-START-FILE zeexygen.config -package zeexygen test.rst -@TEST-END-FILE - -@load zeexygen diff --git a/testing/btest/doc/zeexygen/package_index.zeek b/testing/btest/doc/zeexygen/package_index.zeek deleted file mode 100644 index 3a0c92ca71..0000000000 --- a/testing/btest/doc/zeexygen/package_index.zeek +++ /dev/null @@ -1,9 +0,0 @@ -# @TEST-PORT: BROKER_PORT -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT Broker::default_port=$BROKER_PORT -# @TEST-EXEC: btest-diff test.rst - -@TEST-START-FILE zeexygen.config -package_index zeexygen test.rst -@TEST-END-FILE - -@load zeexygen diff --git a/testing/btest/doc/zeexygen/script_index.zeek b/testing/btest/doc/zeexygen/script_index.zeek deleted file mode 100644 index f92513d632..0000000000 --- a/testing/btest/doc/zeexygen/script_index.zeek +++ /dev/null @@ -1,9 +0,0 @@ -# @TEST-PORT: BROKER_PORT -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT Broker::default_port=$BROKER_PORT -# @TEST-EXEC: btest-diff test.rst - -@TEST-START-FILE zeexygen.config -script_index zeexygen/* test.rst -@TEST-END-FILE - -@load zeexygen diff --git a/testing/btest/doc/zeexygen/script_summary.zeek b/testing/btest/doc/zeexygen/script_summary.zeek deleted file mode 100644 index 9378417f08..0000000000 --- a/testing/btest/doc/zeexygen/script_summary.zeek +++ /dev/null @@ -1,9 +0,0 @@ -# @TEST-PORT: BROKER_PORT -# @TEST-EXEC: unset BRO_DISABLE_BROXYGEN; bro -b -X zeexygen.config %INPUT Broker::default_port=$BROKER_PORT -# @TEST-EXEC: btest-diff test.rst - -@TEST-START-FILE zeexygen.config -script_summary zeexygen/example.zeek test.rst -@TEST-END-FILE - -@load zeexygen diff --git a/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek b/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek index 3cce7bda1e..70c7203170 100644 --- a/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek +++ b/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek @@ -55,14 +55,26 @@ event connection_established(c: connection) OpenFlow::flow_mod(of_controller, match_rev, flow_mod); } +global msg_count: count = 0; + +function got_message() + { + ++msg_count; + + if ( msg_count == 6 ) + terminate(); + } + event OpenFlow::flow_mod_success(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) { print "Flow_mod_success"; + got_message(); } event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) { print "Flow_mod_failure"; + got_message(); } @TEST-END-FILE @@ -73,13 +85,6 @@ event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_ redef exit_only_after_terminate = T; -global msg_count: count = 0; - -event die() - { - terminate(); - } - event zeek_init() { Broker::subscribe("bro/openflow"); @@ -96,28 +101,16 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) terminate(); } -function got_message() - { - ++msg_count; - - if ( msg_count >= 4 ) - { - schedule 2sec { die() }; - } - } - event OpenFlow::broker_flow_mod(name: string, dpid: count, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod) { print "got flow_mod", dpid, match, flow_mod; Broker::publish("bro/openflow", OpenFlow::flow_mod_success, name, match, flow_mod, ""); Broker::publish("bro/openflow", OpenFlow::flow_mod_failure, name, match, flow_mod, ""); - got_message(); } event OpenFlow::broker_flow_clear(name: string, dpid: count) { print "flow_clear", dpid; - got_message(); } @TEST-END-FILE diff --git a/testing/btest/scripts/base/utils/addrs.test b/testing/btest/scripts/base/utils/addrs.test index 8e5580d3e5..78123e30d5 100644 --- a/testing/btest/scripts/base/utils/addrs.test +++ b/testing/btest/scripts/base/utils/addrs.test @@ -5,23 +5,54 @@ event zeek_init() { + print "============ test ipv4 regex (good strings)"; local ip = "0.0.0.0"; - - print "============ test ipv4 regex"; print ip == ipv4_addr_regex; print is_valid_ip(ip); + ip = "1.1.1.1"; print ip == ipv4_addr_regex; print is_valid_ip(ip); + + ip = "9.9.9.9"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + ip = "99.99.99.99"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + ip = "09.99.99.99"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + ip = "009.99.99.99"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + ip = "255.255.255.255"; print ip == ipv4_addr_regex; print is_valid_ip(ip); + + print "============ bad ipv4 decimals"; ip = "255.255.255.256"; - print ip == ipv4_addr_regex; # the regex doesn't check for 0-255 - print is_valid_ip(ip); # but is_valid_ip() will + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + ip = "255.255.255.295"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + ip = "255.255.255.300"; + print ip == ipv4_addr_regex; + print is_valid_ip(ip); + + print "============ too many ipv4 decimals"; ip = "255.255.255.255.255"; print ip == ipv4_addr_regex; print is_valid_ip(ip); + + print "============ typical looking ipv4"; ip = "192.168.1.100"; print ip == ipv4_addr_regex; print is_valid_ip(ip); @@ -97,8 +128,16 @@ event zeek_init() ip = "2001:db8:0:0:0:FFFF:192.168.0.256"; print is_valid_ip(ip); + # These have too many hextets ("::" must expand to at least one hextet) + print is_valid_ip("6:1:2::3:4:5:6:7"); + print is_valid_ip("6:1:2::3:4:5:6:7:8"); + print "============ test extract_ip_addresses()"; print extract_ip_addresses("this is 1.1.1.1 a test 2.2.2.2 string with ip addresses 3.3.3.3"); print extract_ip_addresses("this is 1.1.1.1 a test 0:0:0:0:0:0:0:0 string with ip addresses 3.3.3.3"); + # This will use the leading 6 from "IPv6" (maybe that's not intended + # by a person trying to parse such a string, but that's just what's going + # to happen; it's on them to deal). + print extract_ip_addresses("IPv6:1:2::3:4:5:6:7"); } diff --git a/testing/scripts/gen-zeexygen-docs.sh b/testing/scripts/update-zeekygen-docs.sh similarity index 88% rename from testing/scripts/gen-zeexygen-docs.sh rename to testing/scripts/update-zeekygen-docs.sh index 66287b01aa..19369ae46a 100755 --- a/testing/scripts/gen-zeexygen-docs.sh +++ b/testing/scripts/update-zeekygen-docs.sh @@ -11,9 +11,9 @@ unset BRO_DEFAULT_CONNECT_RETRY dir="$( cd "$( dirname "$0" )" && pwd )" source_dir="$( cd $dir/../.. && pwd )" build_dir=$source_dir/build -conf_file=$build_dir/zeexygen-test.conf +conf_file=$build_dir/zeekygen-test.conf output_dir=$source_dir/doc -zeek_error_file=$build_dir/zeexygen-test-stderr.txt +zeek_error_file=$build_dir/zeekygen-test-stderr.txt if [ -n "$1" ]; then output_dir=$1 @@ -30,10 +30,10 @@ export BRO_SEED_FILE=$source_dir/testing/btest/random.seed function run_zeek { - ZEEK_ALLOW_INIT_ERRORS=1 bro -X $conf_file zeexygen >/dev/null 2>$zeek_error_file + ZEEK_ALLOW_INIT_ERRORS=1 bro -X $conf_file zeekygen >/dev/null 2>$zeek_error_file if [ $? -ne 0 ]; then - echo "Failed running zeek with zeexygen config file $conf_file" + echo "Failed running zeek with zeekygen config file $conf_file" echo "See stderr in $zeek_error_file" exit 1 fi