]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: do not log empty objects for request or response
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 15 Jul 2025 12:58:49 +0000 (14:58 +0200)
committerJason Ish <jason.ish@oisf.net>
Fri, 1 Aug 2025 16:54:15 +0000 (10:54 -0600)
Ticket: 7741

etc/schema.json
rust/src/http2/logger.rs

index 2ba472f5aa4bed9d3a8b9de12de8343203c0a693..97d56571950d9d433eefc11f909651fee4e3cc15 100644 (file)
                         "request": {
                             "type": "object",
                             "additionalProperties": false,
+                            "minProperties": 1,
                             "properties": {
                                 "error_code": {
                                     "type": "string"
                         "response": {
                             "type": "object",
                             "additionalProperties": false,
+                            "minProperties": 1,
                             "properties": {
                                 "error_code": {
                                     "type": "string"
index c231f599e40967231fc2d5d2cb7a2ab08c7fb86c..2197d7a83e1e04c1b6cded37129f3461a35ecaff 100644 (file)
@@ -270,13 +270,23 @@ fn log_http2(tx: &HTTP2Transaction, js: &mut JsonBuilder) -> Result<bool, JsonEr
     js.open_object("http2")?;
 
     js.set_uint("stream_id", tx.stream_id as u64)?;
+    let mark = js.get_mark();
     js.open_object("request")?;
     let has_request = log_http2_frames(&tx.frames_ts, js)?;
-    js.close()?;
+    if has_request {
+        js.close()?;
+    } else {
+        js.restore_mark(&mark)?;
+    }
 
+    let mark = js.get_mark();
     js.open_object("response")?;
     let has_response = log_http2_frames(&tx.frames_tc, js)?;
-    js.close()?;
+    if has_response {
+        js.close()?;
+    } else {
+        js.restore_mark(&mark)?;
+    }
 
     js.close()?; // http2
     js.close()?; // http