Go to the documentation of this file.
49 static void DetectTemplateRustBufferRegisterTests(
void);
51 static int g_template_rust_id = 0;
56 if (
ConfGetNode(
"app-layer.protocols.template-rust") == NULL) {
62 "Template content modifier to match on the template buffers";
71 DetectEngineInspectTemplateRustBuffer, NULL);
73 DetectEngineInspectTemplateRustBuffer, NULL);
77 SCLogNotice(
"Template application layer detect registered.");
95 const uint8_t *data = NULL;
96 uint32_t data_len = 0;
98 if (
flags & STREAM_TOSERVER) {
99 rs_template_get_request_buffer(txv, &data, &data_len);
100 }
else if (
flags & STREAM_TOCLIENT) {
101 rs_template_get_response_buffer(txv, &data, &data_len);
122 static int DetectTemplateRustBufferTest(
void)
133 uint8_t request[] =
"12:Hello World!";
136 memset(&f, 0,
sizeof(
Flow));
143 f.
proto = IPPROTO_TCP;
155 "msg:\"TEMPLATE Test Rule\"; "
156 "template_rust_buffer; content:\"World!\"; "
162 "msg:\"TEMPLATE Test Rule\"; "
163 "template_rust_buffer; content:\"W0rld!\"; "
196 static void DetectTemplateRustBufferRegisterTests(
void)
199 DetectTemplateRustBufferTest);
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
main detection engine ctx
@ DETECT_AL_TEMPLATE_BUFFER
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
#define FLOW_PKT_TOSERVER
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
#define SIG_FLAG_TOCLIENT
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int DetectBufferTypeGetByName(const char *name)
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
#define FLOW_INITIALIZE(f)
#define SIG_FLAG_TOSERVER
#define PASS
Pass the test.
AppLayerParserThreadCtx * alp_tctx
Per thread variable structure.
int SigGroupCleanup(DetectEngineCtx *de_ctx)
void DetectAppLayerInspectEngineRegister2(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr2 Callback2, InspectionBufferGetDataPtr GetData)
register inspect engine at start up time
SignatureInitData * init_data
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
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.
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
#define DETECT_CI_FLAGS_SINGLE
void StreamTcpFreeConfig(bool quiet)
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
void UTHFreePacket(Packet *p)
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
#define FLOW_PKT_ESTABLISHED
DetectEngineCtx * DetectEngineCtxInit(void)
@ DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE
void DetectTemplateRustBufferRegister(void)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
AppProto alproto
application level protocol
void(* RegisterTests)(void)