suricata
detect-filemagic.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2023 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  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  */
24 
25 #include "suricata-common.h"
26 #include "threads.h"
27 #include "decode.h"
28 
29 #include "detect.h"
30 #include "detect-parse.h"
31 #include "detect-content.h"
32 
33 #include "detect-engine.h"
34 #include "detect-engine-buffer.h"
35 #include "detect-engine-mpm.h"
38 #include "detect-engine-file.h"
39 
40 #include "flow.h"
41 #include "flow-var.h"
42 #include "flow-util.h"
43 
44 #include "util-debug.h"
45 #include "util-spm-bm.h"
46 #include "util-magic.h"
47 #include "util-print.h"
48 
49 #include "util-unittest-helper.h"
50 #include "util-profiling.h"
51 
52 #include "app-layer.h"
53 #include "app-layer-parser.h"
54 
55 #include "stream-tcp.h"
56 
57 #include "detect-file-data.h"
58 #include "detect-filemagic.h"
59 
60 #include "conf.h"
61 
62 #ifndef HAVE_MAGIC
63 
64 static int DetectFilemagicSetupNoSupport (DetectEngineCtx *de_ctx, Signature *s, const char *str)
65 {
66  SCLogError("no libmagic support built in, needed for filemagic keyword");
67  return -1;
68 }
69 
70 /**
71  * \brief Registration function for keyword: filemagic
72  */
74 {
75  sigmatch_table[DETECT_FILEMAGIC].name = "filemagic";
76  sigmatch_table[DETECT_FILEMAGIC].desc = "match on the information libmagic returns about a file";
77  sigmatch_table[DETECT_FILEMAGIC].url = "/rules/file-keywords.html#file-magic";
78  sigmatch_table[DETECT_FILEMAGIC].Setup = DetectFilemagicSetupNoSupport;
80 }
81 
82 #else /* HAVE_MAGIC */
83 
84 typedef struct DetectFilemagicThreadData {
85  magic_t ctx;
86 } DetectFilemagicThreadData;
87 
88 static int DetectFilemagicSetup(DetectEngineCtx *, Signature *, const char *);
89 static int g_file_match_list_id = 0;
90 
91 static int DetectFilemagicSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str);
92 static int g_file_magic_buffer_id = 0;
93 
94 static int PrefilterMpmFilemagicRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
95  MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id);
96 static uint8_t DetectEngineInspectFilemagic(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
97  const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags,
98  void *alstate, void *txv, uint64_t tx_id);
99 
100 /**
101  * \brief Registration function for keyword: filemagic
102  */
103 void DetectFilemagicRegister(void)
104 {
105  sigmatch_table[DETECT_FILEMAGIC].name = "filemagic";
106  sigmatch_table[DETECT_FILEMAGIC].desc = "match on the information libmagic returns about a file";
107  sigmatch_table[DETECT_FILEMAGIC].url = "/rules/file-keywords.html#file-magic";
108  sigmatch_table[DETECT_FILEMAGIC].Setup = DetectFilemagicSetup;
111 
112  sigmatch_table[DETECT_FILE_MAGIC].name = "file.magic";
113  sigmatch_table[DETECT_FILE_MAGIC].desc = "sticky buffer to match on the file magic";
114  sigmatch_table[DETECT_FILE_MAGIC].url = "/rules/file-keywords.html#file-magic";
115  sigmatch_table[DETECT_FILE_MAGIC].Setup = DetectFilemagicSetupSticky;
118 
119  filehandler_table[DETECT_FILE_MAGIC].name = "file.magic",
121  filehandler_table[DETECT_FILE_MAGIC].PrefilterFn = PrefilterMpmFilemagicRegister;
122  filehandler_table[DETECT_FILE_MAGIC].Callback = DetectEngineInspectFilemagic;
123 
124  g_file_match_list_id = DetectBufferTypeRegister("files");
125 
126  DetectBufferTypeSetDescriptionByName("file.magic", "file magic");
128 
129  g_file_magic_buffer_id = DetectBufferTypeGetByName("file.magic");
130  SCLogDebug("registering filemagic rule option");
131 }
132 
133 #define FILEMAGIC_MIN_SIZE 512
134 
135 /**
136  * \brief run the magic check
137  *
138  * \param file the file
139  *
140  * \retval -1 error
141  * \retval 0 ok
142  */
143 int FilemagicThreadLookup(magic_t *ctx, File *file)
144 {
145  if (ctx == NULL || file == NULL || FileDataSize(file) == 0) {
146  SCReturnInt(-1);
147  }
148 
149  const uint8_t *data = NULL;
150  uint32_t data_len = 0;
151  uint64_t offset = 0;
152 
154  &data, &data_len, &offset);
155  if (offset == 0) {
156  if (FileDataSize(file) >= FILEMAGIC_MIN_SIZE) {
157  file->magic = MagicThreadLookup(ctx, data, data_len);
158  } else if (file->state >= FILE_STATE_CLOSED) {
159  file->magic = MagicThreadLookup(ctx, data, data_len);
160  }
161  }
162  SCReturnInt(0);
163 }
164 
165 static void *DetectFilemagicThreadInit(void *data /*@unused@*/)
166 {
167  DetectFilemagicThreadData *t = SCCalloc(1, sizeof(DetectFilemagicThreadData));
168  if (unlikely(t == NULL)) {
169  SCLogError("couldn't alloc ctx memory");
170  return NULL;
171  }
172 
173  t->ctx = MagicInitContext();
174  if (t->ctx == NULL)
175  goto error;
176 
177  return (void *)t;
178 
179 error:
180  if (t->ctx)
181  magic_close(t->ctx);
182  SCFree(t);
183  return NULL;
184 }
185 
186 static void DetectFilemagicThreadFree(void *ctx)
187 {
188  if (ctx != NULL) {
189  DetectFilemagicThreadData *t = (DetectFilemagicThreadData *)ctx;
190  if (t->ctx)
191  magic_close(t->ctx);
192  SCFree(t);
193  }
194 }
195 
196 /**
197  * \brief this function is used to parse filemagic options
198  * \brief into the current signature
199  *
200  * \param de_ctx pointer to the Detection Engine Context
201  * \param s pointer to the Current Signature
202  * \param str pointer to the user provided "filemagic" option
203  *
204  * \retval 0 on Success
205  * \retval -1 on Failure
206  */
207 static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
208 {
209  if (s->init_data->transforms.cnt) {
210  SCLogError("previous transforms not consumed before 'filemagic'");
211  SCReturnInt(-1);
212  }
215 
216  if (DetectContentSetup(de_ctx, s, str) < 0) {
217  return -1;
218  }
219 
221  if (sm == NULL)
222  return -1;
223 
225  if (DetectContentConvertToNocase(de_ctx, cd) != 0)
226  return -1;
228  de_ctx, s, NULL, DETECT_FILE_MAGIC, g_file_magic_buffer_id, s->alproto) < 0)
229  return -1;
230 
231  if (de_ctx->filemagic_thread_ctx_id == -1) {
233  de_ctx, "filemagic", DetectFilemagicThreadInit, NULL, DetectFilemagicThreadFree, 1);
234  if (de_ctx->filemagic_thread_ctx_id == -1)
235  return -1;
236  }
237  return 0;
238 }
239 
240 /* file.magic implementation */
241 
242 /**
243  * \brief this function setup the file.magic keyword used in the rule
244  *
245  * \param de_ctx Pointer to the Detection Engine Context
246  * \param s Pointer to the Signature to which the current keyword belongs
247  * \param str Should hold an empty string always
248  *
249  * \retval 0 On success
250  */
251 static int DetectFilemagicSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str)
252 {
253  if (SCDetectBufferSetActiveList(de_ctx, s, g_file_magic_buffer_id) < 0)
254  return -1;
255 
256  if (de_ctx->filemagic_thread_ctx_id == -1) {
258  de_ctx, "filemagic", DetectFilemagicThreadInit, NULL, DetectFilemagicThreadFree, 1);
259  if (de_ctx->filemagic_thread_ctx_id == -1)
260  return -1;
261  }
262  return 0;
263 }
264 
265 static InspectionBuffer *FilemagicGetDataCallback(DetectEngineThreadCtx *det_ctx,
266  const DetectEngineTransforms *transforms, Flow *f, uint8_t flow_flags, File *cur_file,
267  int list_id, int local_file_id)
268 {
269  SCEnter();
270 
271  InspectionBuffer *buffer = InspectionBufferMultipleForListGet(det_ctx, list_id, local_file_id);
272  if (buffer == NULL)
273  return NULL;
274  if (buffer->initialized)
275  return buffer;
276 
277  if (cur_file->magic == NULL) {
278  DetectFilemagicThreadData *tfilemagic =
279  (DetectFilemagicThreadData *)DetectThreadCtxGetKeywordThreadCtx(
280  det_ctx, det_ctx->de_ctx->filemagic_thread_ctx_id);
281  if (tfilemagic == NULL) {
283  return NULL;
284  }
285 
286  FilemagicThreadLookup(&tfilemagic->ctx, cur_file);
287  }
288  if (cur_file->magic == NULL) {
289  return NULL;
290  }
291 
292  const uint8_t *data = (const uint8_t *)cur_file->magic;
293  uint32_t data_len = (uint32_t)strlen(cur_file->magic);
294 
295  InspectionBufferSetupMulti(det_ctx, buffer, transforms, data, data_len);
296 
297  SCReturnPtr(buffer, "InspectionBuffer");
298 }
299 
300 static uint8_t DetectEngineInspectFilemagic(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
301  const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags,
302  void *alstate, void *txv, uint64_t tx_id)
303 {
304  const DetectEngineTransforms *transforms = NULL;
305  if (!engine->mpm) {
306  transforms = engine->v2.transforms;
307  }
308 
310  FileContainer *ffc = files.fc;
311  if (ffc == NULL || ffc->head == NULL) {
312  const bool eof = (AppLayerParserGetStateProgress(f->proto, f->alproto, txv, flags) >
313  engine->progress);
314  if (eof && engine->match_on_null) {
316  }
317  if (ffc != NULL) {
319  }
321  }
322 
324  int local_file_id = 0;
325  for (File *file = ffc->head; file != NULL; file = file->next) {
326  InspectionBuffer *buffer = FilemagicGetDataCallback(
327  det_ctx, transforms, f, flags, file, engine->sm_list, local_file_id);
328  if (buffer == NULL) {
329  local_file_id++;
330  continue;
331  }
332 
333  const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f,
334  buffer->inspect, buffer->inspect_len, buffer->inspect_offset,
336  if (match) {
338  } else {
340  }
341  local_file_id++;
342  }
343  return r;
344 }
345 
346 typedef struct PrefilterMpmFilemagic {
347  int list_id;
348  const MpmCtx *mpm_ctx;
349  const DetectEngineTransforms *transforms;
350 } PrefilterMpmFilemagic;
351 
352 /** \brief Filedata Filedata Mpm prefilter callback
353  *
354  * \param det_ctx detection engine thread ctx
355  * \param p packet to inspect
356  * \param f flow to inspect
357  * \param txv tx to inspect
358  * \param pectx inspection context
359  */
360 static void PrefilterTxFilemagic(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
361  Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *txd, const uint8_t flags)
362 {
363  SCEnter();
364 
366  return;
367 
368  const PrefilterMpmFilemagic *ctx = (const PrefilterMpmFilemagic *)pectx;
369  const MpmCtx *mpm_ctx = ctx->mpm_ctx;
370  const int list_id = ctx->list_id;
371 
373  FileContainer *ffc = files.fc;
374  if (ffc != NULL) {
375  int local_file_id = 0;
376  for (File *file = ffc->head; file != NULL; file = file->next) {
377  InspectionBuffer *buffer = FilemagicGetDataCallback(
378  det_ctx, ctx->transforms, f, flags, file, list_id, local_file_id);
379  if (buffer == NULL)
380  continue;
381 
382  if (buffer->inspect_len >= mpm_ctx->minlen) {
383  (void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx, &det_ctx->mtc, &det_ctx->pmq,
384  buffer->inspect, buffer->inspect_len);
385  PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
386  }
387  local_file_id++;
388  }
389  }
390 }
391 
392 static void PrefilterMpmFilemagicFree(void *ptr)
393 {
394  SCFree(ptr);
395 }
396 
397 static int PrefilterMpmFilemagicRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
398  MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
399 {
400  PrefilterMpmFilemagic *pectx = SCCalloc(1, sizeof(*pectx));
401  if (pectx == NULL)
402  return -1;
403  pectx->list_id = list_id;
404  pectx->mpm_ctx = mpm_ctx;
405  pectx->transforms = &mpm_reg->transforms;
406 
407  return PrefilterAppendTxEngineSubState(de_ctx, sgh, PrefilterTxFilemagic,
408  mpm_reg->app_v2.alproto, mpm_reg->app_v2.sub_state, mpm_reg->app_v2.tx_min_progress,
409  pectx, PrefilterMpmFilemagicFree, mpm_reg->pname);
410 }
411 
412 #endif /* HAVE_MAGIC */
AppLayerParserHasFilesInDir
#define AppLayerParserHasFilesInDir(txd, direction)
check if tx (possibly) has files in this tx for the direction
Definition: app-layer-parser.h:368
DetectEngineAppInspectionEngine_
Definition: detect.h:420
SigTableElmt_::url
const char * url
Definition: detect.h:1545
PrefilterAppendTxEngineSubState
int PrefilterAppendTxEngineSubState(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, AppProto alproto, uint8_t sub_state, const int8_t tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:381
DetectEngineAppInspectionEngine_::mpm
bool mpm
Definition: detect.h:424
detect-content.h
FileContainer_
Definition: util-file.h:37
MpmCtx_::mpm_type
uint8_t mpm_type
Definition: util-mpm.h:113
DetectEngineAppInspectionEngine_::v2
struct DetectEngineAppInspectionEngine_::@82 v2
detect-engine.h
SigTableElmt_::desc
const char * desc
Definition: detect.h:1544
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:78
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
flow-util.h
SigTableElmt_::name
const char * name
Definition: detect.h:1542
InspectionBuffer::initialized
bool initialized
Definition: detect-engine-inspect-buffer.h:38
stream-tcp.h
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1730
DetectThreadCtxGetKeywordThreadCtx
void * DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int id)
Retrieve thread local keyword ctx by id.
Definition: detect-engine.c:4033
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
DetectEngineTransforms
Definition: detect.h:395
DETECT_CONTENT
@ DETECT_CONTENT
Definition: detect-engine-register.h:78
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1533
Signature_::alproto
AppProto alproto
Definition: detect.h:697
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
DetectBufferMpmRegistry_::app_v2
struct DetectBufferMpmRegistry_::@90::@92 app_v2
Flow_::proto
uint8_t proto
Definition: flow.h:381
InspectionBuffer
Definition: detect-engine-inspect-buffer.h:34
threads.h
SCDetectGetLastSMFromLists
SigMatch * SCDetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
Definition: detect-parse.c:600
Flow_
Flow data structure.
Definition: flow.h:359
File_::state
FileState state
Definition: util-file.h:149
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1429
ctx
struct Thresholds ctx
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:995
DetectBufferTypeSupportsMultiInstance
void DetectBufferTypeSupportsMultiInstance(const char *name)
Definition: detect-engine.c:1402
DetectContentConvertToNocase
int DetectContentConvertToNocase(DetectEngineCtx *de_ctx, DetectContentData *cd)
Definition: detect-content.c:764
StreamingBufferGetData
int StreamingBufferGetData(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t *stream_offset)
Definition: util-streaming-buffer.c:1810
DetectBufferMpmRegistry_
one time registration of keywords at start up
Definition: detect.h:791
detect-file-data.h
p
Packet * p
Definition: fuzz_dataset.c:30
SCDetectBufferSetActiveList
int SCDetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
Definition: detect-engine-buffer.c:29
DetectContentData_
Definition: detect-content.h:93
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1524
DetectBufferMpmRegistry_::transforms
DetectEngineTransforms transforms
Definition: detect.h:804
detect-engine-prefilter.h
DetectFilemagicRegister
void DetectFilemagicRegister(void)
Registration function for keyword: filemagic.
Definition: detect-filemagic.c:73
util-unittest-helper.h
AppLayerParserGetTxFiles
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
Definition: app-layer-parser.c:963
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1452
File_::sb
StreamingBuffer * sb
Definition: util-file.h:150
DetectEngineAppInspectionEngine_::sm_list
uint16_t sm_list
Definition: detect.h:428
DETECT_ENGINE_INSPECT_SIG_CANT_MATCH_FILES
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH_FILES
Definition: detect-engine-state.h:46
SIGMATCH_SUPPORT_DIR
#define SIGMATCH_SUPPORT_DIR
Definition: detect-engine-register.h:338
SIGMATCH_INFO_MULTI_BUFFER
#define SIGMATCH_INFO_MULTI_BUFFER
Definition: detect-engine-register.h:340
decode.h
DetectBufferMpmRegistry_::pname
char pname[DETECT_PROFILE_NAME_LEN]
Definition: detect.h:793
util-debug.h
AppLayerTxData
Definition: app-layer-parser.h:172
DETECT_FILE_MAGIC
@ DETECT_FILE_MAGIC
Definition: detect-engine-register.h:230
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:22
DetectContentSetup
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr)
Function to setup a content pattern.
Definition: detect-content.c:322
DetectEngineThreadCtx_
Definition: detect.h:1316
FILE_SIG_NEED_MAGIC
#define FILE_SIG_NEED_MAGIC
Definition: detect.h:326
detect-engine-file.h
SignatureInitData_::list
int list
Definition: detect.h:645
util-print.h
detect-filemagic.h
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
detect-engine-mpm.h
FileContainer_::head
File * head
Definition: util-file.h:38
detect.h
DETECT_ENGINE_INSPECT_SIG_MATCH
#define DETECT_ENGINE_INSPECT_SIG_MATCH
Definition: detect-engine-state.h:41
DETECT_FILEMAGIC
@ DETECT_FILEMAGIC
Definition: detect-engine-register.h:229
InspectionBuffer::inspect_offset
uint64_t inspect_offset
Definition: detect-engine-inspect-buffer.h:36
DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
@ DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
Definition: detect-engine-content-inspection.h:36
SigTableElmt_::alternative
uint16_t alternative
Definition: detect.h:1540
app-layer-parser.h
MpmCtx_::minlen
uint16_t minlen
Definition: util-mpm.h:122
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:363
DetectEngineContentInspection
bool DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Packet *p, Flow *f, const uint8_t *buffer, const uint32_t buffer_len, const uint64_t stream_start_offset, const uint8_t flags, const enum DetectContentInspectionType inspection_mode)
wrapper around DetectEngineContentInspectionInternal to return true/false only
Definition: detect-engine-content-inspection.c:750
AppLayerParserGetStateProgress
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *tx, uint8_t flags)
get the progress value for a tx/protocol
Definition: app-layer-parser.c:1199
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:183
Packet_
Definition: decode.h:516
conf.h
DetectEngineAppInspectionEngine_::match_on_null
bool match_on_null
Definition: detect.h:427
util-magic.h
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:775
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:300
DetectFileHandlerTableElmt_::priority
int priority
Definition: detect-file-data.h:34
MpmTableElmt_::Search
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
Definition: util-mpm.h:200
SIGMATCH_QUOTES_MANDATORY
#define SIGMATCH_QUOTES_MANDATORY
Definition: detect-engine-register.h:322
DetectEngineThreadCtx_::mtc
MpmThreadCtx mtc
Definition: detect.h:1425
FileDataSize
uint64_t FileDataSize(const File *file)
get the size of the file data
Definition: util-file.c:308
detect-engine-content-inspection.h
DETECT_SM_LIST_NOTSET
#define DETECT_SM_LIST_NOTSET
Definition: detect.h:145
DetectEngineAppInspectionEngine_::smd
SigMatchData * smd
Definition: detect.h:444
FILE_STATE_CLOSED
@ FILE_STATE_CLOSED
Definition: util-file.h:138
File_
Definition: util-file.h:146
PREFILTER_PROFILING_ADD_BYTES
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
Definition: util-profiling.h:286
DETECT_CI_FLAGS_SINGLE
#define DETECT_CI_FLAGS_SINGLE
Definition: detect-engine-content-inspection.h:50
DetectBufferTypeRegister
int DetectBufferTypeRegister(const char *name)
Definition: detect-engine.c:1388
flags
uint8_t flags
Definition: decode-gre.h:0
DetectRegisterThreadCtxFuncs
int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *), int mode)
Register Thread keyword context Funcs.
Definition: detect-engine.c:3963
AppLayerGetFileState
Definition: util-file.h:44
suricata-common.h
AppLayerGetFileState::fc
FileContainer * fc
Definition: util-file.h:45
Signature_::file_flags
uint8_t file_flags
Definition: detect.h:708
SIGMATCH_OPTIONAL_OPT
#define SIGMATCH_OPTIONAL_OPT
Definition: detect-engine-register.h:315
File_::next
struct File_ * next
Definition: util-file.h:159
detect-engine-buffer.h
DetectFileHandlerTableElmt_::PrefilterFn
PrefilterRegisterFunc PrefilterFn
Definition: detect-file-data.h:35
util-spm-bm.h
DETECT_ENGINE_INSPECT_SIG_NO_MATCH
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
Definition: detect-engine-state.h:40
InspectionBuffer::inspect_len
uint32_t inspect_len
Definition: detect-engine-inspect-buffer.h:37
DetectEngineCtx_::filemagic_thread_ctx_id
int filemagic_thread_ctx_id
Definition: detect.h:1049
InspectionBuffer::inspect
const uint8_t * inspect
Definition: detect-engine-inspect-buffer.h:35
str
#define str(s)
Definition: suricata-common.h:313
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
SCFree
#define SCFree(p)
Definition: util-mem.h:61
detect-parse.h
Signature_
Signature container.
Definition: detect.h:692
SigMatch_
a single match condition for a signature
Definition: detect.h:360
DetectEngineAppInspectionEngine_::transforms
const DetectEngineTransforms * transforms
Definition: detect.h:441
SIGMATCH_INFO_STICKY_BUFFER
#define SIGMATCH_INFO_STICKY_BUFFER
Definition: detect-engine-register.h:330
mpm_table
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
Definition: util-mpm.c:46
DetectFileHandlerTableElmt_::Callback
InspectEngineFuncPtr Callback
Definition: detect-file-data.h:36
DetectEngineThreadCtx_::de_ctx
DetectEngineCtx * de_ctx
Definition: detect.h:1444
InspectionBufferSetupMultiEmpty
void InspectionBufferSetupMultiEmpty(InspectionBuffer *buffer)
setup the buffer empty
Definition: detect-engine-inspect-buffer.c:144
FILE_SIG_NEED_FILE
#define FILE_SIG_NEED_FILE
Definition: detect.h:324
DetectFileHandlerTableElmt_::name
const char * name
Definition: detect-file-data.h:33
DetectBufferTypeSetDescriptionByName
void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc)
Definition: detect-engine.c:1549
SignatureInitData_::transforms
DetectEngineTransforms transforms
Definition: detect.h:652
MpmCtx_
Definition: util-mpm.h:111
flow.h
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:455
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
flow-var.h
SIGMATCH_HANDLE_NEGATION
#define SIGMATCH_HANDLE_NEGATION
Definition: detect-engine-register.h:326
DetectEngineTransforms::cnt
uint8_t cnt
Definition: detect.h:397
filehandler_table
DetectFileHandlerTableElmt filehandler_table[DETECT_TBLSIZE_STATIC]
Definition: detect-file-data.c:78
InspectionBufferSetupMulti
void InspectionBufferSetupMulti(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
Definition: detect-engine-inspect-buffer.c:157
InspectionBufferMultipleForListGet
InspectionBuffer * InspectionBufferMultipleForListGet(DetectEngineThreadCtx *det_ctx, const int list_id, const uint32_t local_id)
for a InspectionBufferMultipleForList get a InspectionBuffer
Definition: detect-engine-inspect-buffer.c:76
app-layer.h
DetectEngineAppInspectionEngine_::progress
uint8_t progress
Definition: detect.h:430
f
Flow f
Definition: fuzz_dataset.c:32