|
|
@ -1,4 +1,4 @@
|
|
|
|
/* Copyright (C) 2015 Open Information Security Foundation
|
|
|
|
/* Copyright (C) 2015-2016 Open Information Security Foundation
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You can copy, redistribute or modify this Program under the terms of
|
|
|
|
* You can copy, redistribute or modify this Program under the terms of
|
|
|
|
* the GNU General Public License version 2 as published by the Free
|
|
|
|
* the GNU General Public License version 2 as published by the Free
|
|
|
@ -229,40 +229,25 @@ static void DetectTemplateFree(void *ptr) {
|
|
|
|
* \test description of the test
|
|
|
|
* \test description of the test
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static int DetectTemplateParseTest01 (void) {
|
|
|
|
static int DetectTemplateParseTest01 (void)
|
|
|
|
DetectTemplateData *templated = NULL;
|
|
|
|
{
|
|
|
|
uint8_t res = 0;
|
|
|
|
DetectTemplateData *templated = DetectTemplateParse("1,10");
|
|
|
|
|
|
|
|
FAIL_IF_NULL(templated);
|
|
|
|
templated = DetectTemplateParse("1,10");
|
|
|
|
FAIL_IF(!(templated->arg1 == 1 && templated->arg2 == 10));
|
|
|
|
if (templated != NULL) {
|
|
|
|
DetectTemplateFree(templated);
|
|
|
|
if (templated->arg1 == 1 && templated->arg2 == 10)
|
|
|
|
PASS;
|
|
|
|
res = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DetectTemplateFree(templated);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int DetectTemplateSignatureTest01 (void) {
|
|
|
|
static int DetectTemplateSignatureTest01 (void)
|
|
|
|
uint8_t res = 0;
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
|
|
|
|
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
|
|
|
|
if (de_ctx == NULL)
|
|
|
|
FAIL_IF_NULL(de_ctx);
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Signature *sig = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (template:1,10; sid:1; rev:1;)");
|
|
|
|
Signature *sig = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (template:1,10; sid:1; rev:1;)");
|
|
|
|
if (sig == NULL) {
|
|
|
|
FAIL_IF_NULL(sig);
|
|
|
|
printf("parsing signature failed: ");
|
|
|
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* if we get here, all conditions pass */
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
res = 1;
|
|
|
|
PASS;
|
|
|
|
end:
|
|
|
|
|
|
|
|
if (de_ctx != NULL)
|
|
|
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|