diff --git a/CHANGES b/CHANGES index a84e51bfcc..649cc2b503 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +3.1.0-dev.179 | 2019-10-14 21:33:15 -0700 + + * Support whitespace at end of line for config reader (Seth Hall, Corelight) + 3.1.0-dev.177 | 2019-10-14 20:13:24 -0700 * Proof of Concept on Bugprone Narrowing Conversions: Base64 (Dev Bali, Corelight) diff --git a/NEWS b/NEWS index ddc682850e..72c24410e6 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,9 @@ Changed Functionality script logic that inspects the ``qclass`` field of ``DNS::Info`` after a ``dns_request`` event. +- The configuration input reader now ignores trailing spaces at the end of + configuration lines. + Removed Functionality --------------------- diff --git a/VERSION b/VERSION index ec4c90bcba..42f4776c48 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0-dev.177 +3.1.0-dev.179 diff --git a/src/input/readers/config/Config.cc b/src/input/readers/config/Config.cc index d90020e1bf..307ce3cddc 100644 --- a/src/input/readers/config/Config.cc +++ b/src/input/readers/config/Config.cc @@ -199,7 +199,7 @@ bool Config::DoUpdate() } regex_t re; - if ( regcomp(&re, "^([^[:blank:]]+)[[:blank:]]+(.*)$", REG_EXTENDED) ) + if ( regcomp(&re, "^([^[:blank:]]+)[[:blank:]]+(.*[^[:blank:]])?[[:blank:]]*$", REG_EXTENDED) ) { Error(Fmt("Failed to compile regex.")); return true; @@ -215,7 +215,9 @@ bool Config::DoUpdate() } string key = line.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so); - string value = line.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so); + string value; + if ( match[2].rm_so > 0 ) + value = line.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so); auto typeit = option_types.find(key); if ( typeit == option_types.end() ) diff --git a/testing/btest/Baseline/scripts.base.frameworks.config.read_config/zeek.config.log b/testing/btest/Baseline/scripts.base.frameworks.config.read_config/zeek.config.log index fa56b8455e..d8e337f668 100644 --- a/testing/btest/Baseline/scripts.base.frameworks.config.read_config/zeek.config.log +++ b/testing/btest/Baseline/scripts.base.frameworks.config.read_config/zeek.config.log @@ -3,21 +3,22 @@ #empty_field (empty) #unset_field - #path config -#open 2017-10-11-20-47-09 +#open 2019-10-14-15-40-21 #fields ts id old_value new_value location #types time string string string string -1507754829.092788 testbool T F ../configfile -1507754829.092788 testcount 0 1 ../configfile -1507754829.092788 testcount 1 2 ../configfile -1507754829.092788 testint 0 -1 ../configfile -1507754829.092788 testenum SSH::LOG Conn::LOG ../configfile -1507754829.092788 testport 42/tcp 45/unknown ../configfile -1507754829.092788 testaddr 127.0.0.1 127.0.0.1 ../configfile -1507754829.092788 testaddr 127.0.0.1 2607:f8b0:4005:801::200e ../configfile -1507754829.092788 testinterval 1.0 sec 60.0 ../configfile -1507754829.092788 testtime 0.0 1507321987.0 ../configfile -1507754829.092788 test_set (empty) b,c,a,d,erdbeerschnitzel ../configfile -1507754829.092788 test_vector (empty) 1,2,3,4,5,6 ../configfile -1507754829.092788 test_set b,c,a,d,erdbeerschnitzel (empty) ../configfile -1507754829.092788 test_set (empty) \x2d ../configfile -#close 2017-10-11-20-47-09 +1571067621.558501 testbool T F ../configfile +1571067621.558501 testcount 0 1 ../configfile +1571067621.558501 testcount 1 2 ../configfile +1571067621.558501 testint 0 -1 ../configfile +1571067621.558501 testenum SSH::LOG Conn::LOG ../configfile +1571067621.558501 testport 42/tcp 45/unknown ../configfile +1571067621.558501 testaddr 127.0.0.1 127.0.0.1 ../configfile +1571067621.558501 testaddr 127.0.0.1 2607:f8b0:4005:801::200e ../configfile +1571067621.558501 testinterval 1.0 sec 60.0 ../configfile +1571067621.558501 teststring a abc ../configfile +1571067621.558501 testtime 0.0 1507321987.0 ../configfile +1571067621.558501 test_set (empty) b,c,a,d,erdbeerschnitzel ../configfile +1571067621.558501 test_vector (empty) 1,2,3,4,5,6 ../configfile +1571067621.558501 test_set b,c,a,d,erdbeerschnitzel (empty) ../configfile +1571067621.558501 test_set (empty) \x2d ../configfile +#close 2019-10-14-15-40-21 diff --git a/testing/btest/scripts/base/frameworks/config/read_config.zeek b/testing/btest/scripts/base/frameworks/config/read_config.zeek index 8ea2e4690e..caf24e6ffa 100644 --- a/testing/btest/scripts/base/frameworks/config/read_config.zeek +++ b/testing/btest/scripts/base/frameworks/config/read_config.zeek @@ -19,6 +19,7 @@ testport 45 testaddr 127.0.0.1 testaddr 2607:f8b0:4005:801::200e testinterval 60 +teststring abc testtime 1507321987 test_set a,b,c,d,erdbeerschnitzel test_vector 1,2,3,4,5,6 diff --git a/testing/btest/scripts/base/frameworks/input/config/basic.zeek b/testing/btest/scripts/base/frameworks/input/config/basic.zeek index b6f7c2a78a..3ceb0cea9a 100644 --- a/testing/btest/scripts/base/frameworks/input/config/basic.zeek +++ b/testing/btest/scripts/base/frameworks/input/config/basic.zeek @@ -12,11 +12,11 @@ testcount 1 testcount 2 testcount 2 testint -1 -testenum Conn::LOG +testenum Conn::LOG testport 45 testportandproto 45/udp testaddr 127.0.0.1 -testaddr 2607:f8b0:4005:801::200e +testaddr 2607:f8b0:4005:801::200e testinterval 60 testtime 1507321987 test_set a b c d erdbeerschnitzel