suricata
detect-http-header.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 Pablo Rincon <pablo.rincon.crespo@gmail.com>
29  *
30  * Implements support for http_header 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 "util-debug.h"
48 #include "util-print.h"
49 #include "util-memcmp.h"
50 
51 #include "app-layer.h"
52 #include "app-layer-parser.h"
53 
54 #include "app-layer-htp.h"
55 #include "detect-http-header.h"
57 
58 static int DetectHttpHeaderSetup(DetectEngineCtx *, Signature *, const char *);
59 #ifdef UNITTESTS
60 static void DetectHttpHeaderRegisterTests(void);
61 #endif
62 static int g_http_header_buffer_id = 0;
63 static int g_keyword_thread_id = 0;
64 
65 #define BUFFER_SIZE_STEP 1024
67 
68 static uint8_t *GetBufferForTX(
69  htp_tx_t *tx, DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, uint32_t *buffer_len)
70 {
71  *buffer_len = 0;
72 
73  HttpHeaderThreadData *hdr_td = NULL;
74  HttpHeaderBuffer *buf =
75  HttpHeaderGetBufferSpace(det_ctx, f, flags, g_keyword_thread_id, &hdr_td);
76  if (unlikely(buf == NULL)) {
77  return NULL;
78  }
79 
80  htp_table_t *headers;
81  if (flags & STREAM_TOSERVER) {
82  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, tx, flags) <=
83  HTP_REQUEST_HEADERS)
84  return NULL;
85  headers = tx->request_headers;
86  } else {
87  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, tx, flags) <=
88  HTP_RESPONSE_HEADERS)
89  return NULL;
90  headers = tx->response_headers;
91  }
92  if (headers == NULL)
93  return NULL;
94 
95  size_t i = 0;
96  size_t no_of_headers = htp_table_size(headers);
97  for (; i < no_of_headers; i++) {
98  htp_header_t *h = htp_table_get_index(headers, i, NULL);
99  size_t size1 = bstr_size(h->name);
100  size_t size2 = bstr_size(h->value);
101 
102  if (flags & STREAM_TOSERVER) {
103  if (size1 == 6 &&
104  SCMemcmpLowercase("cookie", bstr_ptr(h->name), 6) == 0) {
105  continue;
106  }
107  } else {
108  if (size1 == 10 &&
109  SCMemcmpLowercase("set-cookie", bstr_ptr(h->name), 10) == 0) {
110  continue;
111  }
112  }
113 
114  size_t size = size1 + size2 + 4;
115 #if 0
116  if (i + 1 == no_of_headers)
117  size += 2;
118 #endif
119  if (size + buf->len > buf->size) {
120  if (HttpHeaderExpandBuffer(hdr_td, buf, size) != 0) {
121  return NULL;
122  }
123  }
124 
125  memcpy(buf->buffer + buf->len, bstr_ptr(h->name), bstr_size(h->name));
126  buf->len += bstr_size(h->name);
127  buf->buffer[buf->len++] = ':';
128  buf->buffer[buf->len++] = ' ';
129  memcpy(buf->buffer + buf->len, bstr_ptr(h->value), bstr_size(h->value));
130  buf->len += bstr_size(h->value);
131  buf->buffer[buf->len++] = '\r';
132  buf->buffer[buf->len++] = '\n';
133 #if 0 // looks like this breaks existing rules
134  if (i + 1 == no_of_headers) {
135  buf->buffer[buf->len++] = '\r';
136  buf->buffer[buf->len++] = '\n';
137  }
138 #endif
139  }
140 
141  *buffer_len = buf->len;
142  return buf->buffer;
143 }
144 
145 static InspectionBuffer *GetBuffer2ForTX(DetectEngineThreadCtx *det_ctx,
146  const DetectEngineTransforms *transforms, Flow *_f, const uint8_t flow_flags, void *txv,
147  const int list_id)
148 {
149  InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
150  if (buffer->inspect == NULL) {
151  uint32_t b_len = 0;
152  const uint8_t *b = NULL;
153 
154  if (rs_http2_tx_get_headers(txv, flow_flags, &b, &b_len) != 1)
155  return NULL;
156  if (b == NULL || b_len == 0)
157  return NULL;
158 
159  InspectionBufferSetup(det_ctx, list_id, buffer, b, b_len);
160  InspectionBufferApplyTransforms(buffer, transforms);
161  }
162 
163  return buffer;
164 }
165 
166 /** \internal
167  * \brief custom inspect function to utilize the cached headers
168  */
169 static int DetectEngineInspectBufferHttpHeader(
171  const DetectEngineAppInspectionEngine *engine,
172  const Signature *s,
173  Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
174 {
175  SCEnter();
176 
177  const int list_id = engine->sm_list;
178  InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
179  if (buffer->inspect == NULL) {
180  SCLogDebug("setting up inspect buffer %d", list_id);
181 
182  /* if prefilter didn't already run, we need to consider transformations */
183  const DetectEngineTransforms *transforms = NULL;
184  if (!engine->mpm) {
185  transforms = engine->v2.transforms;
186  }
187 
188  uint32_t rawdata_len = 0;
189  uint8_t *rawdata = GetBufferForTX(txv, det_ctx, f, flags, &rawdata_len);
190  if (rawdata_len == 0) {
191  SCLogDebug("no data");
192  goto end;
193  }
194  /* setup buffer and apply transforms */
195  InspectionBufferSetup(det_ctx, list_id, buffer, rawdata, rawdata_len);
196  InspectionBufferApplyTransforms(buffer, transforms);
197  }
198 
199  const uint32_t data_len = buffer->inspect_len;
200  const uint8_t *data = buffer->inspect;
201  const uint64_t offset = buffer->inspect_offset;
202 
203  det_ctx->discontinue_matching = 0;
204  det_ctx->buffer_offset = 0;
205  det_ctx->inspection_recursion_counter = 0;
206 
207  /* Inspect all the uricontents fetched on each
208  * transaction at the app layer */
209  int r = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd,
210  NULL, f, (uint8_t *)data, data_len, offset,
212  SCLogDebug("r = %d", r);
213  if (r == 1) {
215  }
216 end:
217  if (flags & STREAM_TOSERVER) {
218  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
219  HTP_REQUEST_HEADERS)
221  } else {
222  if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
223  HTP_RESPONSE_HEADERS)
225  }
227 }
228 
230  int list_id;
231  const MpmCtx *mpm_ctx;
234 
235 /** \brief Generic Mpm prefilter callback
236  *
237  * \param det_ctx detection engine thread ctx
238  * \param p packet to inspect
239  * \param f flow to inspect
240  * \param txv tx to inspect
241  * \param pectx inspection context
242  */
243 static void PrefilterMpmHttpHeader(DetectEngineThreadCtx *det_ctx,
244  const void *pectx,
245  Packet *p, Flow *f, void *txv,
246  const uint64_t idx, const uint8_t flags)
247 {
248  SCEnter();
249 
250  const PrefilterMpmHttpHeaderCtx *ctx = pectx;
251  const MpmCtx *mpm_ctx = ctx->mpm_ctx;
252  SCLogDebug("running on list %d", ctx->list_id);
253 
254  const int list_id = ctx->list_id;
255  InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
256  if (buffer->inspect == NULL) {
257  uint32_t rawdata_len = 0;
258  uint8_t *rawdata = GetBufferForTX(txv, det_ctx, f, flags, &rawdata_len);
259  if (rawdata_len == 0)
260  return;
261 
262  /* setup buffer and apply transforms */
263  InspectionBufferSetup(det_ctx, list_id, buffer, rawdata, rawdata_len);
265  }
266 
267  const uint32_t data_len = buffer->inspect_len;
268  const uint8_t *data = buffer->inspect;
269 
270  SCLogDebug("mpm'ing buffer:");
271  //PrintRawDataFp(stdout, data, data_len);
272 
273  if (data != NULL && data_len >= mpm_ctx->minlen) {
274  (void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
275  &det_ctx->mtcu, &det_ctx->pmq, data, data_len);
276  }
277 }
278 
279 static void PrefilterMpmHttpTrailer(DetectEngineThreadCtx *det_ctx,
280  const void *pectx,
281  Packet *p, Flow *f, void *txv,
282  const uint64_t idx, const uint8_t flags)
283 {
284  SCEnter();
285 
286  htp_tx_t *tx = txv;
287  const HtpTxUserData *htud = (const HtpTxUserData *)htp_tx_get_user_data(tx);
288  /* if the request wasn't flagged as having a trailer, we skip */
289  if (htud && (
290  ((flags & STREAM_TOSERVER) && !htud->request_has_trailers) ||
291  ((flags & STREAM_TOCLIENT) && !htud->response_has_trailers))) {
292  SCReturn;
293  }
294  PrefilterMpmHttpHeader(det_ctx, pectx, p, f, txv, idx, flags);
295  SCReturn;
296 }
297 
298 static void PrefilterMpmHttpHeaderFree(void *ptr)
299 {
300  SCFree(ptr);
301 }
302 
303 static int PrefilterMpmHttpHeaderRequestRegister(DetectEngineCtx *de_ctx,
304  SigGroupHead *sgh, MpmCtx *mpm_ctx,
305  const DetectBufferMpmRegistery *mpm_reg, int list_id)
306 {
307  SCEnter();
308 
309  /* header */
310  PrefilterMpmHttpHeaderCtx *pectx = SCCalloc(1, sizeof(*pectx));
311  if (pectx == NULL)
312  return -1;
313  pectx->list_id = list_id;
314  pectx->mpm_ctx = mpm_ctx;
315  pectx->transforms = &mpm_reg->transforms;
316 
317  int r = PrefilterAppendTxEngine(de_ctx, sgh, PrefilterMpmHttpHeader,
318  mpm_reg->app_v2.alproto, HTP_REQUEST_HEADERS,
319  pectx, PrefilterMpmHttpHeaderFree, mpm_reg->pname);
320  if (r != 0) {
321  SCFree(pectx);
322  return r;
323  }
324 
325  /* trailer */
326  pectx = SCCalloc(1, sizeof(*pectx));
327  if (pectx == NULL)
328  return -1;
329  pectx->list_id = list_id;
330  pectx->mpm_ctx = mpm_ctx;
331  pectx->transforms = &mpm_reg->transforms;
332 
333  r = PrefilterAppendTxEngine(de_ctx, sgh, PrefilterMpmHttpTrailer,
334  mpm_reg->app_v2.alproto, HTP_REQUEST_TRAILER,
335  pectx, PrefilterMpmHttpHeaderFree, mpm_reg->pname);
336  if (r != 0) {
337  SCFree(pectx);
338  }
339  return r;
340 }
341 
342 static int PrefilterMpmHttpHeaderResponseRegister(DetectEngineCtx *de_ctx,
343  SigGroupHead *sgh, MpmCtx *mpm_ctx,
344  const DetectBufferMpmRegistery *mpm_reg, int list_id)
345 {
346  SCEnter();
347 
348  /* header */
349  PrefilterMpmHttpHeaderCtx *pectx = SCCalloc(1, sizeof(*pectx));
350  if (pectx == NULL)
351  return -1;
352  pectx->list_id = list_id;
353  pectx->mpm_ctx = mpm_ctx;
354  pectx->transforms = &mpm_reg->transforms;
355 
356  int r = PrefilterAppendTxEngine(de_ctx, sgh, PrefilterMpmHttpHeader,
357  mpm_reg->app_v2.alproto, HTP_RESPONSE_HEADERS,
358  pectx, PrefilterMpmHttpHeaderFree, mpm_reg->pname);
359  if (r != 0) {
360  SCFree(pectx);
361  return r;
362  }
363 
364  /* trailer */
365  pectx = SCCalloc(1, sizeof(*pectx));
366  if (pectx == NULL)
367  return -1;
368  pectx->list_id = list_id;
369  pectx->mpm_ctx = mpm_ctx;
370  pectx->transforms = &mpm_reg->transforms;
371 
372  r = PrefilterAppendTxEngine(de_ctx, sgh, PrefilterMpmHttpTrailer,
373  mpm_reg->app_v2.alproto, HTP_RESPONSE_TRAILER,
374  pectx, PrefilterMpmHttpHeaderFree, mpm_reg->pname);
375  if (r != 0) {
376  SCFree(pectx);
377  }
378  return r;
379 }
380 
381 /**
382  * \brief The setup function for the http_header keyword for a signature.
383  *
384  * \param de_ctx Pointer to the detection engine context.
385  * \param s Pointer to signature for the current Signature being parsed
386  * from the rules.
387  * \param m Pointer to the head of the SigMatchs for the current rule
388  * being parsed.
389  * \param arg Pointer to the string holding the keyword value.
390  *
391  * \retval 0 On success.
392  * \retval -1 On failure.
393  */
394 static int DetectHttpHeaderSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
395 {
397  de_ctx, s, arg, DETECT_AL_HTTP_HEADER, g_http_header_buffer_id, ALPROTO_HTTP1);
398 }
399 
400 /**
401  * \brief this function setup the http.header keyword used in the rule
402  *
403  * \param de_ctx Pointer to the Detection Engine Context
404  * \param s Pointer to the Signature to which the current keyword belongs
405  * \param str Should hold an empty string always
406  *
407  * \retval 0 On success
408  */
409 static int DetectHttpHeaderSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str)
410 {
411  if (DetectBufferSetActiveList(s, g_http_header_buffer_id) < 0)
412  return -1;
414  return -1;
415  return 0;
416 }
417 
418 /**
419  * \brief Registers the keyword handlers for the "http_header" keyword.
420  */
422 {
423  /* http_header content modifier */
424  sigmatch_table[DETECT_AL_HTTP_HEADER].name = "http_header";
425  sigmatch_table[DETECT_AL_HTTP_HEADER].desc = "content modifier to match only on the HTTP header-buffer";
426  sigmatch_table[DETECT_AL_HTTP_HEADER].url = "/rules/http-keywords.html#http-header-and-http-raw-header";
427  sigmatch_table[DETECT_AL_HTTP_HEADER].Setup = DetectHttpHeaderSetup;
428 #ifdef UNITTESTS
430 #endif
434 
435  /* http.header sticky buffer */
436  sigmatch_table[DETECT_HTTP_HEADER].name = "http.header";
437  sigmatch_table[DETECT_HTTP_HEADER].desc = "sticky buffer to match on the normalized HTTP header-buffer";
438  sigmatch_table[DETECT_HTTP_HEADER].url = "/rules/http-keywords.html#http-header-and-http-raw-header";
439  sigmatch_table[DETECT_HTTP_HEADER].Setup = DetectHttpHeaderSetupSticky;
442 
444  HTP_REQUEST_HEADERS, DetectEngineInspectBufferHttpHeader, NULL);
446  PrefilterMpmHttpHeaderRequestRegister, NULL, ALPROTO_HTTP1,
447  0); /* not used, registered twice: HEADERS/TRAILER */
448 
450  HTP_RESPONSE_HEADERS, DetectEngineInspectBufferHttpHeader, NULL);
452  PrefilterMpmHttpHeaderResponseRegister, NULL, ALPROTO_HTTP1,
453  0); /* not used, registered twice: HEADERS/TRAILER */
454 
456  HTTP2StateDataClient, DetectEngineInspectBufferGeneric, GetBuffer2ForTX);
458  GetBuffer2ForTX, ALPROTO_HTTP2, HTTP2StateDataClient);
459 
461  HTTP2StateDataServer, DetectEngineInspectBufferGeneric, GetBuffer2ForTX);
463  GetBuffer2ForTX, ALPROTO_HTTP2, HTTP2StateDataServer);
464 
466  "http headers");
467 
468  g_http_header_buffer_id = DetectBufferTypeGetByName("http_header");
469 
470  g_keyword_thread_id = DetectRegisterThreadCtxGlobalFuncs("http_header",
472 }
473 
474 /************************************Unittests*********************************/
475 
476 #ifdef UNITTESTS
478 #endif
479 
480 /**
481  * @}
482  */
DetectEngineAppInspectionEngine_
Definition: detect.h:398
SigTableElmt_::url
const char * url
Definition: detect.h:1270
DetectSignatureSetAppProto
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:1490
BUFFER_SIZE_STEP
#define BUFFER_SIZE_STEP
Definition: detect-http-header.c:65
DetectEngineAppInspectionEngine_::mpm
bool mpm
Definition: detect.h:402
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:1088
detect-engine.h
SIGMATCH_INFO_STICKY_BUFFER
#define SIGMATCH_INFO_STICKY_BUFFER
Definition: detect.h:1477
SigTableElmt_::desc
const char * desc
Definition: detect.h:1269
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
SIGMATCH_INFO_CONTENT_MODIFIER
#define SIGMATCH_INFO_CONTENT_MODIFIER
Definition: detect.h:1475
SigTableElmt_::name
const char * name
Definition: detect.h:1267
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1425
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DetectEngineTransforms
Definition: detect.h:379
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
DetectBufferMpmRegistery_::transforms
DetectEngineTransforms transforms
Definition: detect.h:648
HttpHeaderBuffer_::len
uint32_t len
Definition: detect-http-header-common.h:30
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:1095
InspectionBuffer
Definition: detect.h:345
threads.h
Flow_
Flow data structure.
Definition: flow.h:353
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1167
PrefilterGenericMpmRegister
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistery *mpm_reg, int list_id)
Definition: detect-engine-prefilter.c:753
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1261
DetectBufferMpmRegistery_::app_v2
struct DetectBufferMpmRegistery_::@87::@89 app_v2
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:811
detect-http-header.h
DetectBufferMpmRegistery_
one time registration of keywords at start up
Definition: detect.h:634
DetectEngineContentInspection
int 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:102
SIG_FLAG_TOCLIENT
#define SIG_FLAG_TOCLIENT
Definition: detect.h:237
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1252
detect-pcre.h
DetectEngineAppInspectionEngine_::v2
struct DetectEngineAppInspectionEngine_::@84 v2
detect-engine-prefilter.h
DetectEngineThreadCtx_::mtcu
MpmThreadCtx mtcu
Definition: detect.h:1165
InspectionBufferGet
InspectionBuffer * InspectionBufferGet(DetectEngineThreadCtx *det_ctx, const int list_id)
Definition: detect-engine.c:1360
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1077
util-memcmp.h
DetectEngineAppInspectionEngine_::sm_list
uint16_t sm_list
Definition: detect.h:404
DETECT_AL_HTTP_HEADER
@ DETECT_AL_HTTP_HEADER
Definition: detect-engine-register.h:131
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:236
app-layer-htp.h
decode.h
util-debug.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectEngineThreadCtx_
Definition: detect.h:1060
util-print.h
SCEnter
#define SCEnter(...)
Definition: util-debug.h:300
detect-engine-mpm.h
detect.h
HtpTxUserData_::response_has_trailers
uint8_t response_has_trailers
Definition: app-layer-htp.h:220
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:347
SigTableElmt_::alternative
uint16_t alternative
Definition: detect.h:1265
app-layer-parser.h
MpmCtx_::minlen
uint16_t minlen
Definition: util-mpm.h:99
HtpTxUserData_::request_has_trailers
uint8_t request_has_trailers
Definition: app-layer-htp.h:219
SCReturn
#define SCReturn
Definition: util-debug.h:302
DetectEngineInspectBufferGeneric
int DetectEngineInspectBufferGeneric(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
Do the content inspection & validation for a signature.
Definition: detect-engine.c:1983
DetectEngineContentModifierBufferSetup
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
Definition: detect-parse.c:146
detect-http-header.c
Packet_
Definition: decode.h:427
detect-http-header-common.h
HttpHeaderThreadConfig_
Definition: detect-http-header-common.h:33
HttpHeaderBuffer_::buffer
uint8_t * buffer
Definition: detect-http-header-common.h:28
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:225
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
ALPROTO_HTTP2
@ ALPROTO_HTTP2
Definition: app-layer-protos.h:62
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:1127
DetectEngineAppInspectionEngine_::smd
SigMatchData * smd
Definition: detect.h:415
HttpHeaderThreadDataInit
void * HttpHeaderThreadDataInit(void *data)
Definition: detect-http-header-common.c:59
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
DETECT_CI_FLAGS_SINGLE
#define DETECT_CI_FLAGS_SINGLE
Definition: detect-engine-content-inspection.h:47
DetectBufferMpmRegistery_::pname
char pname[32]
Definition: detect.h:636
flags
uint8_t flags
Definition: decode-gre.h:0
PrefilterMpmHttpHeaderCtx::list_id
int list_id
Definition: detect-http-header.c:230
PrefilterMpmHttpHeaderCtx
Definition: detect-http-header.c:229
DetectHttpHeaderRegister
void DetectHttpHeaderRegister(void)
Registers the keyword handlers for the "http_header" keyword.
Definition: detect-http-header.c:421
suricata-common.h
DETECT_HTTP_HEADER
@ DETECT_HTTP_HEADER
Definition: detect-engine-register.h:132
InspectionBufferApplyTransforms
void InspectionBufferApplyTransforms(InspectionBuffer *buffer, const DetectEngineTransforms *transforms)
Definition: detect-engine.c:1543
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:1144
HttpHeaderBuffer_::size
uint32_t size
Definition: detect-http-header-common.h:29
HtpTxUserData_
Definition: app-layer-htp.h:214
DETECT_ENGINE_INSPECT_SIG_NO_MATCH
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
Definition: detect-engine-state.h:38
PrefilterMpmHttpHeaderCtx::transforms
const DetectEngineTransforms * transforms
Definition: detect-http-header.c:232
PrefilterMpmHttpHeaderCtx
struct PrefilterMpmHttpHeaderCtx PrefilterMpmHttpHeaderCtx
InspectionBuffer::inspect_len
uint32_t inspect_len
Definition: detect.h:348
InspectionBuffer::inspect
const uint8_t * inspect
Definition: detect.h:346
PrefilterMpmHttpHeaderCtx::mpm_ctx
const MpmCtx * mpm_ctx
Definition: detect-http-header.c:231
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:1441
SCFree
#define SCFree(p)
Definition: util-mem.h:61
detect-parse.h
Signature_
Signature container.
Definition: detect.h:548
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:412
ALPROTO_HTTP
@ ALPROTO_HTTP
Definition: app-layer-protos.h:66
mpm_table
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
Definition: util-mpm.c:48
HttpHeaderGetBufferSpace
HttpHeaderBuffer * HttpHeaderGetBufferSpace(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, const int keyword_id, HttpHeaderThreadData **ret_hdr_td)
Definition: detect-http-header-common.c:102
HttpHeaderExpandBuffer
int HttpHeaderExpandBuffer(HttpHeaderThreadData *td, HttpHeaderBuffer *buf, uint32_t size)
Definition: detect-http-header-common.c:83
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1453
DetectBufferSetActiveList
int DetectBufferSetActiveList(Signature *s, const int list)
Definition: detect-engine.c:1291
DetectBufferTypeSetDescriptionByName
void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc)
Definition: detect-engine.c:1174
MpmCtx_
Definition: util-mpm.h:88
HttpHeaderBuffer_
Definition: detect-http-header-common.h:27
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
DetectHttpHeaderRegisterTests
void DetectHttpHeaderRegisterTests(void)
Definition: detect-http-header.c:5063
HttpHeaderThreadData_
Definition: detect-http-header-common.h:37
HttpHeaderThreadDataFree
void HttpHeaderThreadDataFree(void *data)
Definition: detect-http-header-common.c:76
DetectRegisterThreadCtxGlobalFuncs
int DetectRegisterThreadCtxGlobalFuncs(const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *))
Register Thread keyword context Funcs (Global)
Definition: detect-engine.c:3508
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1259
app-layer.h