mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
...and another small change to error handling -> now errors in single lines
do not kill processing, but simply ignore the line, log it, and continue.
This commit is contained in:
parent
5c486dae7e
commit
56fa56ffa9
4 changed files with 32 additions and 20 deletions
|
@ -228,7 +228,7 @@ bool Ascii::CheckNumberError(const string & s, const char * end)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( endnotnull )
|
if ( endnotnull )
|
||||||
Error(Fmt("Number '%s' contained non-numeric trailing characters. Ignored trailing characters '%s'", s.c_str(), end));
|
Warning(Fmt("Number '%s' contained non-numeric trailing characters. Ignored trailing characters '%s'", s.c_str(), end));
|
||||||
|
|
||||||
if ( errno == EINVAL )
|
if ( errno == EINVAL )
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,10 @@ bool Ascii::CheckNumberError(const string & s, const char * end)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( errno == ERANGE )
|
else if ( errno == ERANGE )
|
||||||
Error(Fmt("Number '%s' out of supported range. Number was truncated", s.c_str()));
|
{
|
||||||
|
Error(Fmt("Number '%s' out of supported range.", s.c_str()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -492,6 +495,7 @@ bool Ascii::DoUpdate()
|
||||||
while ( GetLine(line ) )
|
while ( GetLine(line ) )
|
||||||
{
|
{
|
||||||
// split on tabs
|
// split on tabs
|
||||||
|
bool error = false;
|
||||||
istringstream splitstream(line);
|
istringstream splitstream(line);
|
||||||
|
|
||||||
map<int, string> stringfields;
|
map<int, string> stringfields;
|
||||||
|
@ -537,8 +541,9 @@ bool Ascii::DoUpdate()
|
||||||
Value* val = EntryToVal(stringfields[(*fit).position], *fit);
|
Value* val = EntryToVal(stringfields[(*fit).position], *fit);
|
||||||
if ( val == 0 )
|
if ( val == 0 )
|
||||||
{
|
{
|
||||||
Error(Fmt("Could not convert line '%s' to Val. Aborting file read.", line.c_str()));
|
Error(Fmt("Could not convert line '%s' to Val. Ignoring line.", line.c_str()));
|
||||||
return false;
|
error = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (*fit).secondary_position != -1 )
|
if ( (*fit).secondary_position != -1 )
|
||||||
|
@ -555,6 +560,21 @@ bool Ascii::DoUpdate()
|
||||||
fpos++;
|
fpos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( error )
|
||||||
|
{
|
||||||
|
// encountered non-fatal error. ignoring line.
|
||||||
|
// first - delete all successfully read fields and the array structure.
|
||||||
|
|
||||||
|
for ( int i = 0; i < fpos; i++ )
|
||||||
|
delete fields[fpos];
|
||||||
|
|
||||||
|
delete[] fields;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//printf("fpos: %d, second.num_fields: %d\n", fpos, (*it).second.num_fields);
|
//printf("fpos: %d, second.num_fields: %d\n", fpos, (*it).second.num_fields);
|
||||||
assert ( fpos == NumFields() );
|
assert ( fpos == NumFields() );
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: ../input.log/Input::READER_ASCII: Number '12129223372036854775800' out of supported range. Number was truncated
|
error: ../input.log/Input::READER_ASCII: Number '12129223372036854775800' out of supported range.
|
||||||
error: ../input.log/Input::READER_ASCII: Number '121218446744073709551612' out of supported range. Number was truncated
|
error: ../input.log/Input::READER_ASCII: Could not convert line '12129223372036854775800 121218446744073709551612' to Val. Ignoring line.
|
||||||
error: ../input.log/Input::READER_ASCII: Number '9223372036854775801TEXTHERE' contained non-numeric trailing characters. Ignored trailing characters 'TEXTHERE'
|
warning: ../input.log/Input::READER_ASCII: Number '9223372036854775801TEXTHERE' contained non-numeric trailing characters. Ignored trailing characters 'TEXTHERE'
|
||||||
error: ../input.log/Input::READER_ASCII: Number '1Justtext' contained non-numeric trailing characters. Ignored trailing characters 'Justtext'
|
warning: ../input.log/Input::READER_ASCII: Number '1Justtext' contained non-numeric trailing characters. Ignored trailing characters 'Justtext'
|
||||||
error: ../input2.log/Input::READER_ASCII: String 'Justtext' contained no parseable number
|
error: ../input.log/Input::READER_ASCII: String 'Justtext' contained no parseable number
|
||||||
error: ../input2.log/Input::READER_ASCII: Could not convert line 'Justtext 1' to Val. Aborting file read.
|
error: ../input.log/Input::READER_ASCII: Could not convert line 'Justtext 1' to Val. Ignoring line.
|
||||||
received termination signal
|
received termination signal
|
||||||
>>>
|
>>>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
[9223372036854775807] = [c=18446744073709551615],
|
|
||||||
[9223372036854775800] = [c=4],
|
[9223372036854775800] = [c=4],
|
||||||
[9223372036854775801] = [c=1]
|
[9223372036854775801] = [c=1]
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,17 +13,10 @@
|
||||||
#types int count
|
#types int count
|
||||||
12129223372036854775800 121218446744073709551612
|
12129223372036854775800 121218446744073709551612
|
||||||
9223372036854775801TEXTHERE 1Justtext
|
9223372036854775801TEXTHERE 1Justtext
|
||||||
|
Justtext 1
|
||||||
9223372036854775800 -18446744073709551612
|
9223372036854775800 -18446744073709551612
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@TEST-START-FILE input2.log
|
|
||||||
#separator \x09
|
|
||||||
#fields i c
|
|
||||||
#types int count
|
|
||||||
Justtext 1
|
|
||||||
@TEST-END-FILE
|
|
||||||
|
|
||||||
|
|
||||||
@load frameworks/communication/listen
|
@load frameworks/communication/listen
|
||||||
|
|
||||||
global outfile: file;
|
global outfile: file;
|
||||||
|
@ -51,5 +44,5 @@ event bro_init()
|
||||||
event Input::update_finished(name: string, source:string)
|
event Input::update_finished(name: string, source:string)
|
||||||
{
|
{
|
||||||
print outfile, servers;
|
print outfile, servers;
|
||||||
Input::add_table([$source="../input2.log", $name="ssh2", $idx=Idx, $val=Val, $destination=servers]);
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue