Merge remote-tracking branch 'origin/topic/seth/624'

* origin/topic/seth/624:
  Support whitespace at end of line for config reader.

This merge fixes a failing test; it also sprinkles a few more spaces
into another test file.

The main change is that this now also works with configuration lines
that don't have a value.
This commit is contained in:
Johanna Amann 2019-10-14 21:26:17 -07:00
commit 66effde97d
7 changed files with 32 additions and 21 deletions

View file

@ -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 3.1.0-dev.177 | 2019-10-14 20:13:24 -0700
* Proof of Concept on Bugprone Narrowing Conversions: Base64 (Dev Bali, Corelight) * Proof of Concept on Bugprone Narrowing Conversions: Base64 (Dev Bali, Corelight)

3
NEWS
View file

@ -32,6 +32,9 @@ Changed Functionality
script logic that inspects the ``qclass`` field of ``DNS::Info`` script logic that inspects the ``qclass`` field of ``DNS::Info``
after a ``dns_request`` event. after a ``dns_request`` event.
- The configuration input reader now ignores trailing spaces at the end of
configuration lines.
Removed Functionality Removed Functionality
--------------------- ---------------------

View file

@ -1 +1 @@
3.1.0-dev.177 3.1.0-dev.179

View file

@ -199,7 +199,7 @@ bool Config::DoUpdate()
} }
regex_t re; 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.")); Error(Fmt("Failed to compile regex."));
return true; 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 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); auto typeit = option_types.find(key);
if ( typeit == option_types.end() ) if ( typeit == option_types.end() )

View file

@ -3,21 +3,22 @@
#empty_field (empty) #empty_field (empty)
#unset_field - #unset_field -
#path config #path config
#open 2017-10-11-20-47-09 #open 2019-10-14-15-40-21
#fields ts id old_value new_value location #fields ts id old_value new_value location
#types time string string string string #types time string string string string
1507754829.092788 testbool T F ../configfile 1571067621.558501 testbool T F ../configfile
1507754829.092788 testcount 0 1 ../configfile 1571067621.558501 testcount 0 1 ../configfile
1507754829.092788 testcount 1 2 ../configfile 1571067621.558501 testcount 1 2 ../configfile
1507754829.092788 testint 0 -1 ../configfile 1571067621.558501 testint 0 -1 ../configfile
1507754829.092788 testenum SSH::LOG Conn::LOG ../configfile 1571067621.558501 testenum SSH::LOG Conn::LOG ../configfile
1507754829.092788 testport 42/tcp 45/unknown ../configfile 1571067621.558501 testport 42/tcp 45/unknown ../configfile
1507754829.092788 testaddr 127.0.0.1 127.0.0.1 ../configfile 1571067621.558501 testaddr 127.0.0.1 127.0.0.1 ../configfile
1507754829.092788 testaddr 127.0.0.1 2607:f8b0:4005:801::200e ../configfile 1571067621.558501 testaddr 127.0.0.1 2607:f8b0:4005:801::200e ../configfile
1507754829.092788 testinterval 1.0 sec 60.0 ../configfile 1571067621.558501 testinterval 1.0 sec 60.0 ../configfile
1507754829.092788 testtime 0.0 1507321987.0 ../configfile 1571067621.558501 teststring a abc ../configfile
1507754829.092788 test_set (empty) b,c,a,d,erdbeerschnitzel ../configfile 1571067621.558501 testtime 0.0 1507321987.0 ../configfile
1507754829.092788 test_vector (empty) 1,2,3,4,5,6 ../configfile 1571067621.558501 test_set (empty) b,c,a,d,erdbeerschnitzel ../configfile
1507754829.092788 test_set b,c,a,d,erdbeerschnitzel (empty) ../configfile 1571067621.558501 test_vector (empty) 1,2,3,4,5,6 ../configfile
1507754829.092788 test_set (empty) \x2d ../configfile 1571067621.558501 test_set b,c,a,d,erdbeerschnitzel (empty) ../configfile
#close 2017-10-11-20-47-09 1571067621.558501 test_set (empty) \x2d ../configfile
#close 2019-10-14-15-40-21

View file

@ -19,6 +19,7 @@ testport 45
testaddr 127.0.0.1 testaddr 127.0.0.1
testaddr 2607:f8b0:4005:801::200e testaddr 2607:f8b0:4005:801::200e
testinterval 60 testinterval 60
teststring abc
testtime 1507321987 testtime 1507321987
test_set a,b,c,d,erdbeerschnitzel test_set a,b,c,d,erdbeerschnitzel
test_vector 1,2,3,4,5,6 test_vector 1,2,3,4,5,6