44 #define DETECT_FLOWVAR_NOT_USED 1
45 #define DETECT_FLOWVAR_TYPE_READ 2
46 #define DETECT_FLOWVAR_TYPE_SET_READ 3
47 #define DETECT_FLOWVAR_TYPE_SET 4
49 #define DETECT_PKTVAR_NOT_USED 1
50 #define DETECT_PKTVAR_TYPE_READ 2
51 #define DETECT_PKTVAR_TYPE_SET_READ 3
52 #define DETECT_PKTVAR_TYPE_SET 4
54 #define DETECT_FLOWBITS_NOT_USED 1
55 #define DETECT_FLOWBITS_TYPE_READ 2
56 #define DETECT_FLOWBITS_TYPE_SET_READ 3
57 #define DETECT_FLOWBITS_TYPE_SET 4
59 #define DETECT_FLOWINT_NOT_USED 1
60 #define DETECT_FLOWINT_TYPE_READ 2
61 #define DETECT_FLOWINT_TYPE_SET_READ 3
62 #define DETECT_FLOWINT_TYPE_SET 4
64 #define DETECT_XBITS_NOT_USED 1
65 #define DETECT_XBITS_TYPE_READ 2
66 #define DETECT_XBITS_TYPE_SET_READ 3
67 #define DETECT_XBITS_TYPE_SET 4
92 while (curr != NULL) {
102 FatalError(
"Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
128 static inline int SCSigGetFlowbitsType(
Signature *sig)
170 if (read > 0 && write == 0) {
172 }
else if (read == 0 && write > 0) {
174 }
else if (read > 0 && write > 0) {
178 SCLogDebug(
"Sig %s typeval %d", sig->
msg, flowbits_user_type);
180 return flowbits_user_type;
183 static inline int SCSigGetFlowintType(
Signature *sig)
231 if (read > 0 && write == 0) {
233 }
else if (read == 0 && write > 0) {
235 }
else if (read > 0 && write > 0) {
239 SCLogDebug(
"Sig %s typeval %d", sig->
msg, flowint_user_type);
241 return flowint_user_type;
258 static inline int SCSigGetFlowvarType(
Signature *sig)
270 for (x = 0; x < pd->
idx; x++) {
291 if (read > 0 && write == 0) {
293 }
else if (read == 0 && write > 0) {
295 }
else if (read > 0 && write > 0) {
316 static inline int SCSigGetPktvarType(
Signature *sig)
328 for (x = 0; x < pd->
idx; x++) {
349 if (read > 0 && write == 0) {
351 }
else if (read == 0 && write > 0) {
353 }
else if (read > 0 && write > 0) {
420 if (read > 0 && write == 0) {
422 }
else if (read == 0 && write > 0) {
424 }
else if (read > 0 && write > 0) {
430 return xbits_user_type;
505 while (funcs != NULL) {
556 subA = SCSigOrder(subA, cmp_func_list);
557 subB = SCSigOrder(subB, cmp_func_list);
562 while (subA != NULL && subB != NULL) {
563 if (SCSigLessThan(subA, subB, cmp_func_list)) {
572 if (result == NULL) {
583 else if (subB == NULL)
715 SCSigProcessUserDataForFlowbits(sw);
716 SCSigProcessUserDataForFlowvar(sw);
717 SCSigProcessUserDataForFlowint(sw);
718 SCSigProcessUserDataForPktvar(sw);
719 SCSigProcessUserDataForHostbits(sw);
720 SCSigProcessUserDataForIPPairbits(sw);
747 while (sig != NULL) {
748 sigw = SCSigAllocSignatureWrapper(sig);
750 sigw->
next = sigw_list;
762 SCLogDebug(
"Total Signatures to be processed by the"
763 "sigordering module: %d", i);
771 while (sigw != NULL) {
789 SCLogDebug(
"total signatures reordered by the sigordering module: %d", i);
805 SCLogDebug(
"registering signature ordering functions");
807 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
808 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
809 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowintCompare);
810 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
811 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
812 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByHostbitsCompare);
813 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByIPPairbitsCompare);
814 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
830 while (funcs != NULL) {
847 static int SCSigOrderingTest01(
void)
855 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
856 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
857 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
858 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
859 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
860 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
861 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
862 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
863 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
864 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
865 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
868 while (temp != NULL) {
880 static int SCSigOrderingTest02(
void)
888 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
892 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:2;)");
896 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:3;)");
900 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; flowvar:http_host,\"www.oisf.net\"; rev:4; priority:1; sid:4;)");
904 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:5;)");
908 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:6;)");
912 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:7;)");
916 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
920 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; rev:4; priority:3; flowbits:set,TEST.one; flowbits:noalert; sid:9;)");
924 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)");
928 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)");
932 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)");
936 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; pktvar:http_host,\"www.oisf.net\"; priority:2; flowbits:isnotset,TEST.two; sid:13;)");
940 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; flowbits:set,TEST.two; sid:14;)");
943 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
944 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
945 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
946 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
947 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
953 while (sig != NULL) {
954 printf(
"sid: %d\n", sig->
id);
999 static int SCSigOrderingTest03(
void)
1007 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1008 "offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:1;)");
1012 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1013 "offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:2;)");
1017 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1018 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; "
1019 "flowbits:unset,TEST.one; rev:4; priority:2; sid:3;)");
1023 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1024 "offset:0; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1025 "flowbits:isset,TEST.one; rev:4; priority:1; sid:4;)");
1029 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1030 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; priority:2; sid:5;)");
1034 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1035 "content:\"220\"; offset:10; flowbits:isnotset,TEST.one; pcre:\"/^User-Agent: "
1036 "(?P<flow_http_host>.*)\\r\\n/m\"; rev:4; sid:6;)");
1040 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1041 "content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; "
1042 "flowbits:unset,TEST.one; rev:4; priority:3; sid:7;)");
1046 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1047 "offset:10; depth:4; pcre:\"/220[- ]/\"; flowbits:toggle,TEST.one; rev:4; priority:1; "
1048 "pktvar:http_host,\"www.oisf.net\"; sid:8;)");
1052 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1053 "content:\"220\"; offset:10; depth:4; rev:4; flowbits:set,TEST.one; "
1054 "flowbits:noalert; pktvar:http_host,\"www.oisf.net\"; sid:9;)");
1058 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1059 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)");
1063 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1064 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)");
1068 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1069 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)");
1073 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1074 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; flowbits:isnotset,TEST.one; sid:13;)");
1078 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1079 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; flowbits:set,TEST.one; sid:14;)");
1082 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1083 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1084 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1085 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1086 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1092 while (sig != NULL) {
1093 printf(
"sid: %d\n", sig->
id);
1136 static int SCSigOrderingTest04(
void)
1145 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1146 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1150 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1151 "pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; content:\"220\"; "
1152 "offset:10; rev:4; priority:3; sid:2;)");
1156 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1157 "content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: "
1158 "(?P<flow_http_host>.*)\\r\\n/m\"; rev:4; priority:3; sid:3;)");
1162 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1163 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; rev:4; "
1164 "priority:3; flowvar:http_host,\"www.oisf.net\"; sid:4;)");
1168 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1169 "offset:11; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1170 "pcre:\"/220[- ]/\"; rev:4; priority:3; sid:5;)");
1174 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1175 "offset:11; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1176 "pktvar:http_host,\"www.oisf.net\"; rev:4; priority:1; sid:6;)");
1180 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1181 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; flowvar:http_host,\"www.oisf.net\"; "
1182 "pktvar:http_host,\"www.oisf.net\"; priority:1; sid:7;)");
1186 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1187 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1188 "flowvar:http_host,\"www.oisf.net\"; sid:8;)");
1192 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1193 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1194 "flowvar:http_host,\"www.oisf.net\"; sid:9;)");
1197 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1198 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1199 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1200 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1201 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1207 while (sig != NULL) {
1208 printf(
"sid: %d\n", sig->
id);
1243 static int SCSigOrderingTest05(
void)
1251 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1252 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1256 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1257 "pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; content:\"220\"; "
1258 "offset:10; rev:4; priority:3; sid:2;)");
1262 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1263 "content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: "
1264 "(?P<pkt_http_host>.*)\\r\\n/m\"; rev:4; priority:3; sid:3;)");
1268 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1269 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; rev:4; "
1270 "priority:3; pktvar:http_host,\"www.oisf.net\"; sid:4;)");
1274 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1275 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:5;)");
1279 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1280 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:6;)");
1284 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1285 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1286 "pktvar:http_host,\"www.oisf.net\"; sid:7;)");
1290 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1291 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; "
1292 "pktvar:http_host,\"www.oisf.net\"; sid:8;)");
1295 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1296 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1297 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1298 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1299 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1305 while (sig != NULL) {
1306 printf(
"sid: %d\n", sig->
id);
1337 static int SCSigOrderingTest06(
void)
1346 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1347 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1351 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1352 "content:\"220\"; offset:10; rev:4; priority:2; sid:2;)");
1356 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1357 "content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:3;)");
1361 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1362 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1366 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1367 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1371 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1372 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1375 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1376 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1380 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1381 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1384 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1385 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1386 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1387 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1388 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1394 while (sig != NULL) {
1395 printf(
"sid: %d\n", sig->
id);
1423 static int SCSigOrderingTest07(
void)
1432 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1433 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1; rev:4;)");
1437 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1438 "content:\"220\"; offset:10; sid:2; rev:4; priority:2;)");
1442 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1443 "content:\"220\"; offset:10; depth:4; sid:3; rev:4; priority:3;)");
1447 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1448 "content:\"220\"; offset:10; depth:4; sid:4; rev:4; priority:2;)");
1452 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1453 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:5; rev:4; priority:2;)");
1457 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1458 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:6; rev:4; priority:1;)");
1462 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1463 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:7; rev:4; priority:2;)");
1467 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1468 "offset:12; depth:4; pcre:\"/220[- ]/\"; sid:8; rev:4; priority:2;)");
1471 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1472 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1473 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1474 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1475 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1481 while (sig != NULL) {
1482 printf(
"sid: %d\n", sig->
id);
1515 static int SCSigOrderingTest08(
void)
1517 #ifdef HAVE_LIBNET11
1532 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1533 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1; rev:4;)");
1537 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1538 "content:\"220\"; offset:10; sid:2; rev:4; priority:2;)");
1542 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1543 "content:\"220\"; offset:10; depth:4; sid:3; rev:4; priority:3;)");
1547 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1548 "content:\"220\"; offset:10; depth:4; sid:4; rev:4; priority:2;)");
1552 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1553 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:5; rev:4; priority:2;)");
1557 "reject tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1558 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:6; rev:4; priority:1;)");
1562 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; "
1563 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; sid:7; rev:4;)");
1567 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1568 "offset:12; depth:4; pcre:\"/220[- ]/\"; sid:8; rev:4; priority:2;)");
1571 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1572 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1573 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1574 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1575 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1581 while (sig != NULL) {
1582 printf(
"sid: %d\n", sig->
id);
1622 static int SCSigOrderingTest09(
void)
1638 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1639 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1;)");
1643 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1644 "content:\"220\"; offset:10; priority:2; sid:2;)");
1648 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1649 "content:\"220\"; offset:10; depth:4; priority:3; sid:3;)");
1653 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1654 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1658 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1659 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1663 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1664 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1668 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1669 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1673 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1674 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1677 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1678 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1679 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1680 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1681 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1687 while (sig != NULL) {
1688 printf(
"sid: %d\n", sig->
id);
1726 static int SCSigOrderingTest10(
void)
1742 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1743 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1747 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1748 "content:\"220\"; offset:10; rev:4; priority:2; sid:2;)");
1752 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1753 "content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:3;)");
1757 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1758 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1762 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1763 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1767 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1768 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1772 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1773 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1777 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1778 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1781 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1782 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1783 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1784 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1785 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1791 while (sig != NULL) {
1792 printf(
"sid: %d\n", sig->
id);
1826 static int SCSigOrderingTest11(
void)
1835 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering set\"; "
1836 "flowbits:isnotset,myflow1; rev:4; sid:1;)");
1840 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering toggle\"; "
1841 "flowbits:toggle,myflow2; rev:4; sid:2;)");
1845 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering unset\"; "
1846 "flowbits:isset, myflow1; flowbits:unset,myflow2; rev:4; priority:3; sid:3;)");
1849 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1850 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1851 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1852 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1853 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1859 while (sig != NULL) {
1860 printf(
"sid: %d\n", sig->
id);
1878 static int SCSigOrderingTest12(
void)
1882 uint8_t buf[] =
"test message";
1888 f.
proto = IPPROTO_TCP;
1894 const char *sigs[2];
1895 sigs[0] =
"alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:isset,one; flowbits:set,two; sid:1;)";
1896 sigs[1] =
"alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:set,one; sid:2;)";
1916 uint32_t sids[2] = {1, 2};
1917 uint32_t results[2] = {1, 1};
1930 static int SCSigOrderingTest13(
void)
1938 sig =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flowbits:isset,bit1; flowbits:set,bit2; flowbits:set,bit3; sid:6;)");
1942 sig =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flowbits:isset,bit1; flowbits:isset,bit2; flowbits:isset,bit3; sid:5;)");
1945 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1950 while (sig != NULL) {
1951 printf(
"sid: %d\n", sig->
id);