60 static void IPRepRegisterTests(
void);
78 static inline int8_t GetRep(
const SReputation *r,
const uint8_t cat,
const uint32_t
version)
89 static int8_t GetHostRepSrc(
Packet *p, uint8_t cat, uint32_t
version)
116 static int8_t GetHostRepDst(
Packet *p, uint8_t cat, uint32_t
version)
151 const DetectIPRepData *rd = (
const DetectIPRepData *)
ctx;
162 val = GetHostRepSrc(p, rd->cat,
version);
169 val = GetHostRepDst(p, rd->cat,
version);
178 val = GetHostRepSrc(p, rd->cat,
version);
184 val = GetHostRepDst(p, rd->cat,
version);
196 val = GetHostRepSrc(p, rd->cat,
version);
197 SCLogDebug(
"checking src -- val %d (looking for cat %u, val %u)", val, rd->cat,
212 val = GetHostRepDst(p, rd->cat,
version);
226 val = GetHostRepSrc(p, rd->cat,
version);
231 val = GetHostRepDst(p, rd->cat,
version);
238 val = GetHostRepSrc(p, rd->cat,
version);
244 val = GetHostRepDst(p, rd->cat,
version);
260 DetectIPRepData *cd = SCDetectIPRepParse(rawstr);
262 SCLogError(
"\"%s\" is not a valid setting for iprep", rawstr);
266 SCLogDebug(
"cmd %u, cat %u, op %u, val %u", cd->cmd, cd->cat, cd->du8.mode, cd->du8.arg1);
286 DetectIPRepData *fd = (DetectIPRepData *)ptr;
290 SCDetectIPRepFree(fd);
297 static FILE *DetectIPRepGenerateCategoriesDummy(
void)
300 const char *buffer =
"1,BadHosts,Know bad hosts";
302 fd =
SCFmemopen((
void *)buffer, strlen(buffer),
"r");
309 static FILE *DetectIPRepGenerateCategoriesDummy2(
void)
313 "1,BadHosts,Know bad hosts\n"
314 "2,GoodHosts,Know good hosts\n";
316 fd =
SCFmemopen((
void *)buffer, strlen(buffer),
"r");
323 static FILE *DetectIPRepGenerateNetworksDummy(
void)
326 const char *buffer =
"10.0.0.0/24,1,20";
328 fd =
SCFmemopen((
void *)buffer, strlen(buffer),
"r");
335 static FILE *DetectIPRepGenerateNetworksDummy2(
void)
340 "192.168.0.0/16,2,127";
342 fd =
SCFmemopen((
void *)buffer, strlen(buffer),
"r");
349 static int DetectIPRepTest01(
void)
360 memset(&th_v, 0,
sizeof(th_v));
371 fd = DetectIPRepGenerateCategoriesDummy();
375 fd = DetectIPRepGenerateNetworksDummy();
380 "badhost\"; iprep:any,BadHosts,>,1; sid:1;rev:1;)");
402 static int DetectIPRepTest02(
void)
413 memset(&th_v, 0,
sizeof(th_v));
424 fd = DetectIPRepGenerateCategoriesDummy();
428 fd = DetectIPRepGenerateNetworksDummy();
433 "badhost\"; iprep:src,BadHosts,>,1; sid:1; rev:1;)");
454 static int DetectIPRepTest03(
void)
465 memset(&th_v, 0,
sizeof(th_v));
476 fd = DetectIPRepGenerateCategoriesDummy();
480 fd = DetectIPRepGenerateNetworksDummy();
485 "badhost\"; iprep:dst,BadHosts,>,1; sid:1; rev:1;)");
506 static int DetectIPRepTest04(
void)
517 memset(&th_v, 0,
sizeof(th_v));
529 fd = DetectIPRepGenerateCategoriesDummy();
533 fd = DetectIPRepGenerateNetworksDummy();
538 "badhost\"; iprep:both,BadHosts,>,1; sid:1; rev:1;)");
559 static int DetectIPRepTest05(
void)
570 memset(&th_v, 0,
sizeof(th_v));
581 fd = DetectIPRepGenerateCategoriesDummy();
585 fd = DetectIPRepGenerateNetworksDummy();
590 "badhost\"; iprep:any,BadHosts,>,1; sid:1; rev:1;)");
611 static int DetectIPRepTest06(
void)
622 memset(&th_v, 0,
sizeof(th_v));
633 fd = DetectIPRepGenerateCategoriesDummy();
637 fd = DetectIPRepGenerateNetworksDummy2();
642 "badhost\"; iprep:any,BadHosts,>,1; sid:1; rev:1;)");
663 static int DetectIPRepTest07(
void)
674 memset(&th_v, 0,
sizeof(th_v));
685 fd = DetectIPRepGenerateCategoriesDummy();
689 fd = DetectIPRepGenerateNetworksDummy2();
694 "badhost\"; iprep:any,BadHosts,>,1; sid:1; rev:1;)");
715 static int DetectIPRepTest08(
void)
726 memset(&th_v, 0,
sizeof(th_v));
738 fd = DetectIPRepGenerateCategoriesDummy();
742 fd = DetectIPRepGenerateNetworksDummy();
747 "badhost\"; iprep:any,BadHosts,>,1; sid:1; rev:1;)");
768 static int DetectIPRepTest09(
void)
779 memset(&th_v, 0,
sizeof(th_v));
791 fd = DetectIPRepGenerateCategoriesDummy2();
795 fd = DetectIPRepGenerateNetworksDummy2();
800 "alert tcp any any -> any any (msg:\"test\"; iprep:src,BadHosts,>,9; sid:1; rev:1;)");
821 static FILE *DetectIPRepGenerateNetworksDummy3(
void)
824 const char *buffer =
"192.168.0.0/16,1,127";
826 fd =
SCFmemopen((
void *)buffer, strlen(buffer),
"r");
833 static int DetectIPRepTest10(
void)
844 memset(&th_v, 0,
sizeof(th_v));
856 fd = DetectIPRepGenerateCategoriesDummy2();
860 fd = DetectIPRepGenerateNetworksDummy3();
865 "alert tcp any any -> any any (msg:\"test\"; iprep:src,BadHosts,isset; sid:1; rev:1;)");
883 static int DetectIPRepTest11(
void)
894 memset(&th_v, 0,
sizeof(th_v));
906 fd = DetectIPRepGenerateCategoriesDummy2();
910 fd = DetectIPRepGenerateNetworksDummy3();
915 "iprep:src,BadHosts,isnotset; sid:1; rev:1;)");
936 void IPRepRegisterTests(
void)
948 UtRegisterTest(
"DetectIPRepTest11 -- isnotset", DetectIPRepTest11);