diff --git a/CHANGES b/CHANGES index 15184aa4ac..0eade57028 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,10 @@ +2.5-950 | 2018-08-31 08:54:36 -0700 + + * Add @deprecated directive and deprecate policy/protocols/smb/__load__.bro + + @deprecated a warning stating that the script is deprecated. (Jon Siwek, Corelight) + 2.5-947 | 2018-08-30 16:05:36 -0500 * Allow loading policy/protocols/smb once again (Jon Siwek, Corelight) @@ -11,7 +17,7 @@ * Introduce ssl_plaintext_data event, replacing ssl_application_data event. (Johanna Amann) - + * Add record layer version to event ssl_encrypted_data. (Johanna Amann) * Add compression methods to ssl_client_hello event. (Johanna Amann) diff --git a/NEWS b/NEWS index 86839427b1..338c20d351 100644 --- a/NEWS +++ b/NEWS @@ -348,6 +348,9 @@ New Functionality with &redef by appending the result of expressions "a", "b", and "c" to the vector at initialization-time. +- A new @deprecated directive was added. It marks a script-file as + deprecated. + Changed Functionality --------------------- diff --git a/VERSION b/VERSION index ecd34e707f..5097186c1d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5-947 +2.5-950 diff --git a/doc/script-reference/directives.rst b/doc/script-reference/directives.rst index b56967ff3d..e515cf8bdb 100644 --- a/doc/script-reference/directives.rst +++ b/doc/script-reference/directives.rst @@ -27,6 +27,16 @@ executed. Directives are evaluated before script execution begins. print "File:", @FILENAME; +.. bro:keyword:: @deprecated + + Marks the current script as deprecated. This can be placed anywhere in + the script, but a good convention is to put it as the first line. + You can also supply additional comments. + + Example:: + + @deprecated "Use '@load foo' instead" + .. bro:keyword:: @load Loads the specified Bro script, specified as the relative pathname diff --git a/scripts/broxygen/__load__.bro b/scripts/broxygen/__load__.bro index 2c89631e76..5d4ac5ea03 100644 --- a/scripts/broxygen/__load__.bro +++ b/scripts/broxygen/__load__.bro @@ -7,6 +7,7 @@ @load frameworks/files/extract-all-files.bro @load policy/misc/dump-events.bro @load policy/protocols/dhcp/deprecated_events.bro +@load policy/protocols/smb/__load__.bro @load ./example.bro diff --git a/scripts/policy/protocols/smb/__load__.bro b/scripts/policy/protocols/smb/__load__.bro index 8fd733d382..9e826f7fd6 100644 --- a/scripts/policy/protocols/smb/__load__.bro +++ b/scripts/policy/protocols/smb/__load__.bro @@ -1 +1,3 @@ +@deprecated "Use '@load base/protocols/smb' instead" + @load base/protocols/smb diff --git a/scripts/test-all-policy.bro b/scripts/test-all-policy.bro index d31da65734..c3c2941b06 100644 --- a/scripts/test-all-policy.bro +++ b/scripts/test-all-policy.bro @@ -82,7 +82,7 @@ @load protocols/modbus/track-memmap.bro @load protocols/mysql/software.bro @load protocols/rdp/indicate_ssl.bro -@load protocols/smb/__load__.bro +#@load protocols/smb/__load__.bro @load protocols/smb/log-cmds.bro @load protocols/smtp/blocklists.bro @load protocols/smtp/detect-suspicious-orig.bro diff --git a/src/scan.l b/src/scan.l index ffdec4d640..9e0e5f75fc 100644 --- a/src/scan.l +++ b/src/scan.l @@ -315,6 +315,23 @@ when return TOK_WHEN; return TOK_ATTR_SYNCHRONIZED; } +@deprecated.* { + auto num_files = file_stack.length(); + auto comment = skip_whitespace(yytext + 11); + + if ( num_files > 0 ) + { + auto lf = file_stack[num_files - 1]; + + if ( lf->name ) + reporter->Warning("deprecated script loaded from %s:%d %s", + lf->name, lf->line, comment); + else + reporter->Warning("deprecated script loaded from command line arguments %s", comment); + } + else + reporter->Warning("deprecated script loaded %s", comment); + } @DEBUG return TOK_DEBUG; // marks input for debugger diff --git a/testing/btest/Baseline/coverage.bare-mode-errors/errors b/testing/btest/Baseline/coverage.bare-mode-errors/errors index 8664c8a4d1..e11a4ca00f 100644 --- a/testing/btest/Baseline/coverage.bare-mode-errors/errors +++ b/testing/btest/Baseline/coverage.bare-mode-errors/errors @@ -1,16 +1,18 @@ -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) -warning in /home/jon/projects/bro/bro/testing/btest/../../scripts/policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/smb/__load__.bro, line 1: deprecated script loaded from /Users/jon/projects/bro/bro/testing/btest/../../scripts//broxygen/__load__.bro:10 "Use '@load base/protocols/smb' instead" +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) +warning in /Users/jon/projects/bro/bro/testing/btest/../../scripts//policy/protocols/smb/__load__.bro, line 1: deprecated script loaded from command line arguments "Use '@load base/protocols/smb' instead" diff --git a/testing/btest/Baseline/doc.broxygen.all_scripts/.stderr b/testing/btest/Baseline/doc.broxygen.all_scripts/.stderr index 34c0d82da2..da6c357abf 100644 --- a/testing/btest/Baseline/doc.broxygen.all_scripts/.stderr +++ b/testing/btest/Baseline/doc.broxygen.all_scripts/.stderr @@ -1,10 +1,11 @@ -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) -warning in /home/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) -error in /home/jon/projects/bro/bro/scripts/policy/frameworks/control/controller.bro, line 22: The '' control command is unknown. +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 245: deprecated (dhcp_discover) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 248: deprecated (dhcp_offer) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 251: deprecated (dhcp_request) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 254: deprecated (dhcp_decline) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 257: deprecated (dhcp_ack) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 260: deprecated (dhcp_nak) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 263: deprecated (dhcp_release) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/dhcp/deprecated_events.bro, line 266: deprecated (dhcp_inform) +warning in /Users/jon/projects/bro/bro/scripts/policy/protocols/smb/__load__.bro, line 1: deprecated script loaded from /Users/jon/projects/bro/bro/scripts/broxygen/__load__.bro:10 "Use '@load base/protocols/smb' instead" +error in /Users/jon/projects/bro/bro/scripts/policy/frameworks/control/controller.bro, line 22: The '' control command is unknown. , line 1: received termination signal diff --git a/testing/btest/Baseline/language.at-deprecated/.stderr b/testing/btest/Baseline/language.at-deprecated/.stderr new file mode 100644 index 0000000000..4668f2d7bf --- /dev/null +++ b/testing/btest/Baseline/language.at-deprecated/.stderr @@ -0,0 +1,3 @@ +warning in ./foo.bro, line 1: deprecated script loaded from command line arguments +warning in ./bar.bro, line 1: deprecated script loaded from ./foo.bro:2 "Use '@load qux.bro' instead" +warning in ./baz.bro, line 1: deprecated script loaded from ./foo.bro:3 diff --git a/testing/btest/language/at-deprecated.bro b/testing/btest/language/at-deprecated.bro new file mode 100644 index 0000000000..dd0f746658 --- /dev/null +++ b/testing/btest/language/at-deprecated.bro @@ -0,0 +1,16 @@ +# @TEST-EXEC: bro -b foo +# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr + +@TEST-START-FILE foo.bro +@deprecated +@load bar +@load baz +@TEST-END-FILE + +@TEST-START-FILE bar.bro +@deprecated "Use '@load qux.bro' instead" +@TEST-END-FILE + +@TEST-START-FILE baz.bro +@deprecated +@TEST-END-FILE