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
130 while (curr != NULL) {
140 FatalError(
"Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
166 static inline int SCSigGetFlowbitsType(
Signature *sig)
208 if (read > 0 && write == 0) {
210 }
else if (read == 0 && write > 0) {
212 }
else if (read > 0 && write > 0) {
216 SCLogDebug(
"Sig %s typeval %d", sig->
msg, flowbits_user_type);
218 return flowbits_user_type;
221 static inline int SCSigGetFlowintType(
Signature *sig)
266 if (read > 0 && write == 0) {
268 }
else if (read == 0 && write > 0) {
270 }
else if (read > 0 && write > 0) {
274 SCLogDebug(
"Sig %s typeval %d", sig->
msg, flowint_user_type);
276 return flowint_user_type;
293 static inline int SCSigGetFlowvarType(
Signature *sig)
305 for (x = 0; x < pd->
idx; x++) {
326 if (read > 0 && write == 0) {
328 }
else if (read == 0 && write > 0) {
330 }
else if (read > 0 && write > 0) {
351 static inline int SCSigGetPktvarType(
Signature *sig)
363 for (x = 0; x < pd->
idx; x++) {
384 if (read > 0 && write == 0) {
386 }
else if (read == 0 && write > 0) {
388 }
else if (read > 0 && write > 0) {
455 if (read > 0 && write == 0) {
457 }
else if (read == 0 && write > 0) {
459 }
else if (read > 0 && write > 0) {
465 return xbits_user_type;
540 while (funcs != NULL) {
591 subA = SCSigOrder(subA, cmp_func_list);
592 subB = SCSigOrder(subB, cmp_func_list);
597 while (subA != NULL && subB != NULL) {
598 if (SCSigLessThan(subA, subB, cmp_func_list)) {
607 if (result == NULL) {
618 else if (subB == NULL)
744 SCSigProcessUserDataForFlowbits(sw);
745 SCSigProcessUserDataForFlowvar(sw);
746 SCSigProcessUserDataForFlowint(sw);
747 SCSigProcessUserDataForPktvar(sw);
748 SCSigProcessUserDataForHostbits(sw);
749 SCSigProcessUserDataForIPPairbits(sw);
776 while (sig != NULL) {
777 sigw = SCSigAllocSignatureWrapper(sig);
779 sigw->
next = sigw_list;
791 SCLogDebug(
"Total Signatures to be processed by the"
792 "sigordering module: %d", i);
800 while (sigw != NULL) {
818 SCLogDebug(
"total signatures reordered by the sigordering module: %d", i);
834 SCLogDebug(
"registering signature ordering functions");
836 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
837 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
838 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowintCompare);
839 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
840 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
841 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByHostbitsCompare);
842 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByIPPairbitsCompare);
843 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
859 while (funcs != NULL) {
876 static int SCSigOrderingTest01(
void)
884 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
885 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
886 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
887 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
888 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
889 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
890 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
891 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
892 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
893 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
894 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
897 while (temp != NULL) {
909 static int SCSigOrderingTest02(
void)
917 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
921 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:2;)");
925 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:3;)");
929 "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;)");
933 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:5;)");
937 "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;)");
941 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:7;)");
945 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
949 "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;)");
953 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)");
957 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)");
961 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)");
965 "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;)");
969 "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;)");
972 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
973 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
974 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
975 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
976 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
982 while (sig != NULL) {
983 printf(
"sid: %d\n", sig->
id);
1028 static int SCSigOrderingTest03(
void)
1036 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1037 "offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:1;)");
1041 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1042 "offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:2;)");
1046 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1047 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; "
1048 "flowbits:unset,TEST.one; rev:4; priority:2; sid:3;)");
1052 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1053 "offset:0; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1054 "flowbits:isset,TEST.one; rev:4; priority:1; sid:4;)");
1058 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1059 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; priority:2; sid:5;)");
1063 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1064 "content:\"220\"; offset:10; flowbits:isnotset,TEST.one; pcre:\"/^User-Agent: "
1065 "(?P<flow_http_host>.*)\\r\\n/m\"; rev:4; sid:6;)");
1069 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1070 "content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; "
1071 "flowbits:unset,TEST.one; rev:4; priority:3; sid:7;)");
1075 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1076 "offset:10; depth:4; pcre:\"/220[- ]/\"; flowbits:toggle,TEST.one; rev:4; priority:1; "
1077 "pktvar:http_host,\"www.oisf.net\"; sid:8;)");
1081 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1082 "content:\"220\"; offset:10; depth:4; rev:4; flowbits:set,TEST.one; "
1083 "flowbits:noalert; pktvar:http_host,\"www.oisf.net\"; sid:9;)");
1087 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1088 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)");
1092 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1093 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)");
1097 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1098 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)");
1102 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1103 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; flowbits:isnotset,TEST.one; sid:13;)");
1107 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1108 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; flowbits:set,TEST.one; sid:14;)");
1111 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1112 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1113 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1114 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1115 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1121 while (sig != NULL) {
1122 printf(
"sid: %d\n", sig->
id);
1165 static int SCSigOrderingTest04(
void)
1174 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1175 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1179 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1180 "pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; content:\"220\"; "
1181 "offset:10; rev:4; priority:3; sid:2;)");
1185 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1186 "content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: "
1187 "(?P<flow_http_host>.*)\\r\\n/m\"; rev:4; priority:3; sid:3;)");
1191 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1192 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<flow_http_host>.*)\\r\\n/m\"; rev:4; "
1193 "priority:3; flowvar:http_host,\"www.oisf.net\"; sid:4;)");
1197 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1198 "offset:11; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1199 "pcre:\"/220[- ]/\"; rev:4; priority:3; sid:5;)");
1203 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1204 "offset:11; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; "
1205 "pktvar:http_host,\"www.oisf.net\"; rev:4; priority:1; sid:6;)");
1209 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1210 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; flowvar:http_host,\"www.oisf.net\"; "
1211 "pktvar:http_host,\"www.oisf.net\"; priority:1; sid:7;)");
1215 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1216 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1217 "flowvar:http_host,\"www.oisf.net\"; sid:8;)");
1221 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1222 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1223 "flowvar:http_host,\"www.oisf.net\"; sid:9;)");
1226 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1227 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1228 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1229 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1230 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1236 while (sig != NULL) {
1237 printf(
"sid: %d\n", sig->
id);
1272 static int SCSigOrderingTest05(
void)
1280 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1281 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1285 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1286 "pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; content:\"220\"; "
1287 "offset:10; rev:4; priority:3; sid:2;)");
1291 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1292 "content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: "
1293 "(?P<pkt_http_host>.*)\\r\\n/m\"; rev:4; priority:3; sid:3;)");
1297 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1298 "offset:10; depth:4; pcre:\"/^User-Agent: (?P<pkt_http_host>.*)\\r\\n/m\"; rev:4; "
1299 "priority:3; pktvar:http_host,\"www.oisf.net\"; sid:4;)");
1303 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1304 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:5;)");
1308 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1309 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:6;)");
1313 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1314 "content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; "
1315 "pktvar:http_host,\"www.oisf.net\"; sid:7;)");
1319 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1320 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; "
1321 "pktvar:http_host,\"www.oisf.net\"; sid:8;)");
1324 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1325 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1326 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1327 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1328 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1334 while (sig != NULL) {
1335 printf(
"sid: %d\n", sig->
id);
1366 static int SCSigOrderingTest06(
void)
1375 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1376 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1380 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1381 "content:\"220\"; offset:10; rev:4; priority:2; sid:2;)");
1385 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1386 "content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:3;)");
1390 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; "
1391 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1395 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1396 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1400 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1401 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1404 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1405 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1409 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; "
1410 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1413 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1414 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1415 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1416 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1417 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1423 while (sig != NULL) {
1424 printf(
"sid: %d\n", sig->
id);
1452 static int SCSigOrderingTest07(
void)
1461 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1462 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1; rev:4;)");
1466 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1467 "content:\"220\"; offset:10; sid:2; rev:4; priority:2;)");
1471 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1472 "content:\"220\"; offset:10; depth:4; sid:3; rev:4; priority:3;)");
1476 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1477 "content:\"220\"; offset:10; depth:4; sid:4; rev:4; priority:2;)");
1481 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1482 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:5; rev:4; priority:2;)");
1486 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1487 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:6; rev:4; priority:1;)");
1491 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1492 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:7; rev:4; priority:2;)");
1496 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1497 "offset:12; depth:4; pcre:\"/220[- ]/\"; sid:8; rev:4; priority:2;)");
1500 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1501 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1502 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1503 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1504 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1510 while (sig != NULL) {
1511 printf(
"sid: %d\n", sig->
id);
1544 static int SCSigOrderingTest08(
void)
1546 #ifdef HAVE_LIBNET11
1561 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1562 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1; rev:4;)");
1566 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1567 "content:\"220\"; offset:10; sid:2; rev:4; priority:2;)");
1571 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1572 "content:\"220\"; offset:10; depth:4; sid:3; rev:4; priority:3;)");
1576 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1577 "content:\"220\"; offset:10; depth:4; sid:4; rev:4; priority:2;)");
1581 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1582 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:5; rev:4; priority:2;)");
1586 "reject tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1587 "offset:11; depth:4; pcre:\"/220[- ]/\"; sid:6; rev:4; priority:1;)");
1591 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; "
1592 "content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; sid:7; rev:4;)");
1596 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1597 "offset:12; depth:4; pcre:\"/220[- ]/\"; sid:8; rev:4; priority:2;)");
1600 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1601 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1602 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1603 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1604 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1610 while (sig != NULL) {
1611 printf(
"sid: %d\n", sig->
id);
1651 static int SCSigOrderingTest09(
void)
1667 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1668 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; sid:1;)");
1672 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1673 "content:\"220\"; offset:10; priority:2; sid:2;)");
1677 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1678 "content:\"220\"; offset:10; depth:4; priority:3; sid:3;)");
1682 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1683 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1687 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1688 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1692 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1693 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1697 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1698 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1702 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1703 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1706 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1707 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1708 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1709 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1710 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1716 while (sig != NULL) {
1717 printf(
"sid: %d\n", sig->
id);
1755 static int SCSigOrderingTest10(
void)
1771 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1772 "content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)");
1776 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1777 "content:\"220\"; offset:10; rev:4; priority:2; sid:2;)");
1781 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; "
1782 "content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:3;)");
1786 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; "
1787 "content:\"220\"; offset:10; depth:4; rev:4; priority:2; sid:4;)");
1791 "pass tcp any !21:902 -> any any (msg:\"Testing sigordering pass\"; content:\"220\"; "
1792 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:5;)");
1796 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering drop\"; content:\"220\"; "
1797 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:6;)");
1801 "drop tcp any !21:902 -> any any (msg:\"Testing sigordering reject\"; content:\"220\"; "
1802 "offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:7;)");
1806 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering alert\"; content:\"220\"; "
1807 "offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)");
1810 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1811 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1812 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1813 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1814 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1820 while (sig != NULL) {
1821 printf(
"sid: %d\n", sig->
id);
1855 static int SCSigOrderingTest11(
void)
1864 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering set\"; "
1865 "flowbits:isnotset,myflow1; rev:4; sid:1;)");
1869 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering toggle\"; "
1870 "flowbits:toggle,myflow2; rev:4; sid:2;)");
1874 "alert tcp any !21:902 -> any any (msg:\"Testing sigordering unset\"; "
1875 "flowbits:isset, myflow1; flowbits:unset,myflow2; rev:4; priority:3; sid:3;)");
1878 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByActionCompare);
1879 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1880 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowvarCompare);
1881 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPktvarCompare);
1882 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByPriorityCompare);
1888 while (sig != NULL) {
1889 printf(
"sid: %d\n", sig->
id);
1907 static int SCSigOrderingTest12(
void)
1911 uint8_t buf[] =
"test message";
1917 f.
proto = IPPROTO_TCP;
1923 const char *sigs[2];
1924 sigs[0] =
"alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:isset,one; flowbits:set,two; sid:1;)";
1925 sigs[1] =
"alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:set,one; sid:2;)";
1945 uint32_t sids[2] = {1, 2};
1946 uint32_t results[2] = {1, 1};
1959 static int SCSigOrderingTest13(
void)
1967 sig =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flowbits:isset,bit1; flowbits:set,bit2; flowbits:set,bit3; sid:6;)");
1971 sig =
DetectEngineAppendSig(
de_ctx,
"alert tcp any any -> any any (flowbits:isset,bit1; flowbits:isset,bit2; flowbits:isset,bit3; sid:5;)");
1974 SCSigRegisterSignatureOrderingFunc(
de_ctx, SCSigOrderByFlowbitsCompare);
1979 while (sig != NULL) {
1980 printf(
"sid: %d\n", sig->
id);