]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/tx: add AppLayerTxData to PrefilterTx
authorVictor Julien <vjulien@oisf.net>
Thu, 15 Sep 2022 08:45:46 +0000 (10:45 +0200)
committerVictor Julien <vjulien@oisf.net>
Sat, 1 Oct 2022 18:12:13 +0000 (20:12 +0200)
In preparation of some file inspection optimizations, for which we need the
tx data.

Update all users.

19 files changed:
src/detect-dns-query.c
src/detect-engine-prefilter.c
src/detect-engine-prefilter.h
src/detect-file-data.c
src/detect-filemagic.c
src/detect-filename.c
src/detect-http-client-body.c
src/detect-http-header.c
src/detect-http-raw-header.c
src/detect-http2.c
src/detect-ike-vendor.c
src/detect-krb5-cname.c
src/detect-krb5-sname.c
src/detect-mqtt-subscribe-topic.c
src/detect-mqtt-unsubscribe-topic.c
src/detect-quic-cyu-hash.c
src/detect-quic-cyu-string.c
src/detect-tls-certs.c
src/detect.h

index 97b8ddc6685250a2f33a00ae3b72bc8ebbd32455..77f1c00f95888d865c0f7c0840fab1740014bdbb 100644 (file)
@@ -145,10 +145,8 @@ typedef struct PrefilterMpmDnsQuery {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxDnsQuery(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxDnsQuery(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 034c16e1b7fcc6f776aa518926b7310bad39a737..066098601a9aa2e548cb7cdfbb2bc003e8de52ba 100644 (file)
@@ -118,8 +118,8 @@ void DetectRunPrefilterTx(DetectEngineThreadCtx *det_ctx,
         }
 
         PREFILTER_PROFILING_START(det_ctx);
-        engine->cb.PrefilterTx(det_ctx, engine->pectx,
-                p, p->flow, tx->tx_ptr, tx->tx_id, flow_flags);
+        engine->cb.PrefilterTx(det_ctx, engine->pectx, p, p->flow, tx->tx_ptr, tx->tx_id,
+                tx->tx_data_ptr, flow_flags);
         PREFILTER_PROFILING_END(det_ctx, engine->gid);
 
         if (tx->tx_progress > engine->ctx.tx_min_progress && engine->is_last_for_progress) {
@@ -268,12 +268,8 @@ int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
 }
 
 int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
-        void (*PrefilterTxFunc)(DetectEngineThreadCtx *det_ctx, const void *pectx,
-            Packet *p, Flow *f, void *tx,
-            const uint64_t idx, const uint8_t flags),
-        AppProto alproto, int tx_min_progress,
-        void *pectx, void (*FreeFunc)(void *pectx),
-        const char *name)
+        PrefilterTxFn PrefilterTxFunc, AppProto alproto, int tx_min_progress, void *pectx,
+        void (*FreeFunc)(void *pectx), const char *name)
 {
     if (sgh == NULL || PrefilterTxFunc == NULL || pectx == NULL)
         return -1;
@@ -718,10 +714,8 @@ typedef struct PrefilterMpmCtx {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterMpm(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterMpm(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f,
+        void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 5ad6d1b62386caf91378b3d61bdcc6c020427f15..39ac66fb833bb2dc67eb7cfd19e94b8da4ee0a51 100644 (file)
@@ -44,10 +44,8 @@ int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
         void *pectx, void (*FreeFunc)(void *pectx),
         const char *name);
 int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
-        void (*PrefilterTx)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f,
-                void *tx, const uint64_t idx, const uint8_t flags),
-        const AppProto alproto, const int tx_min_progress, void *pectx,
-        void (*FreeFunc)(void *pectx), const char *name);
+        PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int tx_min_progress,
+        void *pectx, void (*FreeFunc)(void *pectx), const char *name);
 int PrefilterAppendFrameEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
         PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx,
         void (*FreeFunc)(void *pectx), const char *name);
index 08c58f751a2c96c51ffce9793803e7264f80d54f..891bc4111e15c9a0b307891ef065c6d04d073c3a 100644 (file)
@@ -450,7 +450,7 @@ static uint8_t DetectEngineInspectBufferHttpBody(DetectEngineCtx *de_ctx,
  *  \param flags STREAM_* flags including direction
  */
 static void PrefilterTxHTTPFiledata(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
-        Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -653,10 +653,8 @@ static uint8_t DetectEngineInspectFiledata(DetectEngineCtx *de_ctx, DetectEngine
  *  \param idx transaction id
  *  \param flags STREAM_* flags including direction
  */
-static void PrefilterTxFiledata(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxFiledata(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 8bc9c8ecc42a986728faea1856d1016c9e90dbe5..82d5784a357bbced8c6d0bc575b6b5db25b4d855 100644 (file)
@@ -530,10 +530,8 @@ typedef struct PrefilterMpmFilemagic {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxFilemagic(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxFilemagic(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 8159d8e51d67073de1aea5da2d54a87bec3eb39b..35b568234a04b5b4998c81717cc69a5a7ee1ef52 100644 (file)
@@ -426,10 +426,8 @@ typedef struct PrefilterMpmFilename {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxFilename(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxFilename(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index bfaa6e9255b9bd9ff81c692add47341c93ec27e8..ec4caacfd5d8821b8a9a7178d14e58c01d4df9e5 100644 (file)
@@ -351,7 +351,7 @@ static uint8_t DetectEngineInspectBufferHttpBody(DetectEngineCtx *de_ctx,
  *  \param flags STREAM_* flags including direction
  */
 static void PrefilterTxHttpRequestBody(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
-        Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 2e55b4248272f24c77b54f991586d46ec1cf6afc..f9a24d63d31db0023e682cfb25f60c2fb57a4dfb 100644 (file)
@@ -239,10 +239,8 @@ typedef struct PrefilterMpmHttpHeaderCtx {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterMpmHttpHeader(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterMpmHttpHeader(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -276,10 +274,8 @@ static void PrefilterMpmHttpHeader(DetectEngineThreadCtx *det_ctx,
     }
 }
 
-static void PrefilterMpmHttpTrailer(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterMpmHttpTrailer(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -291,7 +287,7 @@ static void PrefilterMpmHttpTrailer(DetectEngineThreadCtx *det_ctx,
             ((flags & STREAM_TOCLIENT) && !htud->response_has_trailers))) {
         SCReturn;
     }
-    PrefilterMpmHttpHeader(det_ctx, pectx, p, f, txv, idx, flags);
+    PrefilterMpmHttpHeader(det_ctx, pectx, p, f, txv, idx, _txd, flags);
     SCReturn;
 }
 
index 36555b4c89eef06ecb6d71d819eeb8d4c36fc1f9..df1e87304fe843bd466d04bc89642421846ad70a 100644 (file)
@@ -241,10 +241,8 @@ typedef struct PrefilterMpmHttpHeaderRawCtx {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterMpmHttpHeaderRaw(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterMpmHttpHeaderRaw(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -272,10 +270,8 @@ static void PrefilterMpmHttpHeaderRaw(DetectEngineThreadCtx *det_ctx,
     }
 }
 
-static void PrefilterMpmHttpTrailerRaw(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterMpmHttpTrailerRaw(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -287,7 +283,7 @@ static void PrefilterMpmHttpTrailerRaw(DetectEngineThreadCtx *det_ctx,
             ((flags & STREAM_TOCLIENT) && !htud->response_has_trailers))) {
         SCReturn;
     }
-    PrefilterMpmHttpHeaderRaw(det_ctx, pectx, p, f, txv, idx, flags);
+    PrefilterMpmHttpHeaderRaw(det_ctx, pectx, p, f, txv, idx, _txd, flags);
     SCReturn;
 }
 
index e21cc7b14bfc93aa7c5981f1d8ef1b4ef77b8df9..3d4fd52f7e618ace7401f7d8e02dc91db11232f0 100644 (file)
@@ -702,10 +702,8 @@ static InspectionBuffer *GetHttp2HNameData(DetectEngineThreadCtx *det_ctx,
     SCReturnPtr(buffer, "InspectionBuffer");
 }
 
-static void PrefilterTxHttp2HName(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxHttp2HName(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
@@ -834,10 +832,8 @@ static InspectionBuffer *GetHttp2HeaderData(DetectEngineThreadCtx *det_ctx,
     SCReturnPtr(buffer, "InspectionBuffer");
 }
 
-static void PrefilterTxHttp2Header(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxHttp2Header(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 5a5c8a66fe48cd9d36957585dd0a3e88fd89633c..4c4be8f1a98ed87f6b8e453b6c28b6a317f5b70e 100644 (file)
@@ -87,7 +87,7 @@ static InspectionBuffer *IkeVendorGetData(DetectEngineThreadCtx *det_ctx,
  *  \param pectx inspection context
  */
 static void PrefilterTxIkeVendor(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
-        Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index bb43056e9d430063180e3d3da279bec0176eb55f..eef48d0c6ca50b3e9e51dca544ee3939b6d7b030 100644 (file)
@@ -134,10 +134,8 @@ typedef struct PrefilterMpmKrb5Name {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxKrb5CName(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxKrb5CName(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 100c635e52ead4439b19fbc08071f7c724f9efef..544dd9e711b9ea66b1fa7ee1096062575a89436f 100644 (file)
@@ -134,10 +134,8 @@ typedef struct PrefilterMpmKrb5Name {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxKrb5SName(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxKrb5SName(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index c63c01919b0e0d63a10902c99beccb157623d761..e0793b0144c8785de777e32c9203996df373c1fa 100644 (file)
@@ -139,10 +139,9 @@ typedef struct PrefilterMpmMQTTSubscribeTopic {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxMQTTSubscribeTopic(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxMQTTSubscribeTopic(DetectEngineThreadCtx *det_ctx, const void *pectx,
+        Packet *p, Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd,
+        const uint8_t flags)
 {
     SCEnter();
 
index 4249153a02dde442f142f064aee90f0a9c0e545f..433e18f0e59a901a49be6ceda18aefeb5971cd10 100644 (file)
@@ -139,10 +139,9 @@ typedef struct PrefilterMpmMQTTUnsubscribeTopic {
  *  \param txv tx to inspect
  *  \param pectx inspection context
  */
-static void PrefilterTxMQTTUnsubscribeTopic(DetectEngineThreadCtx *det_ctx,
-        const void *pectx,
-        Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxMQTTUnsubscribeTopic(DetectEngineThreadCtx *det_ctx, const void *pectx,
+        Packet *p, Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd,
+        const uint8_t flags)
 {
     SCEnter();
 
index e76265de5bff97e50a05b949380d4f0bddb5b586..40cff70ecd2512376ed2c5fb901b0c81829300e7 100644 (file)
@@ -135,7 +135,7 @@ typedef struct PrefilterMpmQuicHash {
  *  \param pectx inspection context
  */
 static void PrefilterTxQuicHash(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
-        Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 6ef0796874f50df17e7a436ce61874b778aa18d2..914a6432a52bf3993f876989a6d60b27e9264817 100644 (file)
@@ -127,7 +127,7 @@ static uint8_t DetectEngineInspectQuicString(DetectEngineCtx *de_ctx,
  *  \param pectx inspection context
  */
 static void PrefilterTxQuicString(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
-        Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index 79fae74d4b796da5ab0650fe4ec9a707f7b28551..be2dd7aed0db435604e8facaf1348654fa13e6a4 100644 (file)
@@ -198,9 +198,8 @@ static uint8_t DetectEngineInspectTlsCerts(DetectEngineCtx *de_ctx, DetectEngine
     return DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
 }
 
-static void PrefilterTxTlsCerts(DetectEngineThreadCtx *det_ctx,
-        const void *pectx, Packet *p, Flow *f, void *txv,
-        const uint64_t idx, const uint8_t flags)
+static void PrefilterTxTlsCerts(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
+        Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *_txd, const uint8_t flags)
 {
     SCEnter();
 
index f5db9f33c88dbcdbb03e0d89b9cf2771b22690db..ce249e1ca9dedc22965bef3dfe46e6b5b99d19a0 100644 (file)
@@ -1306,6 +1306,10 @@ typedef struct MpmStore_ {
 typedef void (*PrefilterFrameFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
         const struct Frames *frames, const struct Frame *frame, const uint32_t idx);
 
+typedef struct AppLayerTxData AppLayerTxData;
+typedef void (*PrefilterTxFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f,
+        void *tx, const uint64_t tx_id, const AppLayerTxData *tx_data, const uint8_t flags);
+
 typedef struct PrefilterEngineList_ {
     uint16_t id;
 
@@ -1322,9 +1326,7 @@ typedef struct PrefilterEngineList_ {
     void *pectx;
 
     void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx);
-    void (*PrefilterTx)(DetectEngineThreadCtx *det_ctx, const void *pectx,
-            Packet *p, Flow *f, void *tx,
-            const uint64_t idx, const uint8_t flags);
+    PrefilterTxFn PrefilterTx;
     PrefilterFrameFn PrefilterFrame;
 
     struct PrefilterEngineList_ *next;
@@ -1356,9 +1358,7 @@ typedef struct PrefilterEngine_ {
 
     union {
         void (*Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx);
-        void (*PrefilterTx)(DetectEngineThreadCtx *det_ctx, const void *pectx,
-                Packet *p, Flow *f, void *tx,
-                const uint64_t idx, const uint8_t flags);
+        PrefilterTxFn PrefilterTx;
         PrefilterFrameFn PrefilterFrame;
     } cb;