Skip to content

LOGMON-240/VDB-5981 treating last part of OP log as freeform, port an… #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: engineering
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions parser/aws/AWS_Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ParserInterface.hpp"

#include <memory>
#include <string>

namespace NCBI
{
Expand Down
1 change: 1 addition & 0 deletions parser/gcp/GCP_Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ParserInterface.hpp"

#include <memory>
#include <string>

namespace NCBI
{
Expand Down
1 change: 1 addition & 0 deletions parser/op/OP_Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ParserInterface.hpp"

#include <memory>
#include <string>

namespace NCBI
{
Expand Down
30 changes: 28 additions & 2 deletions parser/op/op_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,41 @@ log_onprem
referer SPACE
{ op_start_UserAgent( scanner ); } agent { op_pop_state( scanner ); } SPACE
forwarded SPACE
port SPACE
req_len
tail
{
// in case the productions did not find vers/path, set them here to make them at least empty in the ouput
SET_VALUE( OPReceiver::vers, EmptyTSTR );
SET_VALUE( OPReceiver::path, EmptyTSTR );
}
;

tail
: tail_elem
| tail SPACE tail_elem
;

tail_elem
: port
| req_len
| STR
| I64
| quoted_freeform
;

quoted_freeform
: QUOTE freeform QUOTE;

freeform
: freeform_elem
| freeform freeform_elem
;

freeform_elem
: QSTR
| I64
| SPACE
;

log_onprem_err
: ip error
;
Expand Down
6 changes: 6 additions & 0 deletions parser/op/op_test_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ TEST_F( OPTestFixture, parse_path_with_url_encoded_slash_in_extension )
ASSERT_EQ( "", extract_value( res, "extension" ) );
}

TEST_F( OPTestFixture, parse_error )
{
std::string res = try_to_parse_good( "34.140.130.14 - - [07/May/2025:23:48:24 -0400] \"ftp.ncbi.nih.gov\" \"GET /1000genomes/ftp/phase3/data/HG02025/sequence_read/SRR821984_2.filt.fastq.gz HTTP/1.1\" 200 111014168 0 \"-\" \"Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0\" \"-\" -pct 134311 X \"NCBI-SID: -\" port=443 885 80688 application/x-gzip" );
ASSERT_EQ( "443", extract_value( res, "port" ) );
}

extern "C"
{
int main ( int argc, const char * argv [], const char * envp [] )
Expand Down