Merge remote-tracking branch 'origin/topic/dev/non-ascii-logging'

* origin/topic/dev/non-ascii-logging:
  Removed Policy Script for UTF-8 Logs
  Commented out UTF-8 Script in Test All Policy
  Minor Style Tweak
  Use getNumBytesForUTF8 method to determine number of bytes
  Added Jon's test cases as unit tests
  Prioritizes escaping predefined Escape Sequences over Unescaping UTF-8 Sequences
  Added additional check to confirm anything unescaping is a multibyte UTF-8 sequence, addressing the test case Jon brought up
  Added optional script and redef bool to enable utf-8 in ASCII logs
  Initial Commit, removed std::isprint check to escape

Made minor code format and logic adjustments during merge.
This commit is contained in:
Jon Siwek 2019-07-30 19:36:56 -07:00
commit d1770853b3
16 changed files with 181 additions and 3 deletions

View file

@ -0,0 +1,21 @@
#
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff test.log
redef LogAscii::enable_utf_8 = T;
module Test;
export {
redef enum Log::ID += { LOG };
type Log: record {
s: string;
} &log;
}
event zeek_init()
{
local a = "foo \n\t\0 bar";
Log::create_stream(Test::LOG, [$columns=Log]);
Log::write(Test::LOG, [$s=a]);
}

View file

@ -0,0 +1,23 @@
#
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff test.log
redef LogAscii::enable_utf_8 = T;
redef LogAscii::set_separator = "\xc2\xae";
module Test;
export {
redef enum Log::ID += { LOG };
type Log: record {
ss: set[string];
} &log;
}
event zeek_init()
{
Log::create_stream(Test::LOG, [$columns=Log]);
Log::write(Test::LOG, [$ss=set("\xc2\xae")]);
}

View file

@ -0,0 +1,26 @@
#
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff test.log
redef LogAscii::enable_utf_8 = T;
module Test;
export {
redef enum Log::ID += { LOG };
type Log: record {
s: string;
} &log;
}
event zeek_init()
{
local a = "foo \xc2\xae bar"; # 2 bytes
local b = "दुनिया को नमस्ते"; # Hindi characters are 3 byte utf-8
local c = "hello 𠜎"; # A 4 byte Chinese character
Log::create_stream(Test::LOG, [$columns=Log]);
Log::write(Test::LOG, [$s=a]);
Log::write(Test::LOG, [$s=b]);
Log::write(Test::LOG, [$s=c]);
}