From: Victor Julien Date: Fri, 17 Mar 2023 16:23:39 +0000 (+0100) Subject: detect/file_data: remove obsolete tests X-Git-Tag: suricata-7.0.0-rc2~402 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d4e998e0b89db380bbe556fcc74d0b9c4b3b567e;p=thirdparty%2Fsuricata.git detect/file_data: remove obsolete tests --- diff --git a/src/tests/detect-file-data.c b/src/tests/detect-file-data.c index e96b3418a3..cb0168691f 100644 --- a/src/tests/detect-file-data.c +++ b/src/tests/detect-file-data.c @@ -45,51 +45,6 @@ static int DetectEngineSMTPFiledataTest02(void) PASS; } -static int DetectFiledataParseTest01(void) -{ - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - de_ctx->flags |= DE_QUIET; - Signature *s = - DetectEngineAppendSig(de_ctx, "alert smtp any any -> any any " - "(msg:\"test\"; file_data; content:\"abc\"; sid:1;)"); - FAIL_IF_NULL(s); - FAIL_IF_NOT_NULL(s->sm_lists[DETECT_SM_LIST_PMATCH]); - FAIL_IF_NULL(s->sm_lists[g_file_data_buffer_id]); - DetectEngineCtxFree(de_ctx); - PASS; -} - -static int DetectFiledataParseTest02(void) -{ - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - de_ctx->flags |= DE_QUIET; - Signature *s = - DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any " - "(msg:\"test\"; file_data; content:\"abc\"; sid:1;)"); - FAIL_IF_NULL(s); - FAIL_IF_NOT_NULL(s->sm_lists[DETECT_SM_LIST_PMATCH]); - FAIL_IF_NULL(s->sm_lists[g_file_data_buffer_id]); - DetectEngineCtxFree(de_ctx); - PASS; -} - -static int DetectFiledataParseTest03(void) -{ - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - de_ctx->flags |= DE_QUIET; - Signature *s = DetectEngineAppendSig(de_ctx, - "alert tcp any any -> any 25 " - "(msg:\"test\"; flow:to_server,established; file_data; content:\"abc\"; sid:1;)"); - FAIL_IF_NULL(s); - FAIL_IF_NOT_NULL(s->sm_lists[DETECT_SM_LIST_PMATCH]); - FAIL_IF_NULL(s->sm_lists[g_file_data_buffer_id]); - DetectEngineCtxFree(de_ctx); - PASS; -} - /** * \test Test the file_data fails with flow:to_server. */ @@ -106,73 +61,9 @@ static int DetectFiledataParseTest04(void) PASS; } -static int DetectFiledataIsdataatParseTest1(void) -{ - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - de_ctx->flags |= DE_QUIET; - - Signature *s = DetectEngineAppendSig(de_ctx, - "alert tcp any any -> any any (" - "file_data; content:\"one\"; " - "isdataat:!4,relative; sid:1;)"); - FAIL_IF_NULL(s); - - SigMatch *sm = s->init_data->smlists[g_file_data_buffer_id]; - FAIL_IF_NULL(sm); - FAIL_IF_NOT(sm->type == DETECT_CONTENT); - sm = sm->next; - FAIL_IF_NULL(sm); - FAIL_IF_NOT(sm->type == DETECT_ISDATAAT); - - DetectIsdataatData *data = (DetectIsdataatData *)sm->ctx; - FAIL_IF_NOT(data->flags & ISDATAAT_RELATIVE); - FAIL_IF_NOT(data->flags & ISDATAAT_NEGATED); - FAIL_IF(data->flags & ISDATAAT_RAWBYTES); - - DetectEngineCtxFree(de_ctx); - PASS; -} - -static int DetectFiledataIsdataatParseTest2(void) -{ - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - de_ctx->flags |= DE_QUIET; - - Signature *s = DetectEngineAppendSig(de_ctx, - "alert tcp any any -> any any (" - "file_data; " - "isdataat:!4,relative; sid:1;)"); - FAIL_IF_NULL(s); - - SigMatch *sm = s->init_data->smlists_tail[g_file_data_buffer_id]; - FAIL_IF_NULL(sm); - FAIL_IF_NOT(sm->type == DETECT_ISDATAAT); - - DetectIsdataatData *data = (DetectIsdataatData *)sm->ctx; - FAIL_IF_NOT(data->flags & ISDATAAT_RELATIVE); - FAIL_IF_NOT(data->flags & ISDATAAT_NEGATED); - FAIL_IF(data->flags & ISDATAAT_RAWBYTES); - - DetectEngineCtxFree(de_ctx); - PASS; -} - void DetectFiledataRegisterTests(void) { - UtRegisterTest("DetectEngineSMTPFiledataTest02", - DetectEngineSMTPFiledataTest02); - - UtRegisterTest("DetectFiledataParseTest01", DetectFiledataParseTest01); - UtRegisterTest("DetectFiledataParseTest02", DetectFiledataParseTest02); - UtRegisterTest("DetectFiledataParseTest03", DetectFiledataParseTest03); + UtRegisterTest("DetectEngineSMTPFiledataTest02", DetectEngineSMTPFiledataTest02); UtRegisterTest("DetectFiledataParseTest04", DetectFiledataParseTest04); - - UtRegisterTest("DetectFiledataIsdataatParseTest1", - DetectFiledataIsdataatParseTest1); - UtRegisterTest("DetectFiledataIsdataatParseTest2", - DetectFiledataIsdataatParseTest2); } - #endif