From 5c858b46bc04bc18827fcf8779d9a7b0eed58649 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Fri, 27 Jan 2017 11:01:33 -0800 Subject: [PATCH] Fix writing empty strings. Also move version to 0.2 and move out of the Bro namespace. --- VERSION | 2 +- src/Plugin.cc | 6 +++--- src/Plugin.h | 2 +- src/PostgresWriter.cc | 3 --- tests/Baseline/postgres.write-basic/ssh.out | 12 ++++++------ tests/postgres/write-basic.bro | 4 +++- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index 49d5957..3b04cfb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1 +0.2 diff --git a/src/Plugin.cc b/src/Plugin.cc index 91ea82f..fc2e218 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -3,9 +3,9 @@ #include "PostgresWriter.h" #include "PostgresReader.h" -namespace plugin { namespace Bro_PostgreSQL { Plugin plugin; } } +namespace plugin { namespace Johanna_PostgreSQL { Plugin plugin; } } -using namespace plugin::Bro_PostgreSQL; +using namespace plugin::Johanna_PostgreSQL; plugin::Configuration Plugin::Configure() { @@ -16,6 +16,6 @@ plugin::Configuration Plugin::Configure() config.name = "Bro::PostgreSQL"; config.description = "PostgreSQL log writer and input reader"; config.version.major = 0; - config.version.minor = 1; + config.version.minor = 2; return config; } diff --git a/src/Plugin.h b/src/Plugin.h index d2093c6..7144044 100644 --- a/src/Plugin.h +++ b/src/Plugin.h @@ -5,7 +5,7 @@ #include namespace plugin { -namespace Bro_PostgreSQL { +namespace Johanna_PostgreSQL { class Plugin : public ::plugin::Plugin { diff --git a/src/PostgresWriter.cc b/src/PostgresWriter.cc index b8d0500..3508826 100644 --- a/src/PostgresWriter.cc +++ b/src/PostgresWriter.cc @@ -303,9 +303,6 @@ std::tuple PostgreSQL::CreateParams(const Value* val) case TYPE_STRING: case TYPE_FILE: case TYPE_FUNC: - if ( ! val->val.string_val.length || val->val.string_val.length == 0 ) - return std::make_tuple(false, string(), 0); - retval = string(val->val.string_val.data, val->val.string_val.length); break; diff --git a/tests/Baseline/postgres.write-basic/ssh.out b/tests/Baseline/postgres.write-basic/ssh.out index a5edf8d..1e6108a 100644 --- a/tests/Baseline/postgres.write-basic/ssh.out +++ b/tests/Baseline/postgres.write-basic/ssh.out @@ -1,19 +1,19 @@ -id|b|i|e|c|p|sn|a|d|t|iv|s|sc|ss|se|vc|ve|f -1|t|-42|SSH::LOG|21|123|10.0.0.0/24|1.2.3.4|3.14|1485448463.53086|100|hurz|{2,4,1,3}|{BB,AA,CC}||{10,20,30}||SSHTest::foo +id|b|i|e|c|p|sn|a|d|t|iv|s|sc|ss|se|vc|ve|f|vo|so +1|t|-42|SSH::LOG|21|123|10.0.0.0/24|1.2.3.4|3.14|1485543658.08752|100|hurz|{2,4,1,3}|{BB,AA,CC}||{10,20,30}||SSHTest::foo { if (0 < SSHTest::i) return (Foo); else return (Bar); -} -2|t|-42|SSH::LOG|21|123|10.0.0.0/24|1.2.3.4|3.14|1485448463.53086|100|hurz|{2,4,1,3}|{"{\"\"\\hello","a b -c d~e","\\\"\\{}","{{{{{}'","\""}||{10,20,30}||SSHTest::foo +}|| +2|t|-42|SSH::LOG|21|123|10.0.0.0/24|1.2.3.4|3.14|1485543658.08752|100|hurz|{2,4,1,3}|{"{\"\"\\hello","a b +c d~e","\\\"\\{}","{{{{{}'","","\""}||{10,20,30}||SSHTest::foo { if (0 < SSHTest::i) return (Foo); else return (Bar); -} +}|| (2 rows) diff --git a/tests/postgres/write-basic.bro b/tests/postgres/write-basic.bro index e376d5a..331cf33 100644 --- a/tests/postgres/write-basic.bro +++ b/tests/postgres/write-basic.bro @@ -35,6 +35,8 @@ export { vc: vector of count; ve: vector of string; f: function(i: count) : string; + vo: vector of string &optional; + so: string &optional; } &log; } @@ -88,7 +90,7 @@ event bro_init() $iv=100secs, $s="hurz", $sc=set(1,2,3,4), - $ss=set("\\\"\\{}", "\"", "{{{{{}'", "{\"\"\\hello", "a\tb\nc\rd\x01\x02\x03\x7Ee"), + $ss=set("", "\\\"\\{}", "\"", "{{{{{}'", "{\"\"\\hello", "a\tb\nc\rd\x01\x02\x03\x7Ee"), $se=empty_set, $vc=vector(10, 20, 30), $ve=empty_vector,