Go to the documentation of this file.
65 static void DetectFilenameRegisterTests(
void);
67 static int g_file_match_list_id = 0;
68 static int g_file_name_buffer_id = 0;
74 void *alstate,
void *txv, uint64_t tx_id);
109 SCLogDebug(
"registering filename rule option");
126 SCLogError(
"previous transforms not consumed before 'fileext'");
132 size_t dotstr_len = strlen(
str) + 2;
133 char *dotstr =
SCCalloc(1, dotstr_len);
173 SCLogError(
"previous transforms not consumed before 'filename'");
218 int list_id,
int local_file_id)
228 const uint8_t *data = cur_file->
name;
229 uint32_t data_len = cur_file->
name_len;
238 void *alstate,
void *txv, uint64_t tx_id)
247 if (ffc == NULL || ffc->
head == NULL) {
260 int local_file_id = 0;
261 for (
File *file = ffc->
head; file != NULL; file = file->
next) {
263 det_ctx, transforms, f,
flags, file, engine->
sm_list, local_file_id);
299 if (!AppLayerParserHasFilesInDir(txd,
flags))
304 const int list_id =
ctx->list_id;
309 int local_file_id = 0;
310 for (
File *file = ffc->
head; file != NULL; file = file->
next) {
312 det_ctx,
ctx->transforms, f,
flags, file, list_id, local_file_id);
326 static void PrefilterMpmFilenameFree(
void *ptr)
342 mpm_reg->
app_v2.alproto, mpm_reg->
app_v2.tx_min_progress,
343 pectx, PrefilterMpmFilenameFree, mpm_reg->
pname);
351 static int DetectFilenameSignatureParseTest01(
void)
357 FAIL_IF_NOT(
UTHParseSignature(
"alert http any any -> any any (flow:to_client; file.name; content:\"abc\"; startswith; endswith; sid:1;)",
true));
368 void DetectFilenameRegisterTests(
void)
370 UtRegisterTest(
"DetectFilenameSignatureParseTest01", DetectFilenameSignatureParseTest01);
int UTHParseSignature(const char *str, bool expect)
parser a sig and see if the expected result is correct
#define SIGMATCH_INFO_STICKY_BUFFER
SigTableElmt * sigmatch_table
Container for matching data for a signature group.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define SIGMATCH_QUOTES_OPTIONAL
int DetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
struct DetectBufferMpmRegistry_::@84::@86 app_v2
const DetectEngineTransforms * transforms
main detection engine ctx
void DetectBufferTypeSupportsMultiInstance(const char *name)
struct DetectEngineAppInspectionEngine_::@79 v2
int DetectContentConvertToNocase(DetectEngineCtx *de_ctx, DetectContentData *cd)
one time registration of keywords at start up
#define FILE_SIG_NEED_FILENAME
DetectFileHandlerTableElmt filehandler_table[DETECT_TBLSIZE_STATIC]
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
DetectEngineTransforms transforms
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH_FILES
#define PASS
Pass the test.
#define DETECT_CONTENT_ENDS_WITH
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr)
Function to setup a content pattern.
size_t strlcat(char *, const char *src, size_t siz)
#define DETECT_ENGINE_INSPECT_SIG_MATCH
@ DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
#define SIGMATCH_HANDLE_NEGATION
SignatureInitData * init_data
#define SCReturnPtr(x, type)
Data structures and function prototypes for keeping state for the detection engine.
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
#define DETECT_SM_LIST_NOTSET
struct AppLayerTxData AppLayerTxData
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
#define DETECT_CI_FLAGS_SINGLE
int DetectBufferTypeRegister(const char *name)
struct PrefilterMpmFilename PrefilterMpmFilename
PrefilterRegisterFunc PrefilterFn
void InspectionBufferSetupMulti(InspectionBuffer *buffer, const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, AppProto alproto, int tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
#define SCLogError(...)
Macro used to log ERROR messages.
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.
a single match condition for a signature
const DetectEngineTransforms * transforms
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
InspectEngineFuncPtr Callback
InspectionBuffer * InspectionBufferMultipleForListGet(DetectEngineThreadCtx *det_ctx, const int list_id, const uint32_t local_id)
for a InspectionBufferMultipleForList get a InspectionBuffer
#define FILE_SIG_NEED_FILE
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc)
DetectEngineTransforms transforms
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 uint32_t stream_start_offset, const uint8_t flags, const enum DetectContentInspectionType inspection_mode)
wrapper around DetectEngineContentInspectionInternal to return true/false only
void DetectFilenameRegister(void)
Registration function for keyword: filename.
AppProto alproto
application level protocol
void(* RegisterTests)(void)