Go to the documentation of this file.
64 static int rule_warnings_only = 0;
120 { 0,
false,
false,
true,
"http_uri",
"http uri" },
121 { 0,
false,
false,
false,
"http_raw_uri",
"http raw uri" },
122 { 0,
false,
true,
false,
"http_method",
"http method" },
123 { 0,
false,
false,
false,
"http_request_line",
"http request line" },
124 { 0,
false,
false,
false,
"http_client_body",
"http client body" },
125 { 0,
false,
false,
true,
"http_header",
"http header" },
126 { 0,
false,
false,
false,
"http_raw_header",
"http raw header" },
127 { 0,
false,
false,
true,
"http_cookie",
"http cookie" },
128 { 0,
false,
false,
false,
"http_user_agent",
"http user agent" },
129 { 0,
false,
false,
false,
"http_host",
"http host" },
130 { 0,
false,
false,
false,
"http_raw_host",
"http raw host" },
131 { 0,
false,
false,
false,
"http_accept_enc",
"http accept enc" },
132 { 0,
false,
false,
false,
"http_referer",
"http referer" },
133 { 0,
false,
false,
false,
"http_content_type",
"http content type" },
134 { 0,
false,
false,
false,
"http_header_names",
"http header names" },
137 { 0,
false,
false,
false,
"http_stat_msg",
"http stat msg" },
138 { 0,
false,
false,
false,
"http_stat_code",
"http stat code" },
139 { 0,
false,
true,
false,
"file_data",
"http server body" },
142 { 0,
false,
false,
false,
"http_request_line",
"http request line" },
143 { 0,
false,
false,
false,
"http_accept",
"http accept" },
144 { 0,
false,
false,
false,
"http_accept_lang",
"http accept lang" },
145 { 0,
false,
false,
false,
"http_connection",
"http connection" },
146 { 0,
false,
false,
false,
"http_content_len",
"http content len" },
147 { 0,
false,
false,
false,
"http_protocol",
"http protocol" },
148 { 0,
false,
false,
false,
"http_start",
"http start" },
151 { 0,
false,
false,
false,
"http_response_line",
"http response line" },
152 { 0,
false,
false,
false,
"http.server",
"http server" },
153 { 0,
false,
false,
false,
"http.location",
"http location" },
156 static void FpPatternStatsAdd(
FpPatternStats *fp,
int list, uint16_t patlen)
165 else if (patlen < f->min)
177 int fast_pattern_set = 0;
178 int fast_pattern_only_set = 0;
179 int fast_pattern_chop_set = 0;
184 if (mpm_sm != NULL) {
187 fast_pattern_set = 1;
189 fast_pattern_only_set = 1;
191 fast_pattern_chop_set = 1;
197 fprintf(fp,
"== Sid: %u ==\n", s->
id);
198 fprintf(fp,
"%s\n", line);
200 fprintf(fp,
" Fast Pattern analysis:\n");
202 fprintf(fp,
" Prefilter on: %s\n",
209 fprintf(fp,
" No content present\n");
214 fprintf(fp,
" Fast pattern matcher: ");
215 int list_type = mpm_sm_list;
217 fprintf(fp,
"content\n");
222 fprintf(fp,
"%s (%s)\n", desc,
name);
227 fprintf(fp,
" Flags:");
229 fprintf(fp,
" Offset");
232 fprintf(fp,
" Depth");
236 fprintf(fp,
" Within");
240 fprintf(fp,
" Distance");
244 fprintf(fp,
" Nocase");
248 fprintf(fp,
" Negated");
252 fprintf(fp,
" None");
255 fprintf(fp,
" Fast pattern set: %s\n", fast_pattern_set ?
"yes" :
"no");
256 fprintf(fp,
" Fast pattern only set: %s\n", fast_pattern_only_set ?
"yes" :
"no");
257 fprintf(fp,
" Fast pattern chop set: %s\n", fast_pattern_chop_set ?
"yes" :
"no");
258 if (fast_pattern_chop_set) {
259 fprintf(fp,
" Fast pattern offset, length: %u, %u\n", fp_cd->
fp_chop_offset,
270 fprintf(fp,
" Original content: ");
274 if (fast_pattern_chop_set) {
283 fprintf(fp,
" Final content: ");
289 fprintf(fp,
" Final content: ");
318 char *log_path =
SCMalloc(PATH_MAX);
319 if (log_path == NULL) {
320 FatalError(
"Unable to allocate scratch memory for rule filename");
322 snprintf(log_path, PATH_MAX,
"%s/%s%s", log_dir,
325 FILE *fp = fopen(log_path,
"w");
327 SCLogError(
"failed to open %s: %s", log_path, strerror(errno));
334 SCLogInfo(
"Engine-Analysis for fast_pattern printed to file - %s",
339 gettimeofday(&tval, NULL);
341 struct tm *tms =
SCLocalTime(tval.tv_sec, &local_tm);
342 fprintf(fp,
"----------------------------------------------"
343 "---------------------\n");
345 "Date: %" PRId32
"/%" PRId32
"/%04d -- "
347 tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour, tms->tm_min,
349 fprintf(fp,
"----------------------------------------------"
350 "---------------------\n");
363 #define DETECT_PERCENT_ENCODING_REGEX "%[0-9|a-f|A-F]{2}"
369 PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
371 PCRE2_UCHAR errbuffer[256];
372 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
393 }
else if (value && strcasecmp(value,
"warnings-only") == 0) {
395 rule_warnings_only = 1;
400 char log_path[PATH_MAX];
401 snprintf(log_path,
sizeof(log_path),
"%s/%s%s", log_dir,
405 SCLogError(
"failed to open %s: %s", log_path, strerror(errno));
409 SCLogInfo(
"Engine-Analysis for rules printed to file - %s",
413 gettimeofday(&tval, NULL);
415 struct tm *tms =
SCLocalTime(tval.tv_sec, &local_tm);
417 "----------------------------------------------"
418 "---------------------\n");
420 "Date: %" PRId32
"/%" PRId32
"/%04d -- "
422 tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour, tms->tm_min,
425 "----------------------------------------------"
426 "---------------------\n");
429 if (!PerCentEncodingSetup(
de_ctx->
ea)) {
431 "Error compiling regex; can't check for percent encoding in normalized "
437 SCLogInfo(
"Conf parameter \"engine-analysis.rules\" not found. "
438 "Defaulting to not printing the rules analysis report.");
441 SCLogInfo(
"Engine-Analysis for rules disabled in conf file.");
453 fprintf(fp,
"============\n"
454 "Summary:\n============\n");
462 "%s, smallest pattern %u byte(s), longest pattern %u byte(s), number of patterns "
463 "%u, avg pattern len %.2f byte(s)\n",
465 (
float)((
double)f->
tot / (
float)f->
cnt));
485 *fp_analysis =
false;
486 *rule_analysis =
false;
490 FatalError(
"Unable to allocate per-engine analysis context");
495 if (cfg_prefix_len > 0) {
500 FatalError(
"Unable to allocate per-engine analysis context name buffer");
506 *fp_analysis = SetupFPAnalyzer(
de_ctx);
507 *rule_analysis = SetupRuleAnalyzer(
de_ctx);
509 if (!(*fp_analysis || *rule_analysis)) {
522 CleanupRuleAnalyzer(
de_ctx);
523 CleanupFPAnalyzer(
de_ctx);
540 static int PerCentEncodingMatch(
EngineAnalysisCtx *ea_ctx, uint8_t *content, uint16_t content_len)
544 pcre2_match_data *match = pcre2_match_data_create_from_pattern(ea_ctx->
percent_re, NULL);
545 ret = pcre2_match(ea_ctx->
percent_re, (PCRE2_SPTR8)content, content_len, 0, 0, match, NULL);
548 }
else if (ret < -1) {
549 SCLogError(
"Error parsing content - %s; error code is %d", content, ret);
552 pcre2_match_data_free(match);
562 if (mpm_sm != NULL) {
600 const int list_type = mpm_sm_list;
609 payload ? (stream ?
"payload and reassembled stream" :
"payload")
610 :
"reassembled stream");
617 }
else if (desc ||
name) {
637 fprintf(tmp_fp,
"== Sid: UNKNOWN ==\n");
638 fprintf(tmp_fp,
"%s\n", line);
639 fprintf(tmp_fp,
" FAILURE: invalid rule.\n");
640 fprintf(tmp_fp,
" File: %s.\n", file);
641 fprintf(tmp_fp,
" Line: %d.\n", lineno);
642 fprintf(tmp_fp,
"\n");
659 vsnprintf(
str,
sizeof(
str), fmt, ap);
663 ctx->js_notes = SCJbNewArray();
665 SCJbAppendString(
ctx->js_notes,
str);
674 vsnprintf(
str,
sizeof(
str), fmt, ap);
677 if (!
ctx->js_warnings)
678 ctx->js_warnings = SCJbNewArray();
679 if (
ctx->js_warnings)
680 SCJbAppendString(
ctx->js_warnings,
str);
683 #define CHECK(pat) if (strlen((pat)) <= len && memcmp((pat), buf, MIN(len, strlen((pat)))) == 0) return true;
685 static bool LooksLikeHTTPMethod(
const uint8_t *buf, uint16_t
len)
694 static bool LooksLikeHTTPUA(
const uint8_t *buf, uint16_t
len)
696 CHECK(
"User-Agent: ");
697 CHECK(
"\nUser-Agent: ");
703 char pattern_str[1024] =
"";
706 SCJbSetString(js,
"pattern", pattern_str);
715 SCJbSetUint(js,
"offset", cd->
offset);
718 SCJbSetUint(js,
"depth", cd->
depth);
721 SCJbSetInt(js,
"distance", cd->
distance);
724 SCJbSetInt(js,
"within", cd->
within);
743 SCJbOpenArray(js,
"matches");
747 SCJbSetString(js,
"name", mname);
753 SCJbOpenObject(js,
"content");
756 AnalyzerNote(
ctx, (
char *)
"'fast_pattern:only' option is silently ignored and "
757 "is interpreted as regular 'fast_pattern'");
761 (
char *)
"pattern looks like it inspects HTTP, use http.request_line or "
762 "http.method and http.uri instead for improved performance");
766 (
char *)
"pattern looks like it inspects HTTP, use http.user_agent "
767 "or http.header for improved performance");
770 AnalyzerNote(
ctx, (
char *)
"'within' option for pattern w/o previous content "
771 "was converted to 'depth'");
774 AnalyzerNote(
ctx, (
char *)
"'distance' option for pattern w/o previous content "
775 "was converted to 'offset'");
783 SCJbOpenObject(js,
"pcre");
788 (
char *)
"'/B' (rawbytes) option is a no-op and is silently ignored");
791 AnalyzerNote(
ctx, (
char *)
"pcre with \\X (Unicode extended grapheme cluster) "
799 SCJbOpenObject(js,
"byte_jump");
800 SCJbSetUint(js,
"nbytes", cd->
nbytes);
801 SCJbSetInt(js,
"offset", cd->
offset);
802 SCJbSetUint(js,
"multiplier", cd->
multiplier);
806 SCJbSetString(js,
"base",
"unset");
809 SCJbSetString(js,
"base",
"oct");
812 SCJbSetString(js,
"base",
"dec");
815 SCJbSetString(js,
"base",
"hex");
818 SCJbOpenArray(js,
"flags");
820 SCJbAppendString(js,
"from_beginning");
822 SCJbAppendString(js,
"little_endian");
824 SCJbAppendString(js,
"big_endian");
826 SCJbAppendString(js,
"string");
828 SCJbAppendString(js,
"relative");
830 SCJbAppendString(js,
"align");
832 SCJbAppendString(js,
"dce");
834 SCJbAppendString(js,
"offset_be");
836 SCJbAppendString(js,
"from_end");
844 SCJbOpenObject(js,
"byte_test");
845 SCJbSetUint(js,
"nbytes", cd->
nbytes);
846 SCJbSetInt(js,
"offset", cd->
offset);
849 SCJbSetString(js,
"base",
"unset");
852 SCJbSetString(js,
"base",
"oct");
855 SCJbSetString(js,
"base",
"dec");
858 SCJbSetString(js,
"base",
"hex");
861 SCJbOpenArray(js,
"flags");
863 SCJbAppendString(js,
"little_endian");
865 SCJbAppendString(js,
"big_endian");
867 SCJbAppendString(js,
"string");
869 SCJbAppendString(js,
"relative");
871 SCJbAppendString(js,
"dce");
878 SCJbOpenObject(js,
"absent");
879 SCJbSetBool(js,
"or_else", dad->
or_else);
887 SCJbOpenObject(js,
"ipopts");
889 SCJbSetString(js,
"option", flag);
896 SCJbOpenObject(js,
"flowbits");
899 SCJbSetString(js,
"cmd",
"isset");
902 SCJbSetString(js,
"cmd",
"isnotset");
905 SCJbSetString(js,
"cmd",
"set");
908 SCJbSetString(js,
"cmd",
"unset");
912 SCJbOpenArray(js,
"names");
918 const char *varname =
920 SCJbAppendString(js, varname);
925 SCJbSetString(js,
"operator",
"or");
933 SCJbOpenObject(js,
"xbits");
936 SCJbSetString(js,
"cmd",
"isset");
939 SCJbSetString(js,
"cmd",
"isnotset");
942 SCJbSetString(js,
"cmd",
"set");
945 SCJbSetString(js,
"cmd",
"unset");
948 SCJbSetString(js,
"cmd",
"toggle");
954 SCJbSetString(js,
"track",
"ip_src");
957 SCJbSetString(js,
"track",
"ip_dst");
960 SCJbSetString(js,
"track",
"ip_pair");
963 SCJbSetString(js,
"track",
"tx");
967 SCJbSetUint(js,
"expire", xd->
expire);
974 SCJbOpenObject(js,
"flowint");
977 SCJbSetString(js,
"cmd",
"set");
980 SCJbSetString(js,
"cmd",
"add");
983 SCJbSetString(js,
"cmd",
"sub");
986 SCJbSetString(js,
"cmd",
"lt");
989 SCJbSetString(js,
"cmd",
"lte");
992 SCJbSetString(js,
"cmd",
"eq");
995 SCJbSetString(js,
"cmd",
"ne");
998 SCJbSetString(js,
"cmd",
"gte");
1001 SCJbSetString(js,
"cmd",
"gt");
1004 SCJbSetString(js,
"cmd",
"isset");
1007 SCJbSetString(js,
"cmd",
"isnotset");
1011 if (varname != NULL) {
1012 SCJbSetString(js,
"var", varname);
1026 SCJbOpenObject(js,
"ack");
1027 SCDetectU32ToJson(js, cd);
1033 SCJbOpenObject(js,
"seq");
1034 SCDetectU32ToJson(js, cd);
1040 SCJbOpenObject(js,
"tcp_mss");
1041 SCDetectU16ToJson(js, cd);
1047 SCJbOpenObject(js,
"dsize");
1048 SCDetectU16ToJson(js, cd);
1054 SCJbOpenObject(js,
"code");
1055 SCDetectU8ToJson(js, cd);
1061 SCJbOpenObject(js,
"ttl");
1062 SCDetectU8ToJson(js, cd);
1068 SCJbOpenObject(js,
"id");
1069 SCDetectU16ToJson(js, cd);
1075 SCJbOpenObject(js,
"window");
1076 SCDetectU16ToJson(js, cd);
1082 SCJbOpenObject(js,
"flow_age");
1083 SCDetectU32ToJson(js, cd);
1088 const uint8_t *dfd = (
const uint8_t *)smd->
ctx;
1089 SCJbOpenObject(js,
"flow_elephant");
1091 case DETECT_FLOW_TOSERVER:
1092 SCJbSetString(js,
"dir",
"toserver");
1094 case DETECT_FLOW_TOCLIENT:
1095 SCJbSetString(js,
"dir",
"toclient");
1097 case DETECT_FLOW_TOEITHER:
1098 SCJbSetString(js,
"dir",
"either");
1100 case DETECT_FLOW_TOBOTH:
1101 SCJbSetString(js,
"dir",
"both");
1109 SCJbOpenObject(js,
"app_layer_protocol");
1112 SCJbOpenArray(js,
"protocols");
1113 for (uint16_t i = 0; i < n; i++) {
1118 SCJbSetBool(js,
"negated", ad->
negated);
1124 SCJbOpenObject(js,
"tcp_session");
1125 SCJbOpenArray(js,
"phases");
1127 SCJbAppendString(js,
"setup");
1129 SCJbAppendString(js,
"established");
1131 SCJbAppendString(js,
"closing");
1153 ctx.js = SCJbNewObject();
1164 SCJbSetUint(
ctx.js,
"id", s->
id);
1165 SCJbSetUint(
ctx.js,
"gid", s->
gid);
1166 SCJbSetUint(
ctx.js,
"rev", s->
rev);
1167 SCJbSetString(
ctx.js,
"msg", s->
msg);
1170 SCJbSetString(
ctx.js,
"app_proto", alproto);
1172 SCJbOpenArray(
ctx.js,
"requirements");
1174 SCJbAppendString(
ctx.js,
"payload");
1177 SCJbAppendString(
ctx.js,
"no_payload");
1180 SCJbAppendString(
ctx.js,
"flow");
1183 SCJbAppendString(
ctx.js,
"tcp_flags_init_deinit");
1186 SCJbAppendString(
ctx.js,
"tcp_flags_unusual");
1189 SCJbAppendString(
ctx.js,
"engine_event");
1192 SCJbAppendString(
ctx.js,
"real_pkt");
1196 SCJbOpenObject(
ctx.js,
"match_policy");
1197 SCJbOpenArray(
ctx.js,
"actions");
1199 SCJbAppendString(
ctx.js,
"alert");
1202 SCJbAppendString(
ctx.js,
"drop");
1205 SCJbAppendString(
ctx.js,
"reject");
1208 SCJbAppendString(
ctx.js,
"reject_dst");
1211 SCJbAppendString(
ctx.js,
"reject_both");
1214 SCJbAppendString(
ctx.js,
"config");
1217 SCJbAppendString(
ctx.js,
"pass");
1220 SCJbAppendString(
ctx.js,
"accept");
1226 switch (flow_action) {
1228 SCJbSetString(
ctx.js,
"scope",
"packet");
1231 SCJbSetString(
ctx.js,
"scope",
"flow");
1234 SCJbSetString(
ctx.js,
"scope",
"flow_if_stateful");
1241 SCJbSetString(
ctx.js,
"scope",
"packet");
1244 SCJbSetString(
ctx.js,
"scope",
"flow");
1247 SCJbSetString(
ctx.js,
"scope",
"hook");
1250 SCJbSetString(
ctx.js,
"scope",
"tx");
1260 SCJbSetString(
ctx.js,
"type",
"unset");
1263 SCJbSetString(
ctx.js,
"type",
"ip_only");
1266 SCJbSetString(
ctx.js,
"type",
"like_ip_only");
1269 SCJbSetString(
ctx.js,
"type",
"pd_only");
1272 SCJbSetString(
ctx.js,
"type",
"de_only");
1275 SCJbSetString(
ctx.js,
"type",
"pkt");
1278 SCJbSetString(
ctx.js,
"type",
"pkt_stream");
1281 SCJbSetString(
ctx.js,
"type",
"stream");
1284 SCJbSetString(
ctx.js,
"type",
"app_layer");
1287 SCJbSetString(
ctx.js,
"type",
"app_tx");
1290 SCJbSetString(
ctx.js,
"type",
"error");
1296 SCJbOpenObject(
ctx.js,
"dependencies");
1297 SCJbOpenObject(
ctx.js,
"flowbits");
1298 SCJbOpenObject(
ctx.js,
"upstream");
1300 SCJbOpenObject(
ctx.js,
"state_modifying_rules");
1301 SCJbOpenArray(
ctx.js,
"sids");
1306 SCJbOpenArray(
ctx.js,
"names");
1309 SCJbAppendString(
ctx.js,
1322 SCJbOpenArray(
ctx.js,
"flags");
1324 SCJbAppendString(
ctx.js,
"src_any");
1327 SCJbAppendString(
ctx.js,
"dst_any");
1330 SCJbAppendString(
ctx.js,
"sp_any");
1333 SCJbAppendString(
ctx.js,
"dp_any");
1336 SCJbAppendString(
ctx.js,
"noalert");
1339 SCJbAppendString(
ctx.js,
"dsize");
1342 SCJbAppendString(
ctx.js,
"applayer");
1345 SCJbAppendString(
ctx.js,
"need_packet");
1348 SCJbAppendString(
ctx.js,
"need_stream");
1351 SCJbAppendString(
ctx.js,
"negated_mpm");
1354 SCJbAppendString(
ctx.js,
"flush");
1357 SCJbAppendString(
ctx.js,
"need_flowvar");
1360 SCJbAppendString(
ctx.js,
"filestore");
1363 SCJbAppendString(
ctx.js,
"toserver");
1366 SCJbAppendString(
ctx.js,
"toclient");
1369 SCJbAppendString(
ctx.js,
"tlsstore");
1372 SCJbAppendString(
ctx.js,
"bypass");
1375 SCJbAppendString(
ctx.js,
"prefilter");
1378 SCJbAppendString(
ctx.js,
"src_is_target");
1381 SCJbAppendString(
ctx.js,
"dst_is_target");
1388 SCJbOpenArray(
ctx.js,
"pkt_engines");
1390 for ( ; pkt != NULL; pkt = pkt->
next) {
1405 SCJbStartObject(
ctx.js);
1406 SCJbSetString(
ctx.js,
"name",
name);
1407 SCJbSetBool(
ctx.js,
"is_mpm", pkt->
mpm);
1409 SCJbOpenArray(
ctx.js,
"transforms");
1411 SCJbStartObject(
ctx.js);
1412 SCJbSetString(
ctx.js,
"name",
1425 SCJbOpenArray(
ctx.js,
"frame_engines");
1427 for (; frame != NULL; frame = frame->
next) {
1429 SCJbStartObject(
ctx.js);
1430 SCJbSetString(
ctx.js,
"name",
name);
1431 SCJbSetBool(
ctx.js,
"is_mpm", frame->
mpm);
1433 SCJbOpenArray(
ctx.js,
"transforms");
1435 SCJbStartObject(
ctx.js);
1436 SCJbSetString(
ctx.js,
"name",
1448 bool has_stream =
false;
1449 bool has_client_body_mpm =
false;
1450 bool has_file_data_mpm =
false;
1452 SCJbOpenArray(
ctx.js,
"engines");
1454 for ( ; app != NULL; app = app->
next) {
1469 }
else if (app->
mpm && strcmp(
name,
"http_client_body") == 0) {
1470 has_client_body_mpm =
true;
1471 }
else if (app->
mpm && strcmp(
name,
"file_data") == 0) {
1472 has_file_data_mpm =
true;
1475 SCJbStartObject(
ctx.js);
1476 SCJbSetString(
ctx.js,
"name",
name);
1477 const char *direction = app->
dir == 0 ?
"toserver" :
"toclient";
1478 SCJbSetString(
ctx.js,
"direction", direction);
1479 SCJbSetBool(
ctx.js,
"is_mpm", app->
mpm);
1483 SCJbSetString(
ctx.js,
"sub_state",
1487 SCJbOpenArray(
ctx.js,
"transforms");
1489 SCJbStartObject(
ctx.js);
1490 SCJbSetString(
ctx.js,
"name",
1504 if (has_stream && has_client_body_mpm)
1505 AnalyzerNote(&
ctx, (
char *)
"mpm in http_client_body combined with stream match leads to stream buffering");
1506 if (has_stream && has_file_data_mpm)
1507 AnalyzerNote(&
ctx, (
char *)
"mpm in file_data combined with stream match leads to stream buffering");
1510 SCJbOpenObject(
ctx.js,
"lists");
1520 if (pkt_mpm || app_mpm) {
1521 SCJbOpenObject(
ctx.js,
"mpm");
1529 SCJbSetString(
ctx.js,
"buffer",
name);
1537 switch (smd->
type) {
1541 DumpContent(
ctx.js, cd);
1553 SCJbOpenObject(
ctx.js,
"prefilter");
1560 SCJbSetString(
ctx.js,
"buffer",
name);
1562 SCJbSetString(
ctx.js,
"name", mname);
1566 if (
ctx.js_warnings) {
1567 SCJbClose(
ctx.js_warnings);
1568 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
1569 SCJbFree(
ctx.js_warnings);
1570 ctx.js_warnings = NULL;
1573 SCJbClose(
ctx.js_notes);
1574 SCJbSetObject(
ctx.js,
"notes",
ctx.js_notes);
1575 SCJbFree(
ctx.js_notes);
1576 ctx.js_notes = NULL;
1580 const char *filename =
"rules.json";
1582 char json_path[PATH_MAX] =
"";
1583 snprintf(json_path,
sizeof(json_path),
"%s/%s%s", log_dir,
1587 FILE *fp = fopen(json_path,
"a");
1589 fwrite(SCJbPtr(
ctx.js), SCJbLen(
ctx.js), 1, fp);
1603 SCJsonBuilder *root_jb = SCJbNewObject();
1604 if (root_jb == NULL) {
1608 if (arrays == NULL) {
1613 SCJbOpenArray(root_jb,
"buffers");
1617 char str[1024] =
"";
1621 SCJsonBuilder *jb = arrays[
p->sm_list];
1622 if (arrays[
p->sm_list] == NULL) {
1623 jb = arrays[
p->sm_list] = SCJbNewObject();
1629 SCJbSetString(jb,
"name",
name);
1630 SCJbSetUint(jb,
"list_id",
p->sm_list);
1632 SCJbOpenArray(jb,
"patterns");
1635 SCJbStartObject(jb);
1636 SCJbSetString(jb,
"pattern",
str);
1637 SCJbSetUint(jb,
"patlen",
p->cd->content_len);
1638 SCJbSetUint(jb,
"cnt",
p->cnt);
1639 SCJbSetUint(jb,
"mpm",
p->mpm);
1640 SCJbOpenObject(jb,
"flags");
1651 SCJsonBuilder *jb = arrays[i];
1658 SCJbAppendObject(root_jb, jb);
1664 const char *filename =
"patterns.json";
1666 char json_path[PATH_MAX] =
"";
1667 snprintf(json_path,
sizeof(json_path),
"%s/%s%s", log_dir,
1671 FILE *fp = fopen(json_path,
"a");
1673 fwrite(SCJbPtr(root_jb), SCJbLen(root_jb), 1, fp);
1695 EngineAnalysisItemsReset(ea_ctx);
1703 FatalError(
"Unable to allocate analysis scratch pad");
1713 analyzer_item->
item_id = (uint16_t)item_id;
1714 if (analyzer_item->
item_id == -1) {
1716 FatalError(
"unable to initialize engine-analysis table: detect buffer \"%s\" not "
1749 uint32_t rule_bidirectional = 0;
1750 uint32_t rule_pcre = 0;
1751 uint32_t rule_pcre_http = 0;
1752 uint32_t rule_content = 0;
1753 uint32_t rule_flow = 0;
1754 uint32_t rule_flags = 0;
1755 uint32_t rule_flow_toserver = 0;
1756 uint32_t rule_flow_toclient = 0;
1757 uint32_t rule_flow_nostream = 0;
1758 uint32_t rule_ipv4_only = 0;
1759 uint32_t rule_ipv6_only = 0;
1760 uint32_t rule_flowbits = 0;
1761 uint32_t rule_flowint = 0;
1762 uint32_t rule_content_http = 0;
1763 uint32_t rule_content_offset_depth = 0;
1764 int32_t list_id = 0;
1765 uint32_t rule_warning = 0;
1766 uint32_t stream_buf = 0;
1767 uint32_t packet_buf = 0;
1768 uint32_t file_store = 0;
1769 uint32_t warn_pcre_no_content = 0;
1770 uint32_t warn_pcre_http_content = 0;
1771 uint32_t warn_pcre_http = 0;
1772 uint32_t warn_content_http_content = 0;
1773 uint32_t warn_content_http = 0;
1774 uint32_t warn_tcp_no_flow = 0;
1775 uint32_t warn_client_ports = 0;
1776 uint32_t warn_direction = 0;
1777 uint32_t warn_method_toclient = 0;
1778 uint32_t warn_method_serverbody = 0;
1779 uint32_t warn_pcre_method = 0;
1780 uint32_t warn_encoding_norm_http_buf = 0;
1781 uint32_t warn_file_store_not_present = 0;
1782 uint32_t warn_offset_depth_pkt_stream = 0;
1783 uint32_t warn_offset_depth_alproto = 0;
1784 uint32_t warn_non_alproto_fp_for_alproto_sig = 0;
1785 uint32_t warn_no_direction = 0;
1786 uint32_t warn_both_direction = 0;
1788 EngineAnalysisItemsInit(
de_ctx->
ea);
1794 rule_bidirectional = 1;
1808 rule_ipv4_only += 1;
1811 rule_ipv6_only += 1;
1819 if (item_slot == -1) {
1827 if (item_slot == -1) {
1832 rule_content_offset_depth++;
1838 rule_content_http++;
1845 warn_encoding_norm_http_buf += 1;
1852 rule_flow_toserver = 1;
1855 rule_flow_toclient = 1;
1860 rule_flow_nostream = 1;
1874 if (sm->
ctx != NULL) {
1884 warn_file_store_not_present = 1;
1887 if (rule_pcre > 0 && rule_content == 0 && rule_content_http == 0) {
1889 warn_pcre_no_content = 1;
1892 if (rule_content_http > 0 && rule_pcre > 0 && rule_pcre_http == 0) {
1894 warn_pcre_http_content = 1;
1900 if (rule_content > 0 && rule_content_http > 0) {
1902 warn_content_http_content = 1;
1906 warn_content_http = 1;
1908 if (rule_content == 1) {
1913 (rule_content || rule_content_http || rule_pcre || rule_pcre_http || rule_flowbits ||
1916 warn_tcp_no_flow = 1;
1918 if (rule_flow && !rule_bidirectional && (rule_flow_toserver || rule_flow_toclient)
1923 warn_client_ports = 1;
1926 if (rule_flow && rule_bidirectional && (rule_flow_toserver || rule_flow_toclient)) {
1931 if (*http_method_item_seen_ptr) {
1932 if (rule_flow && rule_flow_toclient) {
1934 warn_method_toclient = 1;
1936 if (*http_server_body_item_seen_ptr) {
1938 warn_method_serverbody = 1;
1940 if (rule_content == 0 && rule_content_http == 0 && (rule_pcre > 0 || rule_pcre_http > 0)) {
1942 warn_pcre_method = 1;
1945 if (rule_content_offset_depth > 0 && stream_buf && packet_buf) {
1947 warn_offset_depth_pkt_stream = 1;
1951 warn_offset_depth_alproto = 1;
1956 warn_non_alproto_fp_for_alproto_sig = 1;
1960 warn_no_direction += 1;
1968 warn_both_direction += 1;
1973 if (!rule_warnings_only || (rule_warnings_only && rule_warning > 0)) {
1975 fprintf(fp,
"== Sid: %u ==\n", s->
id);
1976 fprintf(fp,
"%s\n", line);
1982 fprintf(fp,
" Rule is ip only.\n");
1985 fprintf(fp,
" Rule is like ip only.\n");
1988 fprintf(fp,
" Rule is PD only.\n");
1991 fprintf(fp,
" Rule is DE only.\n");
1994 fprintf(fp,
" Rule is packet inspecting.\n");
1997 fprintf(fp,
" Rule is packet and stream inspecting.\n");
2000 fprintf(fp,
" Rule is stream inspecting.\n");
2003 fprintf(fp,
" Rule is app-layer inspecting.\n");
2006 fprintf(fp,
" Rule is App-layer TX inspecting.\n");
2012 fprintf(fp,
" Rule is IPv6 only.\n");
2014 fprintf(fp,
" Rule is IPv4 only.\n");
2016 fprintf(fp,
" Rule matches on packets.\n");
2017 if (!rule_flow_nostream && stream_buf &&
2018 (rule_flow || rule_flowbits || rule_flowint || rule_content || rule_pcre)) {
2019 fprintf(fp,
" Rule matches on reassembled stream.\n");
2024 fprintf(fp,
" Rule matches on %s buffer.\n", ai->
display_name);
2030 if (rule_content || rule_content_http || rule_pcre || rule_pcre_http) {
2032 " Rule contains %u content options, %u http content options, %u pcre "
2033 "options, and %u pcre options with http modifiers.\n",
2034 rule_content, rule_content_http, rule_pcre, rule_pcre_http);
2039 fprintf(fp,
" Prefilter on: %s.\n",
2042 EngineAnalysisRulesPrintFP(
de_ctx, s);
2046 if (warn_pcre_no_content ) {
2047 fprintf(fp,
" Warning: Rule uses pcre without a content option present.\n"
2048 " -Consider adding a content to improve performance of this "
2051 if (warn_pcre_http_content ) {
2052 fprintf(fp,
" Warning: Rule uses content options with http_* and pcre options "
2053 "without http modifiers.\n"
2054 " -Consider adding http pcre modifier.\n");
2056 else if (warn_pcre_http ) {
2057 fprintf(fp,
" Warning: Rule app layer protocol is http, but pcre options do not "
2058 "have http modifiers.\n"
2059 " -Consider adding http pcre modifiers.\n");
2061 if (warn_content_http_content ) {
2063 " Warning: Rule contains content with http_* and content without http_*.\n"
2064 " -Consider adding http content modifiers.\n");
2066 if (warn_content_http ) {
2067 fprintf(fp,
" Warning: Rule app layer protocol is http, but content options do not "
2068 "have http_* modifiers.\n"
2069 " -Consider adding http content modifiers.\n");
2071 if (rule_content == 1) {
2074 if (warn_encoding_norm_http_buf) {
2075 fprintf(fp,
" Warning: Rule may contain percent encoded content for a normalized "
2076 "http buffer match.\n");
2078 if (warn_tcp_no_flow
2080 fprintf(fp,
" Warning: TCP rule without a flow or flags option.\n"
2081 " -Consider adding flow or flags to improve performance of "
2084 if (warn_client_ports
2089 " Warning: Rule contains ports or port variables only on the client side.\n"
2090 " -Flow direction possibly inconsistent with rule.\n");
2092 if (warn_direction ) {
2093 fprintf(fp,
" Warning: Rule is bidirectional and has a flow option with a specific "
2096 if (warn_method_toclient ) {
2097 fprintf(fp,
" Warning: Rule uses content or pcre for http_method with "
2098 "flow:to_client or from_server\n");
2100 if (warn_method_serverbody ) {
2101 fprintf(fp,
" Warning: Rule uses content or pcre for http_method with content or "
2102 "pcre for http_server_body.\n");
2104 if (warn_pcre_method
2106 fprintf(fp,
" Warning: Rule uses pcre with only a http_method content; possible "
2107 "performance issue.\n");
2109 if (warn_offset_depth_pkt_stream) {
2110 fprintf(fp,
" Warning: Rule has depth"
2111 "/offset with raw content keywords. Please note the "
2112 "offset/depth will be checked against both packet "
2113 "payloads and stream. If you meant to have the offset/"
2114 "depth checked against just the payload, you can update "
2115 "the signature as \"alert tcp-pkt...\"\n");
2117 if (warn_offset_depth_alproto) {
2119 " Warning: Rule has "
2120 "offset/depth set along with a match on a specific "
2121 "app layer protocol - %d. This can lead to FNs if we "
2122 "have a offset/depth content match on a packet payload "
2123 "before we can detect the app layer protocol for the "
2127 if (warn_non_alproto_fp_for_alproto_sig) {
2128 fprintf(fp,
" Warning: Rule app layer "
2129 "protocol is http, but the fast_pattern is set on the raw "
2130 "stream. Consider adding fast_pattern over a http "
2131 "buffer for increased performance.");
2133 if (warn_no_direction) {
2134 fprintf(fp,
" Warning: Rule has no direction indicator.\n");
2136 if (warn_both_direction) {
2137 fprintf(fp,
" Warning: Rule is inspecting both the request and the response.\n");
2139 if (warn_file_store_not_present) {
2140 fprintf(fp,
" Warning: Rule requires file-store but the output file-store is not "
2143 if (rule_warning == 0) {
2144 fprintf(fp,
" No warnings for this rule.\n");
2158 static bool FirewallPolicyToString(
2167 snprintf(out, out_size,
"rejectdst:%s", as);
2169 snprintf(out, out_size,
"rejectboth:%s", as);
2171 snprintf(out, out_size,
"rejectsrc:%s", as);
2174 snprintf(out, out_size,
"drop:%s", as);
2176 snprintf(out, out_size,
"accept:%s", as);
2183 if (
strlcat(out,
",pass:", out_size) >= out_size ||
2184 strlcat(out, as, out_size) >= out_size) {
2194 if (
strlcat(out,
",alert", out_size) >= out_size) {
2203 const uint8_t sub_state,
const uint8_t state,
const uint8_t direction)
2205 char policy_string[64] =
"";
2214 if (!FirewallPolicyToString(&ap->
policy, policy_string,
sizeof(policy_string)))
2216 SCJbSetString(
ctx->js,
"policy", policy_string);
2222 uint32_t accept_rules = 0;
2224 SCJbOpenArray(
ctx->js,
"rules");
2248 bool skip_rule =
false;
2250 engine = engine->
next) {
2253 }
else if (engine->sub_state !=
sub_state) {
2274 if (accept_rules == 0) {
2275 AnalyzerWarning(
ctx, (
char *)
"no accept rules for state, default policy will be applied");
2282 ctx.js = SCJbNewObject();
2286 SCJbOpenObject(
ctx.js,
"tables");
2287 SCJbOpenObject(
ctx.js,
"packet:filter");
2288 char pkt_policy[64] =
"";
2290 pkt_policy,
sizeof(pkt_policy))) {
2291 SCJbSetString(
ctx.js,
"policy", pkt_policy);
2293 SCJbOpenArray(
ctx.js,
"rules");
2294 uint32_t accept_rules = 0;
2295 uint32_t last_sid = 0;
2302 if (last_sid == s->
id)
2309 if (accept_rules == 0) {
2310 AnalyzerWarning(&
ctx,
2311 (
char *)
"no accept rules for \'packet:filter\', default policy will be applied");
2313 if (
ctx.js_warnings) {
2314 SCJbClose(
ctx.js_warnings);
2315 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
2316 SCJbFree(
ctx.js_warnings);
2317 ctx.js_warnings = NULL;
2322 if (!AppProtoIsValid(a))
2331 for (uint8_t state = 0; state <= max_progress; state++) {
2337 char table_name[256];
2338 snprintf(table_name,
sizeof(table_name),
"app:%s:%s:%s",
AppProtoToString(a),
2339 sub_state_name,
name);
2340 SCJbOpenObject(
ctx.js, table_name);
2342 if (
ctx.js_warnings) {
2343 SCJbClose(
ctx.js_warnings);
2344 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
2345 SCJbFree(
ctx.js_warnings);
2346 ctx.js_warnings = NULL;
2350 for (uint8_t state = 0; state <= max_progress; state++) {
2356 char table_name[256];
2357 snprintf(table_name,
sizeof(table_name),
"app:%s:%s:%s",
AppProtoToString(a),
2358 sub_state_name,
name);
2359 SCJbOpenObject(
ctx.js, table_name);
2361 if (
ctx.js_warnings) {
2362 SCJbClose(
ctx.js_warnings);
2363 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
2364 SCJbFree(
ctx.js_warnings);
2365 ctx.js_warnings = NULL;
2376 const uint8_t complete_state_ts =
2379 for (uint8_t state = 0; state <= complete_state_ts; state++) {
2388 char table_name[128];
2390 SCJbOpenObject(
ctx.js, table_name);
2391 FirewallAddRulesForState(
de_ctx, a, 0, state, STREAM_TOSERVER, &
ctx);
2392 if (
ctx.js_warnings) {
2393 SCJbClose(
ctx.js_warnings);
2394 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
2395 SCJbFree(
ctx.js_warnings);
2396 ctx.js_warnings = NULL;
2400 const uint8_t complete_state_tc =
2402 for (uint8_t state = 0; state <= complete_state_tc; state++) {
2410 char table_name[128];
2412 SCJbOpenObject(
ctx.js, table_name);
2413 FirewallAddRulesForState(
de_ctx, a, 0, state, STREAM_TOCLIENT, &
ctx);
2414 if (
ctx.js_warnings) {
2415 SCJbClose(
ctx.js_warnings);
2416 SCJbSetObject(
ctx.js,
"warnings",
ctx.js_warnings);
2417 SCJbFree(
ctx.js_warnings);
2418 ctx.js_warnings = NULL;
2424 SCJbOpenObject(
ctx.js,
"packet:td");
2425 SCJbSetString(
ctx.js,
"policy",
"accept:hook");
2427 SCJbOpenArray(
ctx.js,
"rules");
2433 if (last_sid == s->
id)
2440 SCJbOpenObject(
ctx.js,
"app:td");
2441 SCJbSetString(
ctx.js,
"policy",
"accept:hook");
2443 SCJbOpenArray(
ctx.js,
"rules");
2449 if (last_sid == s->
id)
2458 SCJbOpenObject(
ctx.js,
"lists");
2459 SCJbOpenObject(
ctx.js,
"firewall");
2461 SCJbOpenArray(
ctx.js,
"rules");
2465 if (last_sid == s->
id)
2473 SCJbOpenObject(
ctx.js,
"td");
2475 SCJbOpenArray(
ctx.js,
"rules");
2479 if (last_sid == s->
id)
2487 SCJbOpenObject(
ctx.js,
"all");
2489 SCJbOpenArray(
ctx.js,
"rules");
2491 if (last_sid == s->
id)
2502 SCJbOpenObject(
ctx.js,
"keyword_info");
2512 snprintf(sid_key,
sizeof(sid_key),
"%u", s->
id);
2513 SCJbOpenObject(
ctx.js, sid_key);
2514 SCJbOpenArray(
ctx.js,
"tcp_session");
2516 SCJbAppendString(
ctx.js,
"setup");
2518 SCJbAppendString(
ctx.js,
"established");
2520 SCJbAppendString(
ctx.js,
"closing");
2535 const char *filename =
"firewall.json";
2537 char json_path[PATH_MAX] =
"";
2538 snprintf(json_path,
sizeof(json_path),
"%s/%s", log_dir, filename);
2541 FILE *fp = fopen(json_path,
"w");
2543 fwrite(SCJbPtr(
ctx.js), SCJbLen(
ctx.js), 1, fp);
#define DETECT_PCRE_CASELESS
#define DETECT_CONTENT_NOCASE
int SignatureHasPacketContent(const Signature *s)
check if a signature has patterns that are to be inspected against a packets payload (as opposed to t...
#define HashListTableGetListData(hb)
uint32_t rule_state_dependant_sids_idx
#define DETECT_CONTENT_RELATIVE_NEXT
struct DetectEngineAppInspectionEngine_::@82 v2
int SCConfValIsTrue(const char *val)
Check if a value is true.
#define SIG_MASK_REQUIRE_REAL_PKT
#define DETECT_CONTENT_FAST_PATTERN_CHOP
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
#define SIG_FLAG_FW_HOOK_LTE
SigTableElmt * sigmatch_table
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
struct DetectEngineAppInspectionEngine_ * next
#define DETECT_PROTO_IPV6
#define DETECT_FLOW_FLAG_NOSTREAM
const char * DetectListToHumanString(int list)
HashListTable * pattern_hash_table
void DumpPatterns(DetectEngineCtx *de_ctx)
#define DETECT_BYTEJUMP_LITTLE
void SetupEngineAnalysis(DetectEngineCtx *de_ctx, bool *fp_analysis, bool *rule_analysis)
uint8_t app_progress_hook
FILE * rule_engine_analysis_fp
bool is_rule_state_dependant
#define DETECT_BYTETEST_BASE_HEX
const char * ActionScopeToString(enum ActionScope s)
Per-rule keyword data for app-layer-protocol:.
void DetectContentPatternPrettyPrint(const uint8_t *pat, const uint16_t pat_len, char *str, size_t str_len)
SCMutex g_rules_analyzer_write_m
const char * display_name
#define DETECT_CONTENT_WITHIN2DEPTH
@ DETECT_SM_LIST_DYNAMIC_START
#define DETECT_FLOWBITS_CMD_ISNOTSET
#define SIG_FLAG_DEST_IS_TARGET
#define DETECT_CONTENT_NO_DOUBLE_INSPECTION_REQUIRED
uint8_t AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its normalized string equivalent.
tcp.session: keyword (Redmine #7704).
#define DETECT_BYTEJUMP_BASE_OCT
const DetectEngineTransforms * transforms
main detection engine ctx
struct DetectFirewallPolicy policy
#define DETECT_BYTETEST_DCE
HashListTableBucket * HashListTableGetListHead(HashListTable *ht)
FpPatternStats fp_pattern_stats[DETECT_SM_LIST_MAX]
const char * DetectAppLayerProtocolModeName(uint8_t mode)
Map a DETECT_ALPROTO_* mode value to its textual qualifier.
const char * DetectEngineBufferTypeGetNameById(const DetectEngineCtx *de_ctx, const int id)
#define SIG_FLAG_REQUIRE_STREAM
#define DETECT_XBITS_TRACK_IPDST
FILE * fp_engine_analysis_fp
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
bool analyzer_initialized
#define ACTION_REJECT_ANY
#define DETECT_BYTEJUMP_DCE
const char * VarNameStoreSetupLookup(const uint32_t id, const enum VarTypes type)
#define SCMUTEX_INITIALIZER
SigMatchData * sm_arrays[DETECT_SM_LIST_MAX]
#define DETECT_FLOWBITS_CMD_ISSET
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
int16_t analyzer_item_map[256]
#define SIG_FLAG_TOCLIENT
#define DETECT_BYTEJUMP_BIG
void EngineAnalysisRulesFailure(const DetectEngineCtx *de_ctx, const char *line, const char *file, int lineno)
DetectEngineFrameInspectionEngine * frame_inspect
const DetectEngineTransforms * transforms
DetectEngineAnalyzerItems * analyzer_items
#define DETECT_PERCENT_ENCODING_REGEX
int FirewallAnalyzer(const DetectEngineCtx *de_ctx)
#define SIG_FLAG_APPLAYER
int DetectBufferTypeGetByName(const char *name)
uint16_t DetectAppLayerProtocolGetValues(const DetectAppLayerProtocolData *data, AppProto *out, uint16_t max)
Fill out[] with the keyword's set protocol values.
#define SIG_FLAG_FIREWALL
const char * DetectFirewallAppGenericHookName(const uint8_t state, const uint8_t complete_state, const int direction)
Generic start/complete hook alias for an app progress state, in config form (hyphens),...
#define ACTION_REJECT_DST
#define ATTR_FMT_PRINTF(x, y)
#define HashListTableGetListNext(hb)
@ DETECT_APP_LAYER_PROTOCOL
SignaturePropertyFlowAction
#define SIG_FLAG_TOSERVER
#define DETECT_XBITS_CMD_ISNOTSET
#define DETECT_BYTETEST_RELATIVE
uint8_t AppLayerParserGetSubStateCompletion(const AppProto alproto, const uint8_t sub_state)
const char * IpOptsFlagToString(uint16_t flag)
Return human readable value for ipopts flag.
#define JB_SET_STRING(jb, key, val)
struct EngineAnalysisCtx_ EngineAnalysisCtx
struct DetectFirewallPolicies * fw_policies
#define DETECT_CONTENT_ENDS_WITH
#define DETECT_PCRE_RAWBYTES
#define DETECT_CONTENT_DISTANCE
#define SIG_FLAG_INIT_BIDIREC
size_t strlcat(char *, const char *src, size_t siz)
#define SIG_MASK_REQUIRE_ENGINE_EVENT
#define DETECT_BYTETEST_BASE_UNSET
#define DETECT_BYTEJUMP_ALIGN
const char * DetectEngineBufferTypeGetDescriptionById(const DetectEngineCtx *de_ctx, const int id)
#define SCMutexUnlock(mut)
#define DETECT_BYTETEST_BASE_DEC
#define SIG_MASK_REQUIRE_FLOW
#define DETECT_CONTENT_DEPTH
#define DETECT_CONTENT_DISTANCE2OFFSET
#define DETECT_BYTEJUMP_END
DetectEnginePktInspectionEngine * pkt_inspect
struct DetectEngineAnalyzerItems DetectEngineAnalyzerItems
void * HashTableLookup(HashTable *ht, void *data, uint16_t datalen)
#define SIG_MASK_REQUIRE_FLAGS_INITDEINIT
uint32_t rule_state_flowbits_ids_size
#define DETECT_XBITS_TRACK_IPPAIR
struct DetectFirewallPolicy pkt[DETECT_FIREWALL_POLICY_SIZE]
#define DETECT_CONTENT_NEGATED
DetectUintData_u8 DetectU8Data
void EngineAnalysisRules(const DetectEngineCtx *de_ctx, const Signature *s, const char *line)
Prints analysis of loaded rules.
DetectEngineAppInspectionEngine * app_inspect
#define DETECT_TCP_SESSION_PHASE_SETUP
SCJsonBuilder * js_warnings
#define SIG_FLAG_REQUIRE_FLOWVAR
struct DetectEngineFrameInspectionEngine::@86 v1
#define DETECT_BYTETEST_BIG
struct tm * SCLocalTime(time_t timep, struct tm *result)
const char * SCConfigGetLogDirectory(void)
const DetectBufferType * DetectEngineBufferTypeGetById(const DetectEngineCtx *de_ctx, const int id)
#define DETECT_BYTEJUMP_BASE_UNSET
SignatureInitData * init_data
#define SIG_FLAG_SRC_IS_TARGET
uint32_t * rule_state_dependant_sids_array
bool fp_engine_analysis_set
uint32_t rule_state_dependant_sids_size
#define DETECT_PCRE_HAS_UNICODE_CLUSTER
#define DETECT_BYTEJUMP_BASE_HEX
@ SIG_PROP_FLOW_ACTION_PACKET
const struct SignatureProperties signature_properties[SIG_TYPE_MAX]
#define SIG_MASK_REQUIRE_PAYLOAD
#define DETECT_TCP_SESSION_PHASE_ESTABLISHED
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define DETECT_BYTEJUMP_OFFSET_BE
const char * DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type)
const DetectEngineAnalyzerItems analyzer_items[]
#define SIG_FLAG_INIT_STATE_MATCH
#define DETECT_XBITS_TRACK_TX
void EngineAnalysisRules2(const DetectEngineCtx *de_ctx, const Signature *s)
#define ACTION_REJECT_BOTH
union DetectFlowintData_::@68 target
#define DETECT_CONTENT_STARTS_WITH
#define DETECT_PROTO_IPV4
#define DETECT_TCP_SESSION_PHASE_CLOSING
int SignatureHasStreamContent(const Signature *s)
check if a signature has patterns that are to be inspected against the stream payload (as opposed to ...
#define SIG_MASK_REQUIRE_NO_PAYLOAD
struct DetectEnginePktInspectionEngine::@85 v1
@ SIG_PROP_FLOW_ACTION_FLOW_IF_STATEFUL
@ DETECT_FIREWALL_POLICY_PACKET_FILTER
void HashListTableFree(HashListTable *ht)
bool check_encoding_match
void CleanupEngineAnalysis(DetectEngineCtx *de_ctx)
struct DetectEngineFrameInspectionEngine * next
DetectUintData_u32 DetectU32Data
struct DetectEnginePktInspectionEngine * next
const char * AppLayerParserGetSubStateProgressName(const AppProto alproto, const uint8_t sub_state, const uint8_t state, const uint8_t dir_flag)
#define DETECT_BYTEJUMP_BASE_DEC
void PrintRawUriFp(FILE *fp, const uint8_t *buf, uint32_t buflen)
#define SIG_MASK_REQUIRE_FLAGS_UNUSUAL
@ FLOWINT_MODIFIER_ISNOTSET
struct EngineAnalysisCtx_ * ea
#define DETECT_BYTETEST_BASE_OCT
void EngineAnalysisFP(const DetectEngineCtx *de_ctx, const Signature *s, const char *line)
struct FpPatternStats_ FpPatternStats
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
#define SCLogError(...)
Macro used to log ERROR messages.
int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm)
const char * AppLayerParserGetSubStateName(const AppProto alproto, const uint8_t sub_state)
#define DETECT_CONTENT_OFFSET
#define DETECT_XBITS_TRACK_IPSRC
#define DETECT_FLOWBITS_CMD_UNSET
#define DETECT_CONTENT_FAST_PATTERN_ONLY
#define DETECT_CONTENT_MPM
DetectEngineTransforms transforms
a single match condition for a signature
const DetectEngineTransforms * transforms
bool SCRequiresFeature(const char *feature_name)
#define DETECT_XBITS_CMD_ISSET
#define DETECT_BYTETEST_STRING
#define DETECT_PCRE_RELATIVE_NEXT
#define DETECT_BYTEJUMP_STRING
uint8_t AppLayerParserGetMaxSubState(const AppProto alproto)
#define DETECT_XBITS_CMD_SET
#define DETECT_BYTEJUMP_BEGIN
uint32_t * rule_state_flowbits_ids_array
bool AppLayerParserSupportsSubStates(const AppProto alproto)
@ SIG_PROP_FLOW_ACTION_FLOW
#define DETECT_PCRE_RELATIVE
struct RuleAnalyzer RuleAnalyzer
#define SIG_FLAG_TLSSTORE
#define DETECT_XBITS_CMD_TOGGLE
DetectUintData_u16 DetectU16Data
#define DETECT_XBITS_CMD_UNSET
#define DETECT_CONTENT_FAST_PATTERN
#define DETECT_PCRE_NEGATE
struct ExposedItemSeen exposed_item_seen_list[2]
#define DETECT_BYTETEST_LITTLE
#define DEBUG_VALIDATE_BUG_ON(exp)
#define SIG_FLAG_PREFILTER
enum SignaturePropertyFlowAction flow_action
#define SIG_FLAG_FILESTORE
#define DETECT_CONTENT_WITHIN
#define DETECT_BYTEJUMP_RELATIVE
#define DETECT_FLOWBITS_CMD_SET
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto
#define SIG_FLAG_REQUIRE_PACKET