s=SigInit(de_ctx,"alert tcp !any any -> any any (msg:\"SigTest41-01 src address is !any \"; classtype:misc-activity; sid:410001; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation02(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any !any -> any any (msg:\"SigTest41-02 src ip is !any \"; classtype:misc-activity; sid:410002; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation03(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any any -> any [80:!80] (msg:\"SigTest41-03 dst port [80:!80] \"; classtype:misc-activity; sid:410003; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation04(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any any -> any [80,!80] (msg:\"SigTest41-03 dst port [80:!80] \"; classtype:misc-activity; sid:410003; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation05(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any any -> [192.168.0.2,!192.168.0.2] any (msg:\"SigTest41-04 dst ip [192.168.0.2,!192.168.0.2] \"; classtype:misc-activity; sid:410004; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation06(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any any -> any [100:1000,!1:20000] (msg:\"SigTest41-05 dst port [100:1000,!1:20000] \"; classtype:misc-activity; sid:410005; rev:1;)");
if(s!=NULL){
SigFree(s);
gotoend;
}
result=1;
end:
if(de_ctx!=NULL)
DetectEngineCtxFree(de_ctx);
returnresult;
}
/**
*\testcheckthatwedon'tallowinvalidnegationoptions
*/
staticintSigParseTestNegation07(void){
intresult=0;
DetectEngineCtx*de_ctx;
Signature*s=NULL;
de_ctx=DetectEngineCtxInit();
if(de_ctx==NULL)
gotoend;
de_ctx->flags|=DE_QUIET;
s=SigInit(de_ctx,"alert tcp any any -> [192.168.0.2,!192.168.0.0/24] any (msg:\"SigTest41-06 dst ip [192.168.0.2,!192.168.0.0/24] \"; classtype:misc-activity; sid:410006; rev:1;)");
s=SigInit(de_ctx,"alert tcp !any any -> any any (msg:\"SigTest41-01 src address is !any \"; classtype:misc-activity; sid:410001; rev:1;)");
if(s!=NULL){
printf("We set src ip to !any and the sig was parsed successfully: ");
SigFree(s);
result=0;
}
s=SigInit(de_ctx,"alert tcp any !any -> any any (msg:\"SigTest41-02 src ip is !any \"; classtype:misc-activity; sid:410002; rev:1;)");
if(s!=NULL){
printf("We set src port to !any and the sig was parsed successfully: ");
SigFree(s);
result=0;
}
s=SigInit(de_ctx,"alert tcp any any -> any [80:!80] (msg:\"SigTest41-03 dst port [80:!80] \"; classtype:misc-activity; sid:410003; rev:1;)");
if(s!=NULL){
printf("We set dst port to [80:!80] and the sig was parsed successfully: ");
SigFree(s);
result=0;
}
s=SigInit(de_ctx,"alert tcp any any -> [192.168.0.2,!192.168.0.2] any (msg:\"SigTest41-04 dst ip [192.168.0.2,!192.168.0.2] \"; classtype:misc-activity; sid:410004; rev:1;)");
if(s!=NULL){
printf("We set dst ip to [192.168.0.2,!192.168.0.2] and the sig was parsed successfully: ");
SigFree(s);
result=0;
}
s=SigInit(de_ctx,"alert tcp any any -> any [100:1000,!1:20000] (msg:\"SigTest41-05 dst port [100:1000,!1:20000] \"; classtype:misc-activity; sid:410005; rev:1;)");
if(s!=NULL){
printf("We set dst port to [100:1000,!1:20000] and the sig was parsed successfully: ");
SigFree(s);
result=0;
}
s=SigInit(de_ctx,"alert tcp any any -> [192.168.0.2,!192.168.0.0/24] any (msg:\"SigTest41-06 dst ip [192.168.0.2,!192.168.0.0/24] \"; classtype:misc-activity; sid:410006; rev:1;)");
if(s!=NULL){
printf("We set dst ip to [192.168.0.2,!192.168.0.0/24] and the sig was parsed successfully: ");