]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/tls: log ALPN for client and server
authorVictor Julien <vjulien@oisf.net>
Fri, 31 May 2024 12:33:31 +0000 (14:33 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 20 Jun 2024 04:57:21 +0000 (06:57 +0200)
Part of the extended logging.

Logs `client_alpns` and `server_alpns` arrays in the tls object.

Ticket: #7055.

doc/userguide/output/eve/eve-json-format.rst
src/output-json-tls.c

index 9da9e82d3e2c517cc2f8d8485d40c9bc834fe3c3..2ea003fb96146ba5194a76613431ac11d167dd21 100644 (file)
@@ -1046,6 +1046,8 @@ If extended logging is enabled the following fields are also included:
 * "ja3": The JA3 fingerprint consisting of both a JA3 hash and a JA3 string
 * "ja3s": The JA3S fingerprint consisting of both a JA3 hash and a JA3 string
 * "ja4": The JA4 client fingerprint for TLS
+* "client_alpns": array of strings with ALPN values
+* "server_alpns": array of strings with ALPN values
 
 JA3 and JA4 must be enabled in the Suricata config file (set 'app-layer.protocols.tls.ja3-fingerprints'/'app-layer.protocols.tls.ja4-fingerprints' to 'yes').
 
index 821e76553936c2abb49a264a256ce1ee6206f36e..406f6aca01c8b1bdc4c23432316466450869b11f 100644 (file)
@@ -263,6 +263,24 @@ static void JsonTlsLogJa3S(JsonBuilder *js, SSLState *ssl_state)
     }
 }
 
+static void JsonTlsLogAlpns(JsonBuilder *js, SSLStateConnp *connp, const char *object)
+{
+    if (TAILQ_EMPTY(&connp->alpns)) {
+        return;
+    }
+
+    SSLAlpns *a = TAILQ_FIRST(&connp->alpns);
+    if (a == NULL) {
+        return;
+    }
+
+    jb_open_array(js, object);
+    TAILQ_FOREACH (a, &connp->alpns, next) {
+        jb_append_string_from_bytes(js, a->alpn, a->size);
+    }
+    jb_close(js);
+}
+
 static void JsonTlsLogCertificate(JsonBuilder *js, SSLStateConnp *connp)
 {
     if (TAILQ_EMPTY(&connp->certs)) {
@@ -457,6 +475,9 @@ static bool JsonTlsLogJSONExtendedAux(void *vtx, JsonBuilder *tjs)
     /* tls ja4 */
     JsonTlsLogSCJA4(tjs, state);
 
+    JsonTlsLogAlpns(tjs, &state->client_connp, "client_alpns");
+    JsonTlsLogAlpns(tjs, &state->server_connp, "server_alpns");
+
     if (HasClientCert(&state->client_connp)) {
         jb_open_object(tjs, "client");
         JsonTlsLogClientCert(tjs, &state->client_connp, false, false);