mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/parse-only-usage-errors'
* origin/topic/jsiwek/parse-only-usage-errors: Allow --parse-only to work with --usage-issues flag
This commit is contained in:
commit
419c68b188
8 changed files with 48 additions and 7 deletions
13
CHANGES
13
CHANGES
|
@ -1,4 +1,17 @@
|
||||||
|
|
||||||
|
4.1.0-dev.216 | 2021-02-08 13:06:07 -0800
|
||||||
|
|
||||||
|
* Allow --parse-only to work with --usage-issues flag (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Use of --parse-only would previously exit before --usage-issues had a
|
||||||
|
chance to analyze scripts and report any discovered issues and it can be
|
||||||
|
useful to combine both flags for checking scripts for mistakes without
|
||||||
|
actually executing any code.
|
||||||
|
|
||||||
|
This also improves the behavior of --parse-only in combination with
|
||||||
|
reporting problems in signature files (previously, it exited before
|
||||||
|
even reading them).
|
||||||
|
|
||||||
4.1.0-dev.212 | 2021-02-05 10:56:23 -0800
|
4.1.0-dev.212 | 2021-02-05 10:56:23 -0800
|
||||||
|
|
||||||
* Support for Zeek script "Reaching Definitions" (RD) analysis (Vern Paxson, Corelight)
|
* Support for Zeek script "Reaching Definitions" (RD) analysis (Vern Paxson, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.1.0-dev.212
|
4.1.0-dev.216
|
||||||
|
|
|
@ -680,12 +680,6 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
file_mgr->InitPostScript();
|
file_mgr->InitPostScript();
|
||||||
dns_mgr->InitPostScript();
|
dns_mgr->InitPostScript();
|
||||||
|
|
||||||
if ( options.parse_only )
|
|
||||||
{
|
|
||||||
int rc = (reporter->Errors() > 0 ? 1 : 0);
|
|
||||||
exit(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_PERFTOOLS_DEBUG
|
#ifdef USE_PERFTOOLS_DEBUG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -764,6 +758,9 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
// This option is report-and-exit.
|
// This option is report-and-exit.
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
if ( options.parse_only )
|
||||||
|
exit(reporter->Errors() != 0);
|
||||||
|
|
||||||
if ( dns_type != DNS_PRIME )
|
if ( dns_type != DNS_PRIME )
|
||||||
run_state::detail::init_run(options.interface, options.pcap_file, options.pcap_output_file, options.use_watchdog);
|
run_state::detail::init_run(options.interface, options.pcap_file, options.pcap_output_file, options.use_watchdog);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error: Error in signature (./test.sig:1): syntax error
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error: Can't open signature file nope
|
2
testing/btest/Baseline/core.parse-only-usage-issues/out
Normal file
2
testing/btest/Baseline/core.parse-only-usage-issues/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
warning in <...>/parse-only-usage-issues.zeek, line 8: possibly used without definition (a)
|
15
testing/btest/core/parse-only-signature-file-issues.zeek
Normal file
15
testing/btest/core/parse-only-signature-file-issues.zeek
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# @TEST-DOC: ``zeek -a`` should parse scripts and also still detect signature file issues.
|
||||||
|
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b -a -s nope %INPUT >missing-sig-file 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff missing-sig-file
|
||||||
|
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b -a test.zeek >invalid-sig-file 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff invalid-sig-file
|
||||||
|
|
||||||
|
@TEST-START-FILE test.zeek
|
||||||
|
@load-sigs test.sig
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE test.sig
|
||||||
|
invalid
|
||||||
|
@TEST-END-FILE
|
9
testing/btest/core/parse-only-usage-issues.zeek
Normal file
9
testing/btest/core/parse-only-usage-issues.zeek
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# @TEST-DOC: ``zeek -a -u`` should detect usage issues without executing code
|
||||||
|
# @TEST-EXEC: zeek -b -a -u %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local a: count;
|
||||||
|
print a;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue