suricata
detect-http-client-body.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \ingroup httplayer
20  *
21  * @{
22  */
23 
24 
25 /**
26  * \file
27  *
28  * \author Anoop Saldanha <anoopsaldanha@gmail.com>
29  *
30  * Implements support for the http_client_body keyword
31  */
32 
33 #include "suricata-common.h"
34 #include "threads.h"
35 #include "decode.h"
36 
37 #include "detect.h"
38 #include "detect-parse.h"
39 #include "detect-engine.h"
40 #include "detect-engine-mpm.h"
41 #include "detect-engine-state.h"
44 #include "detect-content.h"
45 #include "detect-pcre.h"
46 
47 #include "flow.h"
48 #include "flow-var.h"
49 #include "flow-util.h"
50 
51 #include "util-debug.h"
52 #include "util-unittest.h"
53 #include "util-unittest-helper.h"
54 #include "util-spm.h"
55 
56 #include "app-layer.h"
57 #include "app-layer-parser.h"
58 #include "app-layer-htp.h"
60 #include "stream-tcp.h"
61 #include "util-profiling.h"
62 
63 static int DetectHttpClientBodySetup(DetectEngineCtx *, Signature *, const char *);
64 static int DetectHttpClientBodySetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str);
65 #ifdef UNITTESTS
66 static void DetectHttpClientBodyRegisterTests(void);
67 #endif
68 static void DetectHttpClientBodySetupCallback(const DetectEngineCtx *de_ctx,
69  Signature *s);
70 static int g_http_client_body_buffer_id = 0;
71 
72 static uint8_t DetectEngineInspectBufferHttpBody(DetectEngineCtx *de_ctx,
74  const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
75 
76 static int PrefilterMpmHttpRequestBodyRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
77  MpmCtx *mpm_ctx, const DetectBufferMpmRegistery *mpm_reg, int list_id);
78 
79 /**
80  * \brief Registers the keyword handlers for the "http_client_body" keyword.
81  */
83 {
84  /* http_client_body content modifier */
85  sigmatch_table[DETECT_AL_HTTP_CLIENT_BODY].name = "http_client_body";
86  sigmatch_table[DETECT_AL_HTTP_CLIENT_BODY].desc = "content modifier to match only on HTTP request-body";
87  sigmatch_table[DETECT_AL_HTTP_CLIENT_BODY].url = "/rules/http-keywords.html#http-client-body";
88  sigmatch_table[DETECT_AL_HTTP_CLIENT_BODY].Setup = DetectHttpClientBodySetup;
89 #ifdef UNITTESTS
91 #endif
95 
96  /* http.request_body sticky buffer */
97  sigmatch_table[DETECT_HTTP_REQUEST_BODY].name = "http.request_body";
98  sigmatch_table[DETECT_HTTP_REQUEST_BODY].desc = "sticky buffer to match the HTTP request body buffer";
99  sigmatch_table[DETECT_HTTP_REQUEST_BODY].url = "/rules/http-keywords.html#http-client-body";
100  sigmatch_table[DETECT_HTTP_REQUEST_BODY].Setup = DetectHttpClientBodySetupSticky;
103 
105  HTP_REQUEST_BODY, DetectEngineInspectBufferHttpBody, NULL);
106 
107  DetectAppLayerMpmRegister2("http_client_body", SIG_FLAG_TOSERVER, 2,
108  PrefilterMpmHttpRequestBodyRegister, NULL, ALPROTO_HTTP1, HTP_REQUEST_BODY);
109 
110  DetectBufferTypeSetDescriptionByName("http_client_body",
111  "http request body");
112 
113  DetectBufferTypeRegisterSetupCallback("http_client_body",
114  DetectHttpClientBodySetupCallback);
115 
116  g_http_client_body_buffer_id = DetectBufferTypeGetByName("http_client_body");
117 }
118 
119 static void DetectHttpClientBodySetupCallback(const DetectEngineCtx *de_ctx,
120  Signature *s)
121 {
122  SCLogDebug("callback invoked by %u", s->id);
124 
125  /* client body needs to be inspected in sync with stream if possible */
127 }
128 
129 /**
130  * \brief The setup function for the http_client_body keyword for a signature.
131  *
132  * \param de_ctx Pointer to the detection engine context.
133  * \param s Pointer to signature for the current Signature being parsed
134  * from the rules.
135  * \param m Pointer to the head of the SigMatchs for the current rule
136  * being parsed.
137  * \param arg Pointer to the string holding the keyword value.
138  *
139  * \retval 0 On success
140  * \retval -1 On failure
141  */
142 int DetectHttpClientBodySetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
143 {
145  g_http_client_body_buffer_id, ALPROTO_HTTP1);
146 }
147 
148 /**
149  * \brief this function setup the http.request_body keyword used in the rule
150  *
151  * \param de_ctx Pointer to the Detection Engine Context
152  * \param s Pointer to the Signature to which the current keyword belongs
153  * \param str Should hold an empty string always
154  *
155  * \retval 0 On success
156  */
157 static int DetectHttpClientBodySetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str)
158 {
159  if (DetectBufferSetActiveList(s, g_http_client_body_buffer_id) < 0)
160  return -1;
162  return -1;
163  return 0;
164 }
165 
166 static inline HtpBody *GetRequestBody(htp_tx_t *tx)
167 {
168  HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx);
169  if (htud == NULL) {
170  SCLogDebug("no htud");
171  return NULL;
172  }
173 
174  return &htud->request_body;
175 }
176 
178  int list_id;
180  const MpmCtx *mpm_ctx;
183 
184 static void PrefilterMpmHttpRequestBodyFree(void *ptr)
185 {
186  SCFree(ptr);
187 }
188 
189 static inline InspectionBuffer *HttpRequestBodyXformsGetDataCallback(DetectEngineThreadCtx *det_ctx,
190  const DetectEngineTransforms *transforms, const int list_id, InspectionBuffer *base_buffer)
191 {
192  InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
193  if (buffer->inspect != NULL)
194  return buffer;
195 
196  InspectionBufferSetup(det_ctx, list_id, buffer, base_buffer->inspect, base_buffer->inspect_len);
197  buffer->inspect_offset = base_buffer->inspect_offset;
198  InspectionBufferApplyTransforms(buffer, transforms);
199  SCLogDebug("xformed buffer %p size %u", buffer, buffer->inspect_len);
200  SCReturnPtr(buffer, "InspectionBuffer");
201 }
202 
203 static InspectionBuffer *HttpRequestBodyGetDataCallback(DetectEngineThreadCtx *det_ctx,
204  const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv,
205  const int list_id, const int base_id)
206 {
207  SCEnter();
208 
209  InspectionBuffer *buffer = InspectionBufferGet(det_ctx, base_id);
210  if (base_id != list_id && buffer->inspect != NULL)
211  return HttpRequestBodyXformsGetDataCallback(det_ctx, transforms, list_id, buffer);
212  else if (buffer->inspect != NULL)
213  return buffer;
214 
215  htp_tx_t *tx = txv;
216  HtpState *htp_state = f->alstate;
217  const uint8_t flags = flow_flags;
218 
219  HtpBody *body = GetRequestBody(tx);
220  if (body == NULL) {
221  return NULL;
222  }
223 
224  /* no new data */
225  if (body->body_inspected == body->content_len_so_far) {
226  SCLogDebug("no new data");
227  return NULL;
228  }
229 
230  HtpBodyChunk *cur = body->first;
231  if (cur == NULL) {
232  SCLogDebug("No http chunks to inspect for this transaction");
233  return NULL;
234  }
235 
236  SCLogDebug("request.body_limit %u request_body.content_len_so_far %" PRIu64
237  ", request.inspect_min_size %" PRIu32 ", EOF %s, progress > body? %s",
238  htp_state->cfg->request.body_limit, body->content_len_so_far,
239  htp_state->cfg->request.inspect_min_size, flags & STREAM_EOF ? "true" : "false",
241  HTP_REQUEST_BODY)
242  ? "true"
243  : "false");
244 
245  if (!htp_state->cfg->http_body_inline) {
246  /* inspect the body if the transfer is complete or we have hit
247  * our body size limit */
248  if ((htp_state->cfg->request.body_limit == 0 ||
249  body->content_len_so_far < htp_state->cfg->request.body_limit) &&
250  body->content_len_so_far < htp_state->cfg->request.inspect_min_size &&
251  !(AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, tx, flags) >
252  HTP_REQUEST_BODY) &&
253  !(flags & STREAM_EOF)) {
254  SCLogDebug("we still haven't seen the entire request body. "
255  "Let's defer body inspection till we see the "
256  "entire body.");
257  return NULL;
258  }
259  }
260 
261  /* get the inspect buffer
262  *
263  * make sure that we have at least the configured inspect_win size.
264  * If we have more, take at least 1/4 of the inspect win size before
265  * the new data.
266  */
267  uint64_t offset = 0;
268  if (body->body_inspected > htp_state->cfg->request.inspect_min_size) {
270  uint64_t inspect_win = body->content_len_so_far - body->body_inspected;
271  SCLogDebug("inspect_win %"PRIu64, inspect_win);
272  if (inspect_win < htp_state->cfg->request.inspect_window) {
273  uint64_t inspect_short = htp_state->cfg->request.inspect_window - inspect_win;
274  if (body->body_inspected < inspect_short)
275  offset = 0;
276  else
277  offset = body->body_inspected - inspect_short;
278  } else {
279  offset = body->body_inspected - (htp_state->cfg->request.inspect_window / 4);
280  }
281  }
282 
283  const uint8_t *data;
284  uint32_t data_len;
285 
287  &data, &data_len, offset);
288  InspectionBufferSetup(det_ctx, base_id, buffer, data, data_len);
289  buffer->inspect_offset = offset;
290  body->body_inspected = body->content_len_so_far;
291  SCLogDebug("body->body_inspected now: %" PRIu64, body->body_inspected);
292 
293  if (base_id != list_id) {
294  buffer = HttpRequestBodyXformsGetDataCallback(det_ctx, transforms, list_id, buffer);
295  }
296  SCReturnPtr(buffer, "InspectionBuffer");
297 }
298 
299 static uint8_t DetectEngineInspectBufferHttpBody(DetectEngineCtx *de_ctx,
301  const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
302 {
303  bool eof =
304  (AppLayerParserGetStateProgress(f->proto, f->alproto, txv, flags) > engine->progress);
305  const InspectionBuffer *buffer = HttpRequestBodyGetDataCallback(
306  det_ctx, engine->v2.transforms, f, flags, txv, engine->sm_list, engine->sm_list_base);
307  if (buffer == NULL || buffer->inspect == NULL) {
309  }
310 
311  const uint32_t data_len = buffer->inspect_len;
312  const uint8_t *data = buffer->inspect;
313  const uint64_t offset = buffer->inspect_offset;
314 
315  uint8_t ci_flags = eof ? DETECT_CI_FLAGS_END : 0;
316  ci_flags |= (offset == 0 ? DETECT_CI_FLAGS_START : 0);
317  ci_flags |= buffer->flags;
318 
319  det_ctx->discontinue_matching = 0;
320  det_ctx->buffer_offset = 0;
321  det_ctx->inspection_recursion_counter = 0;
322 
323  /* Inspect all the uricontents fetched on each
324  * transaction at the app layer */
325  int r = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, (uint8_t *)data,
327  if (r == 1) {
329  }
330 
331  if (flags & STREAM_TOSERVER) {
332  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
333  HTP_REQUEST_BODY)
335  } else {
336  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
337  HTP_RESPONSE_BODY)
339  }
341 }
342 
343 /** \brief HTTP Request body callback
344  *
345  * \param det_ctx detection engine thread ctx
346  * \param pectx inspection context
347  * \param p packet to inspect
348  * \param f flow to inspect
349  * \param txv tx to inspect
350  * \param idx transaction id
351  * \param flags STREAM_* flags including direction
352  */
353 static void PrefilterTxHttpRequestBody(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
354  Flow *f, void *txv, const uint64_t idx, const uint8_t flags)
355 {
356  SCEnter();
357 
358  const PrefilterMpmHttpRequestBody *ctx = (const PrefilterMpmHttpRequestBody *)pectx;
359  const MpmCtx *mpm_ctx = ctx->mpm_ctx;
360  const int list_id = ctx->list_id;
361 
362  InspectionBuffer *buffer = HttpRequestBodyGetDataCallback(
363  det_ctx, ctx->transforms, f, flags, txv, list_id, ctx->base_list_id);
364  if (buffer == NULL)
365  return;
366 
367  if (buffer->inspect_len >= mpm_ctx->minlen) {
368  (void)mpm_table[mpm_ctx->mpm_type].Search(
369  mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
370  PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
371  }
372 }
373 
374 static int PrefilterMpmHttpRequestBodyRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
375  MpmCtx *mpm_ctx, const DetectBufferMpmRegistery *mpm_reg, int list_id)
376 {
377  PrefilterMpmHttpRequestBody *pectx = SCCalloc(1, sizeof(*pectx));
378  if (pectx == NULL)
379  return -1;
380  pectx->list_id = list_id;
381  pectx->base_list_id = mpm_reg->sm_list_base;
382  SCLogDebug("list_id %d base_list_id %d", list_id, pectx->base_list_id);
383  pectx->mpm_ctx = mpm_ctx;
384  pectx->transforms = &mpm_reg->transforms;
385 
386  return PrefilterAppendTxEngine(de_ctx, sgh, PrefilterTxHttpRequestBody, mpm_reg->app_v2.alproto,
387  mpm_reg->app_v2.tx_min_progress, pectx, PrefilterMpmHttpRequestBodyFree,
388  mpm_reg->pname);
389 }
390 
391 #ifdef UNITTESTS
393 #endif /* UNITTESTS */
394 
395 /**
396  * @}
397  */
HtpState_::cfg
const struct HTPCfgRec_ * cfg
Definition: app-layer-htp.h:256
DetectEngineAppInspectionEngine_
Definition: detect.h:390
SigTableElmt_::url
const char * url
Definition: detect.h:1248
DetectSignatureSetAppProto
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:1490
detect-content.h
MpmCtx_::mpm_type
uint8_t mpm_type
Definition: util-mpm.h:90
DetectEngineThreadCtx_::buffer_offset
uint32_t buffer_offset
Definition: detect.h:1062
detect-engine.h
SIGMATCH_INFO_STICKY_BUFFER
#define SIGMATCH_INFO_STICKY_BUFFER
Definition: detect.h:1455
SigTableElmt_::desc
const char * desc
Definition: detect.h:1247
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
@ DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
Definition: detect-engine-content-inspection.h:36
DETECT_CI_FLAGS_START
#define DETECT_CI_FLAGS_START
Definition: detect-engine-content-inspection.h:39
flow-util.h
SIGMATCH_INFO_CONTENT_MODIFIER
#define SIGMATCH_INFO_CONTENT_MODIFIER
Definition: detect.h:1453
SigTableElmt_::name
const char * name
Definition: detect.h:1245
stream-tcp.h
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1403
DetectHttpClientBodyRegisterTests
void DetectHttpClientBodyRegisterTests(void)
Definition: detect-http-client-body.c:2941
HtpBody_::sb
StreamingBuffer * sb
Definition: app-layer-htp.h:194
DetectEngineTransforms
Definition: detect.h:372
SIG_FLAG_INIT_NEED_FLUSH
#define SIG_FLAG_INIT_NEED_FLUSH
Definition: detect.h:257
PrefilterMpmHttpRequestBody::list_id
int list_id
Definition: detect-http-client-body.c:178
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:296
HTPCfgDir_::body_limit
uint32_t body_limit
Definition: app-layer-htp.h:154
Flow_::proto
uint8_t proto
Definition: flow.h:375
DETECT_AL_HTTP_CLIENT_BODY
@ DETECT_AL_HTTP_CLIENT_BODY
Definition: detect-engine-register.h:130
DetectBufferMpmRegistery_::transforms
DetectEngineTransforms transforms
Definition: detect.h:640
AppLayerParserGetStateProgress
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
Definition: app-layer-parser.c:1102
InspectionBuffer
Definition: detect.h:338
threads.h
Flow_
Flow data structure.
Definition: flow.h:353
DetectBufferTypeRegisterSetupCallback
void DetectBufferTypeRegisterSetupCallback(const char *name, void(*SetupCallback)(const DetectEngineCtx *, Signature *))
Definition: detect-engine.c:1262
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1141
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1239
DetectBufferMpmRegistery_::app_v2
struct DetectBufferMpmRegistery_::@87::@89 app_v2
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:785
HtpTxUserData_::request_body
HtpBody request_body
Definition: app-layer-htp.h:228
detect-http-client-body.h
DetectEngineAppInspectionEngine_::sm_list_base
uint16_t sm_list_base
Definition: detect.h:397
DetectBufferMpmRegistery_
one time registration of keywords at start up
Definition: detect.h:626
InspectionBuffer::flags
uint8_t flags
Definition: detect.h:342
SignatureInitData_::init_flags
uint32_t init_flags
Definition: detect.h:503
StreamingBufferGetDataAtOffset
int StreamingBufferGetDataAtOffset(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t offset)
Definition: util-streaming-buffer.c:847
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1230
detect-pcre.h
DetectEngineAppInspectionEngine_::v2
struct DetectEngineAppInspectionEngine_::@84 v2
detect-engine-prefilter.h
PrefilterMpmHttpRequestBody
struct PrefilterMpmHttpRequestBody PrefilterMpmHttpRequestBody
HTPCfgDir_::inspect_window
uint32_t inspect_window
Definition: app-layer-htp.h:156
DetectEngineThreadCtx_::mtcu
MpmThreadCtx mtcu
Definition: detect.h:1139
util-unittest.h
InspectionBufferGet
InspectionBuffer * InspectionBufferGet(DetectEngineThreadCtx *det_ctx, const int list_id)
Definition: detect-engine.c:1369
HtpBody_::first
HtpBodyChunk * first
Definition: app-layer-htp.h:191
DETECT_HTTP_REQUEST_BODY
@ DETECT_HTTP_REQUEST_BODY
Definition: detect-engine-register.h:131
HtpState_
Definition: app-layer-htp.h:246
util-unittest-helper.h
PrefilterMpmHttpRequestBody
Definition: detect-http-client-body.c:177
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1086
HtpBody_::content_len_so_far
uint64_t content_len_so_far
Definition: app-layer-htp.h:197
DetectEngineAppInspectionEngine_::sm_list
uint16_t sm_list
Definition: detect.h:396
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:230
app-layer-htp.h
decode.h
util-debug.h
HTPCfgRec_::http_body_inline
int http_body_inline
Definition: app-layer-htp.h:170
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
PrefilterMpmHttpRequestBody::transforms
const DetectEngineTransforms * transforms
Definition: detect-http-client-body.c:181
DetectEngineThreadCtx_
Definition: detect.h:1034
HTPCfgDir_::inspect_min_size
uint32_t inspect_min_size
Definition: app-layer-htp.h:155
AppLayerHtpEnableRequestBodyCallback
void AppLayerHtpEnableRequestBodyCallback(void)
Sets a flag that informs the HTP app layer that some module in the engine needs the http request body...
Definition: app-layer-htp.c:466
SCEnter
#define SCEnter(...)
Definition: util-debug.h:298
detect-engine-mpm.h
detect-http-client-body.c
Handle HTTP request body match corresponding to http_client_body keyword.
detect.h
DETECT_ENGINE_INSPECT_SIG_MATCH
#define DETECT_ENGINE_INSPECT_SIG_MATCH
Definition: detect-engine-state.h:39
InspectionBuffer::inspect_offset
uint64_t inspect_offset
Definition: detect.h:340
SigTableElmt_::alternative
uint16_t alternative
Definition: detect.h:1243
app-layer-parser.h
MpmCtx_::minlen
uint16_t minlen
Definition: util-mpm.h:99
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:281
util-profiling.h
DetectEngineContentModifierBufferSetup
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
Definition: detect-parse.c:146
Packet_
Definition: decode.h:434
DETECT_CI_FLAGS_END
#define DETECT_CI_FLAGS_END
Definition: detect-engine-content-inspection.h:40
DetectAppLayerInspectEngineRegister2
void DetectAppLayerInspectEngineRegister2(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr2 Callback2, InspectionBufferGetDataPtr GetData)
register inspect engine at start up time
Definition: detect-engine.c:227
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:611
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:314
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
MpmTableElmt_::Search
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
Definition: util-mpm.h:165
DETECT_ENGINE_INSPECT_SIG_CANT_MATCH
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH
Definition: detect-engine-state.h:40
detect-engine-content-inspection.h
DetectEngineThreadCtx_::discontinue_matching
uint16_t discontinue_matching
Definition: detect.h:1101
DetectEngineAppInspectionEngine_::smd
SigMatchData * smd
Definition: detect.h:407
DetectEngineContentInspection
uint8_t DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Packet *p, Flow *f, const uint8_t *buffer, uint32_t buffer_len, uint32_t stream_start_offset, uint8_t flags, uint8_t inspection_mode)
Run the actual payload match functions.
Definition: detect-engine-content-inspection.c:104
PrefilterMpmHttpRequestBody::base_list_id
int base_list_id
Definition: detect-http-client-body.c:179
DetectAppLayerMpmRegister2
void DetectAppLayerMpmRegister2(const char *name, int direction, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistery *mpm_reg, int list_id), InspectionBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
register a MPM engine
Definition: detect-engine-mpm.c:89
PREFILTER_PROFILING_ADD_BYTES
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
Definition: util-profiling.h:304
HtpBody_
Definition: app-layer-htp.h:190
DetectBufferMpmRegistery_::pname
char pname[32]
Definition: detect.h:628
flags
uint8_t flags
Definition: decode-gre.h:0
suricata-common.h
PrefilterMpmHttpRequestBody::mpm_ctx
const MpmCtx * mpm_ctx
Definition: detect-http-client-body.c:180
HTPCfgRec_::request
HTPCfgDir request
Definition: app-layer-htp.h:177
InspectionBufferApplyTransforms
void InspectionBufferApplyTransforms(InspectionBuffer *buffer, const DetectEngineTransforms *transforms)
Definition: detect-engine.c:1552
HtpBodyChunk_
Definition: app-layer-htp.h:182
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:30
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:73
DetectEngineThreadCtx_::inspection_recursion_counter
int inspection_recursion_counter
Definition: detect.h:1118
DetectHttpClientBodyRegister
void DetectHttpClientBodyRegister(void)
Registers the keyword handlers for the "http_client_body" keyword.
Definition: detect-http-client-body.c:82
util-spm.h
HtpTxUserData_
Definition: app-layer-htp.h:213
DETECT_ENGINE_INSPECT_SIG_NO_MATCH
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
Definition: detect-engine-state.h:38
DetectEngineAppInspectionEngine_::progress
int16_t progress
Definition: detect.h:398
InspectionBuffer::inspect_len
uint32_t inspect_len
Definition: detect.h:341
InspectionBuffer::inspect
const uint8_t * inspect
Definition: detect.h:339
str
#define str(s)
Definition: suricata-common.h:272
InspectionBufferSetup
void InspectionBufferSetup(DetectEngineThreadCtx *det_ctx, const int list_id, InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
Definition: detect-engine.c:1450
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Flow_::alstate
void * alstate
Definition: flow.h:486
Signature_::id
uint32_t id
Definition: detect.h:574
detect-parse.h
Signature_
Signature container.
Definition: detect.h:540
PrefilterAppendTxEngine
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)
Definition: detect-engine-prefilter.c:270
DetectEngineAppInspectionEngine_::transforms
const DetectEngineTransforms * transforms
Definition: detect.h:404
mpm_table
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
Definition: util-mpm.c:48
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1431
DetectBufferSetActiveList
int DetectBufferSetActiveList(Signature *s, const int list)
Definition: detect-engine.c:1300
DetectBufferTypeSetDescriptionByName
void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc)
Definition: detect-engine.c:1183
MpmCtx_
Definition: util-mpm.h:88
flow.h
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:460
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
flow-var.h
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1237
HtpBody_::body_inspected
uint64_t body_inspected
Definition: app-layer-htp.h:201
app-layer.h
DetectBufferMpmRegistery_::sm_list_base
int16_t sm_list_base
Definition: detect.h:631