Go to the documentation of this file.
53 static void DetectDistanceRegisterTests(
void);
70 const char *distancestr)
72 const char *
str = distancestr;
78 "preceding content, uricontent option, http_client_body, "
79 "http_server_body, http_header option, http_raw_header option, "
80 "http_method option, http_cookie, http_raw_uri, "
81 "http_stat_msg, http_stat_code, http_user_agent or "
82 "file_data/dce_stub_data sticky buffer option");
89 SCLogError(
"can't use multiple distances for the same content.");
94 "keyword like within/distance with a absolute "
95 "relative keyword like depth/offset for the same "
101 "negated keyword set along with a fast_pattern");
106 "keyword set along with a fast_pattern:only;");
109 if (
str[0] !=
'-' && isalpha((
unsigned char)
str[0])) {
113 "seen in distance - %s",
130 if (prev_pm == NULL) {
138 "has a fast_pattern:only; set. Can't "
139 "have relative keywords around a fast_pattern "
158 static int DetectDistanceTest01(
void)
165 "alert tcp any any -> any any (content:\"|AA BB|\"; content:\"|CC DD EE FF 00 11 22 33 "
166 "44 55 66 77 88 99 AA BB CC DD EE|\"; distance: 4; within: 19; sid:1; rev:1;)");
193 static int DetectDistanceTestPacket01 (
void)
195 uint8_t buf[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
196 uint16_t buflen =
sizeof(buf);
200 char sig[] =
"alert tcp any any -> any any (msg:\"suricata test\"; "
201 "byte_jump:1,2; content:\"|00|\"; "
202 "within:1; distance:2; sid:98711212; rev:1;)";
212 static void DetectDistanceRegisterTests(
void)
215 DetectDistanceTest01);
216 UtRegisterTest(
"DetectDistanceTestPacket01", DetectDistanceTestPacket01);
#define DETECT_CONTENT_RELATIVE_NEXT
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
#define DETECT_CONTENT_DISTANCE_VAR
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
int UTHPacketMatchSig(Packet *p, const char *sig)
SigMatch * DetectGetLastSMByListPtr(const Signature *s, SigMatch *sm_list,...)
Returns the sm with the largest index (added last) from the list passed to us as a pointer.
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.
#define DETECT_CONTENT_VALUE_MAX
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
uint8_t DetectByteIndexType
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define DETECT_CONTENT_DISTANCE
int StringParseI32RangeCheck(int32_t *res, int base, size_t len, const char *str, int32_t min, int32_t max)
#define DETECT_CONTENT_DEPTH
#define DETECT_CONTENT_NEGATED
SignatureInitData * init_data
#define DETECT_CONTENT_DISTANCE_NEXT
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define FLOW_PKT_TOCLIENT
bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
Used to retrieve args from BM.
#define SCLogError(...)
Macro used to log ERROR messages.
void UTHFreePacket(Packet *p)
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
#define DETECT_CONTENT_OFFSET
#define DETECT_CONTENT_FAST_PATTERN_ONLY
a single match condition for a signature
void DetectDistanceRegister(void)
#define FLOW_PKT_ESTABLISHED
DetectEngineCtx * DetectEngineCtxInit(void)
#define DETECT_PCRE_RELATIVE_NEXT
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
#define DETECT_CONTENT_FAST_PATTERN
void(* RegisterTests)(void)