|
|
|
|
@ -325,6 +325,7 @@ static int g_file_data_buffer_id = 0;
|
|
|
|
|
static int g_http_method_buffer_id = 0;
|
|
|
|
|
static int g_http_uri_buffer_id = 0;
|
|
|
|
|
static int g_http_ua_buffer_id = 0;
|
|
|
|
|
static int g_http_cookie_buffer_id = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Checks if a fast_pattern is registered in a Signature
|
|
|
|
|
@ -8277,7 +8278,7 @@ int DetectFastPatternTest302(void)
|
|
|
|
|
"content:\"three\"; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_NEGATED &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
@ -8315,7 +8316,7 @@ int DetectFastPatternTest303(void)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[g_http_cookie_buffer_id];
|
|
|
|
|
if (sm != NULL) {
|
|
|
|
|
if ( ((DetectContentData *)sm->ctx)->flags &
|
|
|
|
|
DETECT_CONTENT_FAST_PATTERN) {
|
|
|
|
|
@ -8352,7 +8353,7 @@ int DetectFastPatternTest304(void)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[g_http_cookie_buffer_id];
|
|
|
|
|
if (sm != NULL) {
|
|
|
|
|
if ( ((DetectContentData *)sm->ctx)->flags &
|
|
|
|
|
DETECT_CONTENT_FAST_PATTERN) {
|
|
|
|
|
@ -8384,7 +8385,7 @@ int DetectFastPatternTest305(void)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[g_http_cookie_buffer_id];
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)sm->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
|
|
|
|
|
@ -8418,7 +8419,7 @@ int DetectFastPatternTest306(void)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
|
|
|
|
|
sm = de_ctx->sig_list->sm_lists[g_http_cookie_buffer_id];
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)sm->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
@ -8648,7 +8649,7 @@ int DetectFastPatternTest316(void)
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
|
|
|
|
|
@ -8678,7 +8679,7 @@ int DetectFastPatternTest317(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; within:30; content:\"two\"; fast_pattern:only; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
|
|
|
|
|
@ -8708,7 +8709,7 @@ int DetectFastPatternTest318(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; offset:30; content:\"two\"; fast_pattern:only; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
|
|
|
|
|
@ -8738,7 +8739,7 @@ int DetectFastPatternTest319(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; depth:30; content:\"two\"; fast_pattern:only; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
|
|
|
|
|
@ -8768,7 +8769,7 @@ int DetectFastPatternTest320(void)
|
|
|
|
|
"(content:!\"one\"; fast_pattern; http_cookie; content:\"two\"; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_NEGATED &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
@ -8887,7 +8888,7 @@ int DetectFastPatternTest325(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -8917,7 +8918,7 @@ int DetectFastPatternTest326(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; distance:30; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -8947,7 +8948,7 @@ int DetectFastPatternTest327(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; within:30; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -8977,7 +8978,7 @@ int DetectFastPatternTest328(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; offset:30; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9007,7 +9008,7 @@ int DetectFastPatternTest329(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; depth:30; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9037,7 +9038,7 @@ int DetectFastPatternTest330(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; distance:10; content:\"oneonethree\"; fast_pattern:3,4; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9067,7 +9068,7 @@ int DetectFastPatternTest331(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; within:10; content:\"oneonethree\"; fast_pattern:3,4; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9097,7 +9098,7 @@ int DetectFastPatternTest332(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; offset:10; content:\"oneonethree\"; fast_pattern:3,4; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9127,7 +9128,7 @@ int DetectFastPatternTest333(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:\"two\"; http_cookie; depth:10; content:\"oneonethree\"; fast_pattern:3,4; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
|
|
|
|
|
@ -9226,7 +9227,7 @@ int DetectFastPatternTest337(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:!\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_NEGATED &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
@ -9345,7 +9346,7 @@ int DetectFastPatternTest342(void)
|
|
|
|
|
"(content:\"one\"; http_cookie; content:!\"oneonetwo\"; fast_pattern:3,4; http_cookie; content:\"three\"; http_cookie; sid:1;)");
|
|
|
|
|
if (de_ctx->sig_list == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[DETECT_SM_LIST_HCDMATCH]->prev->ctx;
|
|
|
|
|
DetectContentData *ud = (DetectContentData *)de_ctx->sig_list->sm_lists_tail[g_http_cookie_buffer_id]->prev->ctx;
|
|
|
|
|
if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
|
|
|
|
|
ud->flags & DETECT_CONTENT_NEGATED &&
|
|
|
|
|
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
|
|
|
|
|
@ -18829,6 +18830,7 @@ void DetectFastPatternRegisterTests(void)
|
|
|
|
|
g_http_method_buffer_id = DetectBufferTypeGetByName("http_method");
|
|
|
|
|
g_http_uri_buffer_id = DetectBufferTypeGetByName("http_uri");
|
|
|
|
|
g_http_ua_buffer_id = DetectBufferTypeGetByName("http_user_agent");
|
|
|
|
|
g_http_cookie_buffer_id = DetectBufferTypeGetByName("http_cookie");
|
|
|
|
|
|
|
|
|
|
UtRegisterTest("DetectFastPatternTest01", DetectFastPatternTest01);
|
|
|
|
|
UtRegisterTest("DetectFastPatternTest02", DetectFastPatternTest02);
|
|
|
|
|
|