|
|
|
|
@ -439,6 +439,21 @@ void DetectHostbitFree (void *ptr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
|
|
|
|
|
|
static void HostBitsTestSetup(void)
|
|
|
|
|
{
|
|
|
|
|
StorageInit();
|
|
|
|
|
HostBitInitCtx();
|
|
|
|
|
StorageFinalize();
|
|
|
|
|
HostInitConfig(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void HostBitsTestShutdown(void)
|
|
|
|
|
{
|
|
|
|
|
HostCleanup();
|
|
|
|
|
StorageCleanup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test HostBitsTestSig01 is a test for a valid noalert flowbits option
|
|
|
|
|
*
|
|
|
|
|
@ -462,8 +477,6 @@ static int HostBitsTestSig01(void)
|
|
|
|
|
DetectEngineCtx *de_ctx = NULL;
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
|
|
HostInitConfig(TRUE);
|
|
|
|
|
|
|
|
|
|
memset(&th_v, 0, sizeof(th_v));
|
|
|
|
|
memset(p, 0, SIZE_OF_PACKET);
|
|
|
|
|
p->src.family = AF_INET;
|
|
|
|
|
@ -472,6 +485,8 @@ static int HostBitsTestSig01(void)
|
|
|
|
|
p->payload_len = buflen;
|
|
|
|
|
p->proto = IPPROTO_TCP;
|
|
|
|
|
|
|
|
|
|
HostBitsTestSetup();
|
|
|
|
|
|
|
|
|
|
de_ctx = DetectEngineCtxInit();
|
|
|
|
|
|
|
|
|
|
if (de_ctx == NULL) {
|
|
|
|
|
@ -509,7 +524,7 @@ end:
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HostCleanup();
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
@ -550,13 +565,13 @@ static int HostBitsTestSig02(void)
|
|
|
|
|
if (s == NULL) {
|
|
|
|
|
error_count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO reenable after both is supported
|
|
|
|
|
s = DetectEngineAppendSig(de_ctx,
|
|
|
|
|
"alert ip any any -> any any (hostbits:set,abc,both; content:\"GET \"; sid:3;)");
|
|
|
|
|
if (s == NULL) {
|
|
|
|
|
error_count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
s = DetectEngineAppendSig(de_ctx,
|
|
|
|
|
"alert ip any any -> any any (hostbits:unset,abc,src; content:\"GET \"; sid:4;)");
|
|
|
|
|
if (s == NULL) {
|
|
|
|
|
@ -700,6 +715,8 @@ static int HostBitsTestSig04(void)
|
|
|
|
|
p->payload_len = buflen;
|
|
|
|
|
p->proto = IPPROTO_TCP;
|
|
|
|
|
|
|
|
|
|
HostBitsTestSetup();
|
|
|
|
|
|
|
|
|
|
de_ctx = DetectEngineCtxInit();
|
|
|
|
|
|
|
|
|
|
if (de_ctx == NULL) {
|
|
|
|
|
@ -728,6 +745,8 @@ static int HostBitsTestSig04(void)
|
|
|
|
|
|
|
|
|
|
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
@ -746,6 +765,8 @@ end:
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@ -781,6 +802,8 @@ static int HostBitsTestSig05(void)
|
|
|
|
|
p->payload_len = buflen;
|
|
|
|
|
p->proto = IPPROTO_TCP;
|
|
|
|
|
|
|
|
|
|
HostBitsTestSetup();
|
|
|
|
|
|
|
|
|
|
de_ctx = DetectEngineCtxInit();
|
|
|
|
|
|
|
|
|
|
if (de_ctx == NULL) {
|
|
|
|
|
@ -811,6 +834,8 @@ static int HostBitsTestSig05(void)
|
|
|
|
|
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
end:
|
|
|
|
|
@ -828,6 +853,8 @@ end:
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@ -1072,7 +1099,7 @@ static int HostBitsTestSig07(void)
|
|
|
|
|
memset(&th_v, 0, sizeof(th_v));
|
|
|
|
|
memset(&f, 0, sizeof(Flow));
|
|
|
|
|
|
|
|
|
|
HostInitConfig(TRUE);
|
|
|
|
|
HostBitsTestSetup();
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
p->flow = &f;
|
|
|
|
|
@ -1126,8 +1153,7 @@ static int HostBitsTestSig07(void)
|
|
|
|
|
|
|
|
|
|
FLOW_DESTROY(&f);
|
|
|
|
|
|
|
|
|
|
HostCleanup();
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
end:
|
|
|
|
|
@ -1147,6 +1173,7 @@ end:
|
|
|
|
|
|
|
|
|
|
FLOW_DESTROY(&f);
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@ -1178,7 +1205,7 @@ static int HostBitsTestSig08(void)
|
|
|
|
|
memset(&th_v, 0, sizeof(th_v));
|
|
|
|
|
memset(&f, 0, sizeof(Flow));
|
|
|
|
|
|
|
|
|
|
HostInitConfig(TRUE);
|
|
|
|
|
HostBitsTestSetup();
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
p->flow = &f;
|
|
|
|
|
@ -1253,7 +1280,7 @@ static int HostBitsTestSig08(void)
|
|
|
|
|
|
|
|
|
|
FLOW_DESTROY(&f);
|
|
|
|
|
|
|
|
|
|
HostCleanup();
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
@ -1274,6 +1301,8 @@ end:
|
|
|
|
|
|
|
|
|
|
FLOW_DESTROY(&f);
|
|
|
|
|
|
|
|
|
|
HostBitsTestShutdown();
|
|
|
|
|
|
|
|
|
|
SCFree(p);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|