testing/btest/*js: Comment all @TEST lines

This commit is contained in:
Arne Welzel 2025-04-17 15:46:21 +02:00
parent 86249db2a3
commit 51f504b38f
4 changed files with 15 additions and 14 deletions

View file

@ -15,8 +15,8 @@ zeek.on('file_state_remove', (f) => {
f.info.from_js = "Hello from JavaScript"; f.info.from_js = "Hello from JavaScript";
}); });
@TEST-START-FILE ext.zeek // @TEST-START-FILE ext.zeek
redef record Files::Info += { redef record Files::Info += {
from_js: string &log &optional; from_js: string &log &optional;
}; };
@TEST-END-FILE // @TEST-END-FILE

View file

@ -3,7 +3,7 @@
* @TEST-EXEC: zeek -b -Cr $TRACES/http/get.trace main.zeek LogAscii::use_json=T * @TEST-EXEC: zeek -b -Cr $TRACES/http/get.trace main.zeek LogAscii::use_json=T
* @TEST-EXEC: btest-diff http.log * @TEST-EXEC: btest-diff http.log
*/ */
@TEST-START-FILE main.zeek // @TEST-START-FILE main.zeek
@load base/protocols/http @load base/protocols/http
# Extending log records only works in Zeek script. # Extending log records only works in Zeek script.
@ -14,9 +14,9 @@ redef record HTTP::Info += {
# Load the JavaScript pieces # Load the JavaScript pieces
@load ./main.js @load ./main.js
@TEST-END-FILE // @TEST-END-FILE
@TEST-START-FILE main.js // @TEST-START-FILE main.js
const crypto = require('crypto'); const crypto = require('crypto');
/* /*
@ -27,4 +27,4 @@ const crypto = require('crypto');
zeek.on('http_request', { priority: -10 }, (c, method, orig_URI, escaped_URI, version) => { zeek.on('http_request', { priority: -10 }, (c, method, orig_URI, escaped_URI, version) => {
c.http.uri_sha256 = crypto.createHash('sha256').update(orig_URI).digest().toString('hex'); c.http.uri_sha256 = crypto.createHash('sha256').update(orig_URI).digest().toString('hex');
}); });
@TEST-END-FILE // @TEST-END-FILE

View file

@ -5,12 +5,13 @@
* @TEST-EXEC: zeek-cut < intel.log > intel.log.noheader * @TEST-EXEC: zeek-cut < intel.log > intel.log.noheader
* @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff intel.log.noheader * @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff intel.log.noheader
* *
* Following the intel file that we load via Intel::insert(). */
@TEST-START-FILE intel.json_lines
// Following the intel file that we load via Intel::insert().
// @TEST-START-FILE intel.json_lines
{"indicator": "141.142.228.5", "indicator_type": "Intel::ADDR", "meta": {"source": "json1"}} {"indicator": "141.142.228.5", "indicator_type": "Intel::ADDR", "meta": {"source": "json1"}}
{"indicator": "bro.org", "indicator_type": "Intel::DOMAIN", "meta": {"source": "json2"}} {"indicator": "bro.org", "indicator_type": "Intel::DOMAIN", "meta": {"source": "json2"}}
@TEST-END-FILE // @TEST-END-FILE
*/
const fs = require('fs'); const fs = require('fs');
zeek.on('zeek_init', () => { zeek.on('zeek_init', () => {

View file

@ -6,7 +6,7 @@
* @TEST-EXEC: zeek-cut -m ts uid id.orig_h id.resp_h new_field < http.log > http.log.cut * @TEST-EXEC: zeek-cut -m ts uid id.orig_h id.resp_h new_field < http.log > http.log.cut
* @TEST-EXEC: btest-diff http.log.cut * @TEST-EXEC: btest-diff http.log.cut
*/ */
@TEST-START-FILE main.zeek // @TEST-START-FILE main.zeek
@load base/protocols/http @load base/protocols/http
redef record HTTP::Info += { redef record HTTP::Info += {
@ -15,9 +15,9 @@ redef record HTTP::Info += {
# Load the JavaScript pieces # Load the JavaScript pieces
@load ./main.js @load ./main.js
@TEST-END-FILE // @TEST-END-FILE
@TEST-START-FILE main.js // @TEST-START-FILE main.js
zeek.hook('Log::log_stream_policy', (rec, id) => { zeek.hook('Log::log_stream_policy', (rec, id) => {
if ( id != "HTTP::LOG" ) if ( id != "HTTP::LOG" )
return; return;
@ -50,4 +50,4 @@ setTimeout(() => {
console.error('force exit'); console.error('force exit');
process.exit(1); process.exit(1);
}, 5000); }, 5000);
@TEST-END-FILE // @TEST-END-FILE