51 static int rule_warnings_only = 0;
107 { 0,
false,
false,
true,
"http_uri",
"http uri" },
108 { 0,
false,
false,
false,
"http_raw_uri",
"http raw uri" },
109 { 0,
false,
true,
false,
"http_method",
"http method" },
110 { 0,
false,
false,
false,
"http_request_line",
"http request line" },
111 { 0,
false,
false,
false,
"http_client_body",
"http client body" },
112 { 0,
false,
false,
true,
"http_header",
"http header" },
113 { 0,
false,
false,
false,
"http_raw_header",
"http raw header" },
114 { 0,
false,
false,
true,
"http_cookie",
"http cookie" },
115 { 0,
false,
false,
false,
"http_user_agent",
"http user agent" },
116 { 0,
false,
false,
false,
"http_host",
"http host" },
117 { 0,
false,
false,
false,
"http_raw_host",
"http raw host" },
118 { 0,
false,
false,
false,
"http_accept_enc",
"http accept enc" },
119 { 0,
false,
false,
false,
"http_referer",
"http referer" },
120 { 0,
false,
false,
false,
"http_content_type",
"http content type" },
121 { 0,
false,
false,
false,
"http_header_names",
"http header names" },
124 { 0,
false,
false,
false,
"http_stat_msg",
"http stat msg" },
125 { 0,
false,
false,
false,
"http_stat_code",
"http stat code" },
126 { 0,
false,
true,
false,
"file_data",
"http server body" },
129 { 0,
false,
false,
false,
"http_request_line",
"http request line" },
130 { 0,
false,
false,
false,
"http_accept",
"http accept" },
131 { 0,
false,
false,
false,
"http_accept_lang",
"http accept lang" },
132 { 0,
false,
false,
false,
"http_connection",
"http connection" },
133 { 0,
false,
false,
false,
"http_content_len",
"http content len" },
134 { 0,
false,
false,
false,
"http_protocol",
"http protocol" },
135 { 0,
false,
false,
false,
"http_start",
"http start" },
138 { 0,
false,
false,
false,
"http_response_line",
"http response line" },
139 { 0,
false,
false,
false,
"http.server",
"http server" },
140 { 0,
false,
false,
false,
"http.location",
"http location" },
143 static void FpPatternStatsAdd(
FpPatternStats *fp,
int list, uint16_t patlen)
152 else if (patlen < f->min)
164 int fast_pattern_set = 0;
165 int fast_pattern_only_set = 0;
166 int fast_pattern_chop_set = 0;
171 if (mpm_sm != NULL) {
174 fast_pattern_set = 1;
176 fast_pattern_only_set = 1;
178 fast_pattern_chop_set = 1;
184 fprintf(fp,
"== Sid: %u ==\n", s->
id);
185 fprintf(fp,
"%s\n", line);
187 fprintf(fp,
" Fast Pattern analysis:\n");
189 fprintf(fp,
" Prefilter on: %s\n",
196 fprintf(fp,
" No content present\n");
201 fprintf(fp,
" Fast pattern matcher: ");
202 int list_type = mpm_sm_list;
204 fprintf(fp,
"content\n");
209 fprintf(fp,
"%s (%s)\n", desc, name);
214 fprintf(fp,
" Flags:");
216 fprintf(fp,
" Offset");
219 fprintf(fp,
" Depth");
223 fprintf(fp,
" Within");
227 fprintf(fp,
" Distance");
231 fprintf(fp,
" Nocase");
235 fprintf(fp,
" Negated");
239 fprintf(fp,
" None");
242 fprintf(fp,
" Fast pattern set: %s\n", fast_pattern_set ?
"yes" :
"no");
243 fprintf(fp,
" Fast pattern only set: %s\n", fast_pattern_only_set ?
"yes" :
"no");
244 fprintf(fp,
" Fast pattern chop set: %s\n", fast_pattern_chop_set ?
"yes" :
"no");
245 if (fast_pattern_chop_set) {
246 fprintf(fp,
" Fast pattern offset, length: %u, %u\n", fp_cd->
fp_chop_offset,
257 fprintf(fp,
" Original content: ");
261 if (fast_pattern_chop_set) {
270 fprintf(fp,
" Final content: ");
276 fprintf(fp,
" Final content: ");
296 int fp_engine_analysis_set = 0;
298 if ((
ConfGetBool(
"engine-analysis.rules-fast-pattern",
299 &fp_engine_analysis_set)) == 0) {
303 if (fp_engine_analysis_set == 0)
307 char *log_path =
SCMalloc(PATH_MAX);
308 if (log_path == NULL) {
309 FatalError(
"Unable to allocate scratch memory for rule filename");
311 snprintf(log_path, PATH_MAX,
"%s/%s%s", log_dir,
314 FILE *fp = fopen(log_path,
"w");
316 SCLogError(
"failed to open %s: %s", log_path, strerror(errno));
323 SCLogInfo(
"Engine-Analysis for fast_pattern printed to file - %s",
328 gettimeofday(&tval, NULL);
330 struct tm *tms =
SCLocalTime(tval.tv_sec, &local_tm);
331 fprintf(fp,
"----------------------------------------------"
332 "---------------------\n");
334 "Date: %" PRId32
"/%" PRId32
"/%04d -- "
336 tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour, tms->tm_min,
338 fprintf(fp,
"----------------------------------------------"
339 "---------------------\n");
352 #define DETECT_PERCENT_ENCODING_REGEX "%[0-9|a-f|A-F]{2}"
358 PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
360 PCRE2_UCHAR errbuffer[256];
361 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
382 }
else if (value && strcasecmp(value,
"warnings-only") == 0) {
384 rule_warnings_only = 1;
389 char log_path[PATH_MAX];
390 snprintf(log_path,
sizeof(log_path),
"%s/%s%s", log_dir,
394 SCLogError(
"failed to open %s: %s", log_path, strerror(errno));
398 SCLogInfo(
"Engine-Analysis for rules printed to file - %s",
402 gettimeofday(&tval, NULL);
404 struct tm *tms =
SCLocalTime(tval.tv_sec, &local_tm);
406 "----------------------------------------------"
407 "---------------------\n");
409 "Date: %" PRId32
"/%" PRId32
"/%04d -- "
411 tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour, tms->tm_min,
414 "----------------------------------------------"
415 "---------------------\n");
418 if (!PerCentEncodingSetup(
de_ctx->
ea)) {
420 "Error compiling regex; can't check for percent encoding in normalized "
426 SCLogInfo(
"Conf parameter \"engine-analysis.rules\" not found. "
427 "Defaulting to not printing the rules analysis report.");
430 SCLogInfo(
"Engine-Analysis for rules disabled in conf file.");
439 fprintf(fp,
"============\n"
440 "Summary:\n============\n");
448 "%s, smallest pattern %u byte(s), longest pattern %u byte(s), number of patterns "
449 "%u, avg pattern len %.2f byte(s)\n",
451 (
float)((
double)f->
tot / (
float)f->
cnt));
473 *fp_analysis =
false;
474 *rule_analysis =
false;
478 FatalError(
"Unable to allocate per-engine analysis context");
483 if (cfg_prefix_len > 0) {
487 FatalError(
"Unable to allocate per-engine analysis context name buffer");
495 *fp_analysis = SetupFPAnalyzer(
de_ctx);
496 *rule_analysis = SetupRuleAnalyzer(
de_ctx);
498 if (!(*fp_analysis || *rule_analysis)) {
510 CleanupRuleAnalyzer(
de_ctx);
511 CleanupFPAnalyzer(
de_ctx);
528 static int PerCentEncodingMatch(
EngineAnalysisCtx *ea_ctx, uint8_t *content, uint16_t content_len)
532 pcre2_match_data *match = pcre2_match_data_create_from_pattern(ea_ctx->
percent_re, NULL);
533 ret = pcre2_match(ea_ctx->
percent_re, (PCRE2_SPTR8)content, content_len, 0, 0, match, NULL);
536 }
else if (ret < -1) {
537 SCLogError(
"Error parsing content - %s; error code is %d", content, ret);
540 pcre2_match_data_free(match);
550 if (mpm_sm != NULL) {
588 const int list_type = mpm_sm_list;
597 payload ? (stream ?
"payload and reassembled stream" :
"payload")
598 :
"reassembled stream");
605 }
else if (desc || name) {
644 vsnprintf(
str,
sizeof(
str), fmt, ap);
648 ctx->js_notes = jb_new_array();
650 jb_append_string(ctx->js_notes,
str);
659 vsnprintf(
str,
sizeof(
str), fmt, ap);
662 if (!ctx->js_warnings)
663 ctx->js_warnings = jb_new_array();
664 if (ctx->js_warnings)
665 jb_append_string(ctx->js_warnings,
str);
668 #define CHECK(pat) if (strlen((pat)) <= len && memcmp((pat), buf, MIN(len, strlen((pat)))) == 0) return true;
670 static bool LooksLikeHTTPMethod(
const uint8_t *buf, uint16_t
len)
679 static bool LooksLikeHTTPUA(
const uint8_t *buf, uint16_t
len)
681 CHECK(
"User-Agent: ");
682 CHECK(
"\nUser-Agent: ");
688 char pattern_str[1024] =
"";
691 jb_set_string(js,
"pattern", pattern_str);
700 jb_set_uint(js,
"offset", cd->
offset);
703 jb_set_uint(js,
"depth", cd->
depth);
706 jb_set_int(js,
"distance", cd->
distance);
709 jb_set_int(js,
"within", cd->
within);
728 jb_open_array(js,
"matches");
732 jb_set_string(js,
"name", mname);
738 jb_open_object(js,
"content");
741 AnalyzerNote(ctx, (
char *)
"'fast_pattern:only' option is silently ignored and "
742 "is interpreted as regular 'fast_pattern'");
746 (
char *)
"pattern looks like it inspects HTTP, use http.request_line or "
747 "http.method and http.uri instead for improved performance");
751 (
char *)
"pattern looks like it inspects HTTP, use http.user_agent "
752 "or http.header for improved performance");
755 AnalyzerNote(ctx, (
char *)
"'within' option for pattern w/o previous content "
756 "was converted to 'depth'");
759 AnalyzerNote(ctx, (
char *)
"'distance' option for pattern w/o previous content "
760 "was converted to 'offset'");
768 jb_open_object(js,
"pcre");
773 (
char *)
"'/B' (rawbytes) option is a no-op and is silently ignored");
780 jb_open_object(js,
"byte_jump");
781 jb_set_uint(js,
"nbytes", cd->
nbytes);
782 jb_set_int(js,
"offset", cd->
offset);
783 jb_set_uint(js,
"multiplier", cd->
multiplier);
787 jb_set_string(js,
"base",
"unset");
790 jb_set_string(js,
"base",
"oct");
793 jb_set_string(js,
"base",
"dec");
796 jb_set_string(js,
"base",
"hex");
799 jb_open_array(js,
"flags");
801 jb_append_string(js,
"from_beginning");
803 jb_append_string(js,
"little_endian");
805 jb_append_string(js,
"big_endian");
807 jb_append_string(js,
"string");
809 jb_append_string(js,
"relative");
811 jb_append_string(js,
"align");
813 jb_append_string(js,
"dce");
815 jb_append_string(js,
"offset_be");
817 jb_append_string(js,
"from_end");
825 jb_open_object(js,
"byte_test");
826 jb_set_uint(js,
"nbytes", cd->
nbytes);
827 jb_set_int(js,
"offset", cd->
offset);
830 jb_set_string(js,
"base",
"unset");
833 jb_set_string(js,
"base",
"oct");
836 jb_set_string(js,
"base",
"dec");
839 jb_set_string(js,
"base",
"hex");
842 jb_open_array(js,
"flags");
844 jb_append_string(js,
"little_endian");
846 jb_append_string(js,
"big_endian");
848 jb_append_string(js,
"string");
850 jb_append_string(js,
"relative");
852 jb_append_string(js,
"dce");
860 jb_open_object(js,
"ipopts");
862 jb_set_string(js,
"option", flag);
869 jb_open_object(js,
"flowbits");
872 jb_set_string(js,
"cmd",
"isset");
875 jb_set_string(js,
"cmd",
"isnotset");
878 jb_set_string(js,
"cmd",
"set");
881 jb_set_string(js,
"cmd",
"unset");
884 jb_set_string(js,
"cmd",
"toggle");
888 jb_open_array(js,
"names");
894 const char *varname =
896 jb_append_string(js, varname);
901 jb_set_string(js,
"operator",
"or");
923 ctx.
js = jb_new_object();
927 jb_set_string(ctx.
js,
"raw", s->
sig_str);
928 jb_set_uint(ctx.
js,
"id", s->
id);
929 jb_set_uint(ctx.
js,
"gid", s->
gid);
930 jb_set_uint(ctx.
js,
"rev", s->
rev);
931 jb_set_string(ctx.
js,
"msg", s->
msg);
934 jb_set_string(ctx.
js,
"app_proto", alproto);
936 jb_open_array(ctx.
js,
"requirements");
938 jb_append_string(ctx.
js,
"payload");
941 jb_append_string(ctx.
js,
"no_payload");
944 jb_append_string(ctx.
js,
"flow");
947 jb_append_string(ctx.
js,
"tcp_flags_init_deinit");
950 jb_append_string(ctx.
js,
"tcp_flags_unusual");
953 jb_append_string(ctx.
js,
"engine_event");
959 jb_set_string(ctx.
js,
"type",
"unset");
962 jb_set_string(ctx.
js,
"type",
"ip_only");
965 jb_set_string(ctx.
js,
"type",
"like_ip_only");
968 jb_set_string(ctx.
js,
"type",
"pd_only");
971 jb_set_string(ctx.
js,
"type",
"de_only");
974 jb_set_string(ctx.
js,
"type",
"pkt");
977 jb_set_string(ctx.
js,
"type",
"pkt_stream");
980 jb_set_string(ctx.
js,
"type",
"stream");
983 jb_set_string(ctx.
js,
"type",
"app_layer");
986 jb_set_string(ctx.
js,
"type",
"app_tx");
989 jb_set_string(ctx.
js,
"type",
"error");
993 jb_open_array(ctx.
js,
"flags");
995 jb_append_string(ctx.
js,
"src_any");
998 jb_append_string(ctx.
js,
"dst_any");
1001 jb_append_string(ctx.
js,
"sp_any");
1004 jb_append_string(ctx.
js,
"dp_any");
1007 jb_append_string(ctx.
js,
"noalert");
1010 jb_append_string(ctx.
js,
"dsize");
1013 jb_append_string(ctx.
js,
"applayer");
1016 jb_append_string(ctx.
js,
"need_packet");
1019 jb_append_string(ctx.
js,
"need_stream");
1022 jb_append_string(ctx.
js,
"negated_mpm");
1025 jb_append_string(ctx.
js,
"flush");
1028 jb_append_string(ctx.
js,
"need_flowvar");
1031 jb_append_string(ctx.
js,
"filestore");
1034 jb_append_string(ctx.
js,
"toserver");
1037 jb_append_string(ctx.
js,
"toclient");
1040 jb_append_string(ctx.
js,
"tlsstore");
1043 jb_append_string(ctx.
js,
"bypass");
1046 jb_append_string(ctx.
js,
"prefilter");
1049 jb_append_string(ctx.
js,
"src_is_target");
1052 jb_append_string(ctx.
js,
"dst_is_target");
1059 jb_open_array(ctx.
js,
"pkt_engines");
1061 for ( ; pkt != NULL; pkt = pkt->
next) {
1076 jb_start_object(ctx.
js);
1077 jb_set_string(ctx.
js,
"name", name);
1078 jb_set_bool(ctx.
js,
"is_mpm", pkt->
mpm);
1080 jb_open_array(ctx.
js,
"transforms");
1082 jb_start_object(ctx.
js);
1083 jb_set_string(ctx.
js,
"name",
1089 DumpMatches(&ctx, ctx.
js, pkt->
smd);
1096 jb_open_array(ctx.
js,
"frame_engines");
1098 for (; frame != NULL; frame = frame->
next) {
1100 jb_start_object(ctx.
js);
1101 jb_set_string(ctx.
js,
"name", name);
1102 jb_set_bool(ctx.
js,
"is_mpm", frame->
mpm);
1104 jb_open_array(ctx.
js,
"transforms");
1106 jb_start_object(ctx.
js);
1107 jb_set_string(ctx.
js,
"name",
1113 DumpMatches(&ctx, ctx.
js, frame->
smd);
1119 bool has_stream =
false;
1120 bool has_client_body_mpm =
false;
1121 bool has_file_data_mpm =
false;
1123 jb_open_array(ctx.
js,
"engines");
1125 for ( ; app != NULL; app = app->
next) {
1140 }
else if (app->
mpm && strcmp(name,
"http_client_body") == 0) {
1141 has_client_body_mpm =
true;
1142 }
else if (app->
mpm && strcmp(name,
"file_data") == 0) {
1143 has_file_data_mpm =
true;
1146 jb_start_object(ctx.
js);
1147 jb_set_string(ctx.
js,
"name", name);
1148 const char *direction = app->
dir == 0 ?
"toserver" :
"toclient";
1149 jb_set_string(ctx.
js,
"direction", direction);
1150 jb_set_bool(ctx.
js,
"is_mpm", app->
mpm);
1152 jb_set_uint(ctx.
js,
"progress", app->
progress);
1155 jb_open_array(ctx.
js,
"transforms");
1157 jb_start_object(ctx.
js);
1158 jb_set_string(ctx.
js,
"name",
1164 DumpMatches(&ctx, ctx.
js, app->
smd);
1172 if (has_stream && has_client_body_mpm)
1173 AnalyzerNote(&ctx, (
char *)
"mpm in http_client_body combined with stream match leads to stream buffering");
1174 if (has_stream && has_file_data_mpm)
1175 AnalyzerNote(&ctx, (
char *)
"mpm in file_data combined with stream match leads to stream buffering");
1178 jb_open_object(ctx.
js,
"lists");
1188 if (pkt_mpm || app_mpm) {
1189 jb_open_object(ctx.
js,
"mpm");
1197 jb_set_string(ctx.
js,
"buffer", name);
1204 switch (smd->
type) {
1208 DumpContent(ctx.
js, cd);
1220 jb_open_object(ctx.
js,
"prefilter");
1227 jb_set_string(ctx.
js,
"buffer", name);
1229 jb_set_string(ctx.
js,
"name", mname);
1241 jb_set_object(ctx.
js,
"notes", ctx.
js_notes);
1247 const char *filename =
"rules.json";
1249 char json_path[PATH_MAX] =
"";
1250 snprintf(json_path,
sizeof(json_path),
"%s/%s%s", log_dir,
1254 FILE *fp = fopen(json_path,
"a");
1256 fwrite(jb_ptr(ctx.
js), jb_len(ctx.
js), 1, fp);
1270 JsonBuilder *root_jb = jb_new_object();
1274 jb_open_array(root_jb,
"buffers");
1278 char str[1024] =
"";
1282 JsonBuilder *jb = arrays[p->
sm_list];
1283 if (arrays[p->
sm_list] == NULL) {
1284 jb = arrays[p->
sm_list] = jb_new_object();
1290 jb_set_string(jb,
"name", name);
1291 jb_set_uint(jb,
"list_id", p->
sm_list);
1293 jb_open_array(jb,
"patterns");
1296 jb_start_object(jb);
1297 jb_set_string(jb,
"pattern",
str);
1299 jb_set_uint(jb,
"cnt", p->
cnt);
1300 jb_set_uint(jb,
"mpm", p->
mpm);
1301 jb_open_object(jb,
"flags");
1312 JsonBuilder *jb = arrays[i];
1319 jb_append_object(root_jb, jb);
1325 const char *filename =
"patterns.json";
1327 char json_path[PATH_MAX] =
"";
1328 snprintf(json_path,
sizeof(json_path),
"%s/%s%s", log_dir,
1332 FILE *fp = fopen(json_path,
"a");
1334 fwrite(jb_ptr(root_jb), jb_len(root_jb), 1, fp);
1355 EngineAnalysisItemsReset(ea_ctx);
1363 FatalError(
"Unable to allocate analysis scratch pad");
1373 analyzer_item->
item_id = (uint16_t)item_id;
1374 if (analyzer_item->
item_id == -1) {
1376 FatalError(
"unable to initialize engine-analysis table: detect buffer \"%s\" not "
1409 uint32_t rule_bidirectional = 0;
1410 uint32_t rule_pcre = 0;
1411 uint32_t rule_pcre_http = 0;
1412 uint32_t rule_content = 0;
1413 uint32_t rule_flow = 0;
1414 uint32_t rule_flags = 0;
1415 uint32_t rule_flow_toserver = 0;
1416 uint32_t rule_flow_toclient = 0;
1417 uint32_t rule_flow_nostream = 0;
1418 uint32_t rule_ipv4_only = 0;
1419 uint32_t rule_ipv6_only = 0;
1420 uint32_t rule_flowbits = 0;
1421 uint32_t rule_flowint = 0;
1422 uint32_t rule_content_http = 0;
1423 uint32_t rule_content_offset_depth = 0;
1424 int32_t list_id = 0;
1425 uint32_t rule_warning = 0;
1426 uint32_t stream_buf = 0;
1427 uint32_t packet_buf = 0;
1428 uint32_t file_store = 0;
1429 uint32_t warn_pcre_no_content = 0;
1430 uint32_t warn_pcre_http_content = 0;
1431 uint32_t warn_pcre_http = 0;
1432 uint32_t warn_content_http_content = 0;
1433 uint32_t warn_content_http = 0;
1434 uint32_t warn_tcp_no_flow = 0;
1435 uint32_t warn_client_ports = 0;
1436 uint32_t warn_direction = 0;
1437 uint32_t warn_method_toclient = 0;
1438 uint32_t warn_method_serverbody = 0;
1439 uint32_t warn_pcre_method = 0;
1440 uint32_t warn_encoding_norm_http_buf = 0;
1441 uint32_t warn_file_store_not_present = 0;
1442 uint32_t warn_offset_depth_pkt_stream = 0;
1443 uint32_t warn_offset_depth_alproto = 0;
1444 uint32_t warn_non_alproto_fp_for_alproto_sig = 0;
1445 uint32_t warn_no_direction = 0;
1446 uint32_t warn_both_direction = 0;
1448 EngineAnalysisItemsInit(
de_ctx->
ea);
1454 rule_bidirectional = 1;
1468 rule_ipv4_only += 1;
1471 rule_ipv6_only += 1;
1479 if (item_slot == -1) {
1487 if (item_slot == -1) {
1492 rule_content_offset_depth++;
1498 rule_content_http++;
1505 warn_encoding_norm_http_buf += 1;
1512 rule_flow_toserver = 1;
1515 rule_flow_toclient = 1;
1520 rule_flow_nostream = 1;
1545 warn_file_store_not_present = 1;
1548 if (rule_pcre > 0 && rule_content == 0 && rule_content_http == 0) {
1550 warn_pcre_no_content = 1;
1553 if (rule_content_http > 0 && rule_pcre > 0 && rule_pcre_http == 0) {
1555 warn_pcre_http_content = 1;
1561 if (rule_content > 0 && rule_content_http > 0) {
1563 warn_content_http_content = 1;
1567 warn_content_http = 1;
1569 if (rule_content == 1) {
1574 (rule_content || rule_content_http || rule_pcre || rule_pcre_http || rule_flowbits ||
1577 warn_tcp_no_flow = 1;
1579 if (rule_flow && !rule_bidirectional && (rule_flow_toserver || rule_flow_toclient)
1584 warn_client_ports = 1;
1587 if (rule_flow && rule_bidirectional && (rule_flow_toserver || rule_flow_toclient)) {
1592 if (*http_method_item_seen_ptr) {
1593 if (rule_flow && rule_flow_toclient) {
1595 warn_method_toclient = 1;
1597 if (*http_server_body_item_seen_ptr) {
1599 warn_method_serverbody = 1;
1601 if (rule_content == 0 && rule_content_http == 0 && (rule_pcre > 0 || rule_pcre_http > 0)) {
1603 warn_pcre_method = 1;
1606 if (rule_content_offset_depth > 0 && stream_buf && packet_buf) {
1608 warn_offset_depth_pkt_stream = 1;
1612 warn_offset_depth_alproto = 1;
1617 warn_non_alproto_fp_for_alproto_sig = 1;
1621 warn_no_direction += 1;
1628 warn_both_direction += 1;
1633 if (!rule_warnings_only || (rule_warnings_only && rule_warning > 0)) {
1635 fprintf(fp,
"== Sid: %u ==\n", s->
id);
1636 fprintf(fp,
"%s\n", line);
1642 fprintf(fp,
" Rule is ip only.\n");
1645 fprintf(fp,
" Rule is like ip only.\n");
1648 fprintf(fp,
" Rule is PD only.\n");
1651 fprintf(fp,
" Rule is DE only.\n");
1654 fprintf(fp,
" Rule is packet inspecting.\n");
1657 fprintf(fp,
" Rule is packet and stream inspecting.\n");
1660 fprintf(fp,
" Rule is stream inspecting.\n");
1663 fprintf(fp,
" Rule is app-layer inspecting.\n");
1666 fprintf(fp,
" Rule is App-layer TX inspecting.\n");
1672 fprintf(fp,
" Rule is IPv6 only.\n");
1674 fprintf(fp,
" Rule is IPv4 only.\n");
1676 fprintf(fp,
" Rule matches on packets.\n");
1677 if (!rule_flow_nostream && stream_buf &&
1678 (rule_flow || rule_flowbits || rule_flowint || rule_content || rule_pcre)) {
1679 fprintf(fp,
" Rule matches on reassembled stream.\n");
1684 fprintf(fp,
" Rule matches on %s buffer.\n", ai->
display_name);
1690 if (rule_content || rule_content_http || rule_pcre || rule_pcre_http) {
1692 " Rule contains %u content options, %u http content options, %u pcre "
1693 "options, and %u pcre options with http modifiers.\n",
1694 rule_content, rule_content_http, rule_pcre, rule_pcre_http);
1699 fprintf(fp,
" Prefilter on: %s.\n",
1702 EngineAnalysisRulesPrintFP(
de_ctx, s);
1706 if (warn_pcre_no_content ) {
1707 fprintf(fp,
" Warning: Rule uses pcre without a content option present.\n"
1708 " -Consider adding a content to improve performance of this "
1711 if (warn_pcre_http_content ) {
1712 fprintf(fp,
" Warning: Rule uses content options with http_* and pcre options "
1713 "without http modifiers.\n"
1714 " -Consider adding http pcre modifier.\n");
1716 else if (warn_pcre_http ) {
1717 fprintf(fp,
" Warning: Rule app layer protocol is http, but pcre options do not "
1718 "have http modifiers.\n"
1719 " -Consider adding http pcre modifiers.\n");
1721 if (warn_content_http_content ) {
1723 " Warning: Rule contains content with http_* and content without http_*.\n"
1724 " -Consider adding http content modifiers.\n");
1726 if (warn_content_http ) {
1727 fprintf(fp,
" Warning: Rule app layer protocol is http, but content options do not "
1728 "have http_* modifiers.\n"
1729 " -Consider adding http content modifiers.\n");
1731 if (rule_content == 1) {
1734 if (warn_encoding_norm_http_buf) {
1735 fprintf(fp,
" Warning: Rule may contain percent encoded content for a normalized "
1736 "http buffer match.\n");
1738 if (warn_tcp_no_flow
1740 fprintf(fp,
" Warning: TCP rule without a flow or flags option.\n"
1741 " -Consider adding flow or flags to improve performance of "
1744 if (warn_client_ports
1749 " Warning: Rule contains ports or port variables only on the client side.\n"
1750 " -Flow direction possibly inconsistent with rule.\n");
1752 if (warn_direction ) {
1753 fprintf(fp,
" Warning: Rule is bidirectional and has a flow option with a specific "
1756 if (warn_method_toclient ) {
1757 fprintf(fp,
" Warning: Rule uses content or pcre for http_method with "
1758 "flow:to_client or from_server\n");
1760 if (warn_method_serverbody ) {
1761 fprintf(fp,
" Warning: Rule uses content or pcre for http_method with content or "
1762 "pcre for http_server_body.\n");
1764 if (warn_pcre_method
1766 fprintf(fp,
" Warning: Rule uses pcre with only a http_method content; possible "
1767 "performance issue.\n");
1769 if (warn_offset_depth_pkt_stream) {
1770 fprintf(fp,
" Warning: Rule has depth"
1771 "/offset with raw content keywords. Please note the "
1772 "offset/depth will be checked against both packet "
1773 "payloads and stream. If you meant to have the offset/"
1774 "depth checked against just the payload, you can update "
1775 "the signature as \"alert tcp-pkt...\"\n");
1777 if (warn_offset_depth_alproto) {
1779 " Warning: Rule has "
1780 "offset/depth set along with a match on a specific "
1781 "app layer protocol - %d. This can lead to FNs if we "
1782 "have a offset/depth content match on a packet payload "
1783 "before we can detect the app layer protocol for the "
1787 if (warn_non_alproto_fp_for_alproto_sig) {
1788 fprintf(fp,
" Warning: Rule app layer "
1789 "protocol is http, but the fast_pattern is set on the raw "
1790 "stream. Consider adding fast_pattern over a http "
1791 "buffer for increased performance.");
1793 if (warn_no_direction) {
1794 fprintf(fp,
" Warning: Rule has no direction indicator.\n");
1796 if (warn_both_direction) {
1797 fprintf(fp,
" Warning: Rule is inspecting both the request and the response.\n");
1799 if (warn_file_store_not_present) {
1800 fprintf(fp,
" Warning: Rule requires file-store but the output file-store is not "
1803 if (rule_warning == 0) {
1804 fprintf(fp,
" No warnings for this rule.\n");