From: Juliana Fajardini Date: Mon, 24 Oct 2022 00:58:42 +0000 (-0300) Subject: pgsql: add test for parameter status parser X-Git-Tag: suricata-7.0.0-rc1~416 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a654ef50de255628c7a6b5f08521908ecedc24e2;p=thirdparty%2Fsuricata.git pgsql: add test for parameter status parser Since we've done some changes to how the parameters are parsed, add one more test case to check that. Bug #5579 --- diff --git a/rust/src/pgsql/parser.rs b/rust/src/pgsql/parser.rs index c7022795ed..14be325c71 100644 --- a/rust/src/pgsql/parser.rs +++ b/rust/src/pgsql/parser.rs @@ -2073,7 +2073,69 @@ mod tests { } } - // TODO keep adding more messages + //A series of response messages from the backend: + // R · S ·application_name + // S ·client_encoding UTF8 S ·DateStyle ISO, MDY + // S &default_transaction_read_only off S ·in_hot_standby off + // S ·integer_datetimes on S ·IntervalStyle postgres + // S ·is_superuser off S ·server_encoding UTF8 + // S ·server_version 14.5 S "session_authorization ctfpost + // S #standard_conforming_strings on S ·TimeZone Europe/Paris + // K ···O··Z ·I + let buf = &[ + 0x52, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x53, 0x00, 0x00, 0x00, 0x16, 0x61, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x19, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x6e, 0x63, 0x6f, + 0x64, 0x69, 0x6e, 0x67, 0x00, 0x55, 0x54, 0x46, + 0x38, 0x00, 0x53, 0x00, 0x00, 0x00, 0x17, 0x44, + 0x61, 0x74, 0x65, 0x53, 0x74, 0x79, 0x6c, 0x65, + 0x00, 0x49, 0x53, 0x4f, 0x2c, 0x20, 0x4d, 0x44, + 0x59, 0x00, 0x53, 0x00, 0x00, 0x00, 0x26, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x5f, + 0x6f, 0x6e, 0x6c, 0x79, 0x00, 0x6f, 0x66, 0x66, + 0x00, 0x53, 0x00, 0x00, 0x00, 0x17, 0x69, 0x6e, + 0x5f, 0x68, 0x6f, 0x74, 0x5f, 0x73, 0x74, 0x61, + 0x6e, 0x64, 0x62, 0x79, 0x00, 0x6f, 0x66, 0x66, + 0x00, 0x53, 0x00, 0x00, 0x00, 0x19, 0x69, 0x6e, + 0x74, 0x65, 0x67, 0x65, 0x72, 0x5f, 0x64, 0x61, + 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x00, + 0x6f, 0x6e, 0x00, 0x53, 0x00, 0x00, 0x00, 0x1b, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x53, 0x74, 0x79, 0x6c, 0x65, 0x00, 0x70, 0x6f, + 0x73, 0x74, 0x67, 0x72, 0x65, 0x73, 0x00, 0x53, + 0x00, 0x00, 0x00, 0x15, 0x69, 0x73, 0x5f, 0x73, + 0x75, 0x70, 0x65, 0x72, 0x75, 0x73, 0x65, 0x72, + 0x00, 0x6f, 0x66, 0x66, 0x00, 0x53, 0x00, 0x00, + 0x00, 0x19, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, + 0x67, 0x00, 0x55, 0x54, 0x46, 0x38, 0x00, 0x53, + 0x00, 0x00, 0x00, 0x18, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x00, 0x31, 0x34, 0x2e, 0x35, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x22, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x00, 0x63, 0x74, 0x66, 0x70, 0x6f, + 0x73, 0x74, 0x00, 0x53, 0x00, 0x00, 0x00, 0x23, + 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x73, 0x00, 0x6f, 0x6e, 0x00, 0x53, + 0x00, 0x00, 0x00, 0x1a, 0x54, 0x69, 0x6d, 0x65, + 0x5a, 0x6f, 0x6e, 0x65, 0x00, 0x45, 0x75, 0x72, + 0x6f, 0x70, 0x65, 0x2f, 0x50, 0x61, 0x72, 0x69, + 0x73, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0c, 0x00, + 0x00, 0x0b, 0x8d, 0xcf, 0x4f, 0xb6, 0xcf, 0x5a, + 0x00, 0x00, 0x00, 0x05, 0x49 + ]; + + let result = pgsql_parse_response(buf); + assert!(result.is_ok()); } #[test]