]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/entropy: Use entropy matching when needed
authorJeff Lucovsky <jlucovsky@oisf.net>
Wed, 5 Feb 2025 21:38:03 +0000 (16:38 -0500)
committerVictor Julien <victor@inliniac.net>
Tue, 1 Apr 2025 19:11:11 +0000 (21:11 +0200)
This commit causes the content inspection engine to recognize and
invoke the entropy "match" function when the entropy keyword is used.

Issue: 4162

src/detect-engine-content-inspection.c

index 6ccc5e533efbd9b4969eb3550e1215c8e827072d..7ee7c19d4873ab85d4366799baab7eff324a0896 100644 (file)
@@ -41,6 +41,7 @@
 #include "detect-bytemath.h"
 #include "detect-bytejump.h"
 #include "detect-byte-extract.h"
+#include "detect-entropy.h"
 #include "detect-replace.h"
 #include "detect-engine-content-inspection.h"
 #include "detect-uricontent.h"
@@ -486,6 +487,11 @@ static int DetectEngineContentInspectionInternal(DetectEngineThreadCtx *det_ctx,
             det_ctx->pcre_match_start_offset = prev_offset;
         } while (1);
 
+    } else if (smd->type == DETECT_ENTROPY) {
+        if (!DetectEntropyDoMatch(det_ctx, s, smd->ctx, buffer, buffer_len)) {
+            goto no_match;
+        }
+        goto match;
     } else if (smd->type == DETECT_BYTETEST) {
         const DetectBytetestData *btd = (const DetectBytetestData *)smd->ctx;
         uint16_t btflags = btd->flags;