]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
email-json: body md5 logging is optional
authorEric Leblond <eric@regit.org>
Tue, 5 May 2015 13:16:35 +0000 (15:16 +0200)
committerEric Leblond <eric@regit.org>
Tue, 6 Oct 2015 21:30:45 +0000 (23:30 +0200)
src/output-json-email-common.c

index fae43a2e9aa501692474ea274e31fb49fa943d09..080151589c14734e1c98c7ca354c83e373666607 100644 (file)
@@ -145,6 +145,21 @@ static void JsonEmailLogJSONMd5(OutputJsonEmailCtx *email_ctx, json_t *js, SMTPT
             }
         }
     }
+
+    if (email_ctx->flags & LOG_EMAIL_BODY_MD5) {
+        MimeDecParseState *mime_state = tx->mime_state;
+        if (mime_state && mime_state->md5_ctx && (mime_state->state_flag == PARSE_DONE)) {
+            size_t x;
+            int i;
+            char s[256];
+            if (likely(s != NULL)) {
+                for (i = 0, x = 0; x < sizeof(mime_state->md5); x++) {
+                    i += snprintf(s + i, 255-i, "%02x", mime_state->md5[x]);
+                }
+                json_object_set_new(js, "body_md5", json_string(s));
+            }
+        }
+    }
 }
 #endif
 
@@ -244,20 +259,6 @@ json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_
             SCReturnPtr(NULL, "json_t");
         }
 
-#ifdef HAVE_NSS
-        if (mime_state->md5_ctx && (mime_state->state_flag == PARSE_DONE)) {
-            size_t x;
-            int i;
-            char s[256];
-            if (likely(s != NULL)) {
-                for (i = 0, x = 0; x < sizeof(mime_state->md5); x++) {
-                    i += snprintf(s + i, 255-i, "%02x", mime_state->md5[x]);
-                }
-                json_object_set_new(sjs, "body_md5", json_string(s));
-            }
-        }
-#endif
-
         json_object_set_new(sjs, "status",
                             json_string(MimeDecParseStateGetStatus(mime_state)));