suricata
detect-filename.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 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  * \author Pablo Rincon <pablo.rincon.crespo@gmail.com>
23  *
24  */
25 
26 #include "suricata-common.h"
27 #include "threads.h"
28 #include "decode.h"
29 
30 #include "detect.h"
31 
32 #include "detect-engine.h"
33 #include "detect-engine-buffer.h"
34 #include "detect-engine-mpm.h"
35 #include "detect-engine-state.h"
36 #include "detect-engine-file.h"
39 
40 #include "detect-parse.h"
41 #include "detect-content.h"
42 #include "detect-file-data.h"
43 
44 #include "flow.h"
45 #include "flow-var.h"
46 #include "flow-util.h"
47 
48 #include "util-debug.h"
49 #include "util-spm-bm.h"
50 #include "util-unittest-helper.h"
51 #include "util-profiling.h"
52 
53 #include "app-layer.h"
54 #include "app-layer-htp.h"
55 
56 #include "stream-tcp.h"
57 
58 #include "detect-filename.h"
59 #include "app-layer-parser.h"
60 
61 static int DetectFileextSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str);
62 static int DetectFilenameSetup (DetectEngineCtx *, Signature *, const char *);
63 static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str);
64 #ifdef UNITTESTS
65 static void DetectFilenameRegisterTests(void);
66 #endif
67 static int g_file_name_buffer_id = 0;
68 
69 static int PrefilterMpmFilenameRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx,
70  const DetectBufferMpmRegistry *mpm_reg, int list_id);
71 static uint8_t DetectEngineInspectFilename(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
72  const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags,
73  void *alstate, void *txv, uint64_t tx_id);
74 
75 /**
76  * \brief Registration function for keyword: filename
77  */
79 {
80  sigmatch_table[DETECT_FILENAME].name = "filename";
81  sigmatch_table[DETECT_FILENAME].desc = "match on the file name";
82  sigmatch_table[DETECT_FILENAME].url = "/rules/file-keywords.html#file-name";
83  sigmatch_table[DETECT_FILENAME].Setup = DetectFilenameSetup;
84 #ifdef UNITTESTS
85  sigmatch_table[DETECT_FILENAME].RegisterTests = DetectFilenameRegisterTests;
86 #endif
89 
90  sigmatch_table[DETECT_FILEEXT].name = "fileext";
91  sigmatch_table[DETECT_FILEEXT].desc = "match on the extension of a file name";
92  sigmatch_table[DETECT_FILEEXT].url = "/rules/file-keywords.html#fileext";
93  sigmatch_table[DETECT_FILEEXT].Setup = DetectFileextSetup;
96 
97  sigmatch_table[DETECT_FILE_NAME].name = "file.name";
98  sigmatch_table[DETECT_FILE_NAME].desc = "sticky buffer to match on the file name";
99  sigmatch_table[DETECT_FILE_NAME].url = "/rules/file-keywords.html#file-name";
100  sigmatch_table[DETECT_FILE_NAME].Setup = DetectFilenameSetupSticky;
103 
104  DetectBufferTypeSetDescriptionByName("file.name", "file name");
105 
106  g_file_name_buffer_id = DetectBufferTypeRegister("file.name");
107 
108  SCLogDebug("registering filename rule option");
113 
114  filehandler_table[DETECT_FILE_NAME].name = "file.name";
116  filehandler_table[DETECT_FILE_NAME].PrefilterFn = PrefilterMpmFilenameRegister;
117  filehandler_table[DETECT_FILE_NAME].Callback = DetectEngineInspectFilename;
118 
120 }
121 
122 static int DetectFileextSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
123 {
124  if (s->init_data->transforms.cnt) {
125  SCLogError("previous transforms not consumed before 'fileext'");
126  SCReturnInt(-1);
127  }
130 
131  size_t dotstr_len = strlen(str) + 2;
132  char *dotstr = SCCalloc(1, dotstr_len);
133  if (dotstr == NULL)
134  return -1;
135  dotstr[0] = '.';
136  strlcat(dotstr, str, dotstr_len);
137 
138  if (DetectContentSetup(de_ctx, s, dotstr) < 0) {
139  SCFree(dotstr);
140  return -1;
141  }
142  SCFree(dotstr);
143 
145  if (sm == NULL)
146  return -1;
147 
150  if (DetectContentConvertToNocase(de_ctx, cd) != 0)
151  return -1;
153  de_ctx, s, NULL, DETECT_FILE_NAME, g_file_name_buffer_id, s->alproto) < 0)
154  return -1;
155 
156  return 0;
157 }
158 /**
159  * \brief this function is used to parse filename options
160  * \brief into the current signature
161  *
162  * \param de_ctx pointer to the Detection Engine Context
163  * \param s pointer to the Current Signature
164  * \param str pointer to the user provided "filename" option
165  *
166  * \retval 0 on Success
167  * \retval -1 on Failure
168  */
169 static int DetectFilenameSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str)
170 {
171  if (s->init_data->transforms.cnt) {
172  SCLogError("previous transforms not consumed before 'filename'");
173  SCReturnInt(-1);
174  }
177 
178  if (DetectContentSetup(de_ctx, s, str) < 0) {
179  return -1;
180  }
181 
183  if (sm == NULL)
184  return -1;
185 
187  if (DetectContentConvertToNocase(de_ctx, cd) != 0)
188  return -1;
190  de_ctx, s, NULL, DETECT_FILE_NAME, g_file_name_buffer_id, s->alproto) < 0)
191  return -1;
192 
193  return 0;
194 }
195 
196 /* file.name implementation */
197 
198 /**
199  * \brief this function setup the file.data keyword used in the rule
200  *
201  * \param de_ctx Pointer to the Detection Engine Context
202  * \param s Pointer to the Signature to which the current keyword belongs
203  * \param str Should hold an empty string always
204  *
205  * \retval 0 On success
206  */
207 static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str)
208 {
209  if (SCDetectBufferSetActiveList(de_ctx, s, g_file_name_buffer_id) < 0)
210  return -1;
212  return 0;
213 }
214 
215 static InspectionBuffer *FilenameGetDataCallback(DetectEngineThreadCtx *det_ctx,
216  const DetectEngineTransforms *transforms, Flow *f, uint8_t flow_flags, File *cur_file,
217  int list_id, int local_file_id)
218 {
219  SCEnter();
220 
221  InspectionBuffer *buffer = InspectionBufferMultipleForListGet(det_ctx, list_id, local_file_id);
222  if (buffer == NULL)
223  return NULL;
224  if (buffer->initialized)
225  return buffer;
226 
227  const uint8_t *data = cur_file->name;
228  uint32_t data_len = cur_file->name_len;
229 
230  InspectionBufferSetupMulti(det_ctx, buffer, transforms, data, data_len);
231 
232  SCReturnPtr(buffer, "InspectionBuffer");
233 }
234 
235 static uint8_t DetectEngineInspectFilename(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
236  const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags,
237  void *alstate, void *txv, uint64_t tx_id)
238 {
239  const DetectEngineTransforms *transforms = NULL;
240  if (!engine->mpm) {
241  transforms = engine->v2.transforms;
242  }
243 
245  FileContainer *ffc = files.fc;
246  if (ffc == NULL || ffc->head == NULL) {
247  const bool eof = (AppLayerParserGetStateProgress(f->proto, f->alproto, txv, flags) >
248  engine->progress);
249  if (eof && engine->match_on_null) {
251  }
252  if (ffc != NULL) {
254  }
256  }
257 
259  int local_file_id = 0;
260  for (File *file = ffc->head; file != NULL; file = file->next) {
261  InspectionBuffer *buffer = FilenameGetDataCallback(
262  det_ctx, transforms, f, flags, file, engine->sm_list, local_file_id);
263  if (buffer == NULL) {
264  local_file_id++;
265  continue;
266  }
267 
268  const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f,
269  buffer->inspect, buffer->inspect_len, buffer->inspect_offset,
271  if (match) {
273  } else {
275  }
276  local_file_id++;
277  }
278  return r;
279 }
280 
281 typedef struct PrefilterMpmFilename {
282  int list_id;
283  const MpmCtx *mpm_ctx;
286 
287 /** \brief Filedata Filedata Mpm prefilter callback
288  *
289  * \param det_ctx detection engine thread ctx
290  * \param p packet to inspect
291  * \param f flow to inspect
292  * \param txv tx to inspect
293  * \param pectx inspection context
294  */
295 static void PrefilterTxFilename(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p,
296  Flow *f, void *txv, const uint64_t idx, const AppLayerTxData *txd, const uint8_t flags)
297 {
298  SCEnter();
299 
301  return;
302 
303  const PrefilterMpmFilename *ctx = (const PrefilterMpmFilename *)pectx;
304  const MpmCtx *mpm_ctx = ctx->mpm_ctx;
305  const int list_id = ctx->list_id;
306 
308  FileContainer *ffc = files.fc;
309  if (ffc != NULL) {
310  int local_file_id = 0;
311  for (File *file = ffc->head; file != NULL; file = file->next) {
312  InspectionBuffer *buffer = FilenameGetDataCallback(
313  det_ctx, ctx->transforms, f, flags, file, list_id, local_file_id);
314  if (buffer == NULL)
315  continue;
316 
317  if (buffer->inspect_len >= mpm_ctx->minlen) {
318  (void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx, &det_ctx->mtc, &det_ctx->pmq,
319  buffer->inspect, buffer->inspect_len);
320  PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
321  }
322  local_file_id++;
323  }
324  }
325 }
326 
327 static void PrefilterMpmFilenameFree(void *ptr)
328 {
329  SCFree(ptr);
330 }
331 
332 static int PrefilterMpmFilenameRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx,
333  const DetectBufferMpmRegistry *mpm_reg, int list_id)
334 {
335  PrefilterMpmFilename *pectx = SCCalloc(1, sizeof(*pectx));
336  if (pectx == NULL)
337  return -1;
338  pectx->list_id = list_id;
339  pectx->mpm_ctx = mpm_ctx;
340  pectx->transforms = &mpm_reg->transforms;
341 
342  return PrefilterAppendTxEngineSubState(de_ctx, sgh, PrefilterTxFilename,
343  mpm_reg->app_v2.alproto, mpm_reg->app_v2.sub_state, mpm_reg->app_v2.tx_min_progress,
344  pectx, PrefilterMpmFilenameFree, mpm_reg->pname);
345 }
346 
347 #ifdef UNITTESTS /* UNITTESTS */
348 
349 /**
350  * \test Test parser accepting valid rules and rejecting invalid rules
351  */
352 static int DetectFilenameSignatureParseTest01(void)
353 {
354  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; sid:1;)", true));
355  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; nocase; sid:1;)", true));
356  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; endswith; sid:1;)", true));
357  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; startswith; sid:1;)", true));
358  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; startswith; endswith; sid:1;)", true));
359  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; bsize:10; sid:1;)", true));
360 
361  FAIL_IF_NOT(UTHParseSignature("alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; rawbytes; sid:1;)", false));
362  FAIL_IF_NOT(UTHParseSignature("alert tcp any any -> any any (flow:to_client; file.name; sid:1;)", false));
363  //FAIL_IF_NOT(UTHParseSignature("alert tls any any -> any any (flow:to_client; file.name; content:\"abc\"; sid:1;)", false));
364  PASS;
365 }
366 /**
367  * \brief this function registers unit tests for DetectFilename
368  */
369 void DetectFilenameRegisterTests(void)
370 {
371  UtRegisterTest("DetectFilenameSignatureParseTest01", DetectFilenameSignatureParseTest01);
372 }
373 #endif /* UNITTESTS */
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
UTHParseSignature
int UTHParseSignature(const char *str, bool expect)
parser a sig and see if the expected result is correct
Definition: util-unittest-helper.c:916
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
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
DetectEngineTransforms
Definition: detect.h:395
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:101
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
SIGMATCH_QUOTES_OPTIONAL
#define SIGMATCH_QUOTES_OPTIONAL
Definition: detect-engine-register.h:318
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
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1429
PrefilterMpmFilename::transforms
const DetectEngineTransforms * transforms
Definition: detect-filename.c:284
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
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
FILE_SIG_NEED_FILENAME
#define FILE_SIG_NEED_FILENAME
Definition: detect.h:325
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
detect-filename.h
util-unittest-helper.h
FAIL_IF_NOT
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
Definition: util-unittest.h:82
AppLayerParserGetTxFiles
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
Definition: app-layer-parser.c:963
File_::name_len
uint16_t name_len
Definition: util-file.h:148
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
PrefilterMpmFilename::list_id
int list_id
Definition: detect-filename.c:282
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
app-layer-htp.h
decode.h
DetectBufferMpmRegistry_::pname
char pname[DETECT_PROFILE_NAME_LEN]
Definition: detect.h:793
util-debug.h
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
DETECT_CONTENT_ENDS_WITH
#define DETECT_CONTENT_ENDS_WITH
Definition: detect-content.h:42
AppLayerTxData
Definition: app-layer-parser.h:172
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
strlcat
size_t strlcat(char *, const char *src, size_t siz)
Definition: util-strlcatu.c:45
detect-engine-file.h
SignatureInitData_::list
int list
Definition: detect.h:645
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
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
DETECT_FILENAME
@ DETECT_FILENAME
Definition: detect-engine-register.h:224
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
DetectEngineAppInspectionEngine_::match_on_null
bool match_on_null
Definition: detect.h:427
DetectContentData_::flags
uint32_t flags
Definition: detect-content.h:104
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:775
SCReturnPtr
#define SCReturnPtr(x, type)
Definition: util-debug.h:300
File_::name
uint8_t * name
Definition: util-file.h:155
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
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
DetectEngineThreadCtx_::mtc
MpmThreadCtx mtc
Definition: detect.h:1425
PrefilterMpmFilename::mpm_ctx
const MpmCtx * mpm_ctx
Definition: detect-filename.c:283
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_
Definition: util-file.h:146
PREFILTER_PROFILING_ADD_BYTES
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
Definition: util-profiling.h:286
DETECT_FILE_NAME
@ DETECT_FILE_NAME
Definition: detect-engine-register.h:225
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
AppLayerGetFileState
Definition: util-file.h:44
suricata-common.h
PrefilterMpmFilename
struct PrefilterMpmFilename PrefilterMpmFilename
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
PrefilterMpmFilename
Definition: detect-filename.c:281
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
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
DetectFileInspectGeneric
uint8_t DetectFileInspectGeneric(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
Inspect the file inspecting keywords against the state.
Definition: detect-engine-file.c:181
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
FILE_SIG_NEED_FILE
#define FILE_SIG_NEED_FILE
Definition: detect.h:324
DETECT_FILEEXT
@ DETECT_FILEEXT
Definition: detect-engine-register.h:226
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
DetectFilenameRegister
void DetectFilenameRegister(void)
Registration function for keyword: filename.
Definition: detect-filename.c:78
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
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1531
app-layer.h
DetectEngineAppInspectionEngine_::progress
uint8_t progress
Definition: detect.h:430
f
Flow f
Definition: fuzz_dataset.c:32