const Field& HttpMsgSection::get_classic_buffer(const HttpBufferInfo& buf)
{
- // buffer_side replaces source_id for buffers that support the request option
+ // buffer_side replaces source_id for rule options that support the request option
const SourceId buffer_side = (buf.form & FORM_REQUEST) ? SRC_CLIENT : source_id;
switch (buf.type)
int32_t HttpMsgSection::get_num_headers(const HttpBufferInfo& buf) const
{
- // buffer_side replaces source_id for buffers that support the request option
+ // buffer_side replaces source_id for rule options that support the request option
const SourceId buffer_side = (buf.form & FORM_REQUEST) ? SRC_CLIENT : source_id;
const HttpMsgHeadShared* const head = (buf.type == HTTP_RANGE_NUM_TRAILERS) ?
return head->get_num_headers();
}
+int32_t HttpMsgSection::get_max_header_line(const HttpBufferInfo& buf) const
+{
+ // buffer_side replaces source_id for rule options that support the request option
+ const SourceId buffer_side = (buf.form & FORM_REQUEST) ? SRC_CLIENT : source_id;
+
+ const HttpMsgHeadShared* const head = (buf.type == HTTP_RANGE_MAX_TRAILER_LINE) ?
+ (HttpMsgHeadShared*)trailer[buffer_side]:
+ (HttpMsgHeadShared*)header[buffer_side] ;
+ if (head == nullptr)
+ return HttpCommon::STAT_NO_SOURCE;
+
+ return head->get_max_header_line();
+}
+
int32_t HttpMsgSection::get_num_cookies(const HttpBufferInfo& buf) const
{
// buffer_side replaces source_id for rule options that support the request option
VersionId HttpMsgSection::get_version_id(const HttpBufferInfo& buf) const
{
- // buffer_side replaces source_id for buffers that support the request option
+ // buffer_side replaces source_id for rule options that support the request option
const SourceId buffer_side = (buf.form & FORM_REQUEST) ? SRC_CLIENT : source_id;
HttpMsgStart* start = (buffer_side == SRC_CLIENT) ?
(HttpMsgStart*)request : (HttpMsgStart*)status;
}
//-------------------------------------------------------------------------
-// num_header_lines
+// max_header_line
//-------------------------------------------------------------------------
#undef IPS_OPT
-#define IPS_OPT "http_num_headers"
+#define IPS_OPT "http_max_header_line"
#undef IPS_HELP
-#define IPS_HELP "rule option to perform range check on number of headers"
+#define IPS_HELP "rule option to perform range check on longest header line"
-static const Parameter http_num_hdrs_params[] =
+static const Parameter http_max_header_line_params[] =
{
{ "~range", Parameter::PT_INTERVAL, "0:65535", nullptr,
- "check that number of headers of current buffer are in given range" },
+ "check that longest line of current header is in given range" },
{ "request", Parameter::PT_IMPLIED, nullptr, nullptr,
"match against the version from the request message even when examining the response" },
- { "with_header", Parameter::PT_IMPLIED, nullptr, nullptr,
- "this rule is limited to examining HTTP message headers" },
- { "with_body", Parameter::PT_IMPLIED, nullptr, nullptr,
- "parts of this rule examine HTTP message body" },
- { "with_trailer", Parameter::PT_IMPLIED, nullptr, nullptr,
- "parts of this rule examine HTTP message trailers" },
{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
-static Module* num_hdrs_mod_ctor()
+static Module* max_header_line_mod_ctor()
{
- return new HttpNumRuleOptModule<HTTP_RANGE_NUM_HDRS, IS_FLEX_HEADER>(IPS_OPT, IPS_HELP,
- http_num_hdrs_params);
+ return new HttpNumRuleOptModule<HTTP_RANGE_MAX_HEADER_LINE, IS_FLEX_HEADER>(IPS_OPT, IPS_HELP,
+ http_max_header_line_params);
}
-static const IpsApi num_headers_api =
+static const IpsApi max_header_line_api =
{
{
PT_IPS_OPTION,
API_OPTIONS,
IPS_OPT,
IPS_HELP,
- num_hdrs_mod_ctor,
+ max_header_line_mod_ctor,
HttpRangeRuleOptModule::mod_dtor
},
OPT_TYPE_DETECTION,
nullptr,
nullptr,
nullptr,
- HttpNumIpsOption<&HttpInspect::http_get_num_headers>::opt_ctor,
+ HttpNumIpsOption<&HttpInspect::http_get_max_header_line>::opt_ctor,
HttpRangeIpsOption::opt_dtor,
nullptr
};
//-------------------------------------------------------------------------
-// num_trailer_lines
+// max_trailer_line
//-------------------------------------------------------------------------
#undef IPS_OPT
-#define IPS_OPT "http_num_trailers"
+#define IPS_OPT "http_max_trailer_line"
#undef IPS_HELP
-#define IPS_HELP "rule option to perform range check on number of trailers"
+#define IPS_HELP "rule option to perform range check on longest trailer line"
-static Module* num_trailers_mod_ctor()
+static const Parameter http_max_trailer_line_params[] =
{
- return new HttpNumRuleOptModule<HTTP_RANGE_NUM_TRAILERS, IS_TRAILER>(IPS_OPT, IPS_HELP,
- http_num_hdrs_params);
+ { "~range", Parameter::PT_INTERVAL, "0:65535", nullptr,
+ "check that longest line of current trailer is in given range" },
+ { "request", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "match against the version from the request message even when examining the response" },
+ { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
+};
+
+static Module* max_trailer_line_mod_ctor()
+{
+ return new HttpNumRuleOptModule<HTTP_RANGE_MAX_TRAILER_LINE, IS_TRAILER>(IPS_OPT, IPS_HELP,
+ http_max_trailer_line_params);
}
-static const IpsApi num_trailers_api =
+static const IpsApi max_trailer_line_api =
{
{
PT_IPS_OPTION,
API_OPTIONS,
IPS_OPT,
IPS_HELP,
- num_trailers_mod_ctor,
+ max_trailer_line_mod_ctor,
HttpRangeRuleOptModule::mod_dtor
},
OPT_TYPE_DETECTION,
nullptr,
nullptr,
nullptr,
- HttpNumIpsOption<&HttpInspect::http_get_num_headers>::opt_ctor,
+ HttpNumIpsOption<&HttpInspect::http_get_max_header_line>::opt_ctor,
HttpRangeIpsOption::opt_dtor,
nullptr
};
nullptr
};
+//-------------------------------------------------------------------------
+// num_header_lines
+//-------------------------------------------------------------------------
+#undef IPS_OPT
+#define IPS_OPT "http_num_headers"
+#undef IPS_HELP
+#define IPS_HELP "rule option to perform range check on number of headers"
+
+static const Parameter http_num_hdrs_params[] =
+{
+ { "~range", Parameter::PT_INTERVAL, "0:65535", nullptr,
+ "check that number of headers of current buffer are in given range" },
+ { "request", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "match against the version from the request message even when examining the response" },
+ { "with_header", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "this rule is limited to examining HTTP message headers" },
+ { "with_body", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "parts of this rule examine HTTP message body" },
+ { "with_trailer", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "parts of this rule examine HTTP message trailers" },
+ { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
+};
+
+static Module* num_hdrs_mod_ctor()
+{
+ return new HttpNumRuleOptModule<HTTP_RANGE_NUM_HDRS, IS_FLEX_HEADER>(IPS_OPT, IPS_HELP,
+ http_num_hdrs_params);
+}
+
+static const IpsApi num_headers_api =
+{
+ {
+ PT_IPS_OPTION,
+ sizeof(IpsApi),
+ IPSAPI_VERSION,
+ 1,
+ API_RESERVED,
+ API_OPTIONS,
+ IPS_OPT,
+ IPS_HELP,
+ num_hdrs_mod_ctor,
+ HttpRangeRuleOptModule::mod_dtor
+ },
+ OPT_TYPE_DETECTION,
+ 0, PROTO_BIT__TCP,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ HttpNumIpsOption<&HttpInspect::http_get_num_headers>::opt_ctor,
+ HttpRangeIpsOption::opt_dtor,
+ nullptr
+};
+
+//-------------------------------------------------------------------------
+// num_trailer_lines
+//-------------------------------------------------------------------------
+#undef IPS_OPT
+#define IPS_OPT "http_num_trailers"
+#undef IPS_HELP
+#define IPS_HELP "rule option to perform range check on number of trailers"
+
+static Module* num_trailers_mod_ctor()
+{
+ return new HttpNumRuleOptModule<HTTP_RANGE_NUM_TRAILERS, IS_TRAILER>(IPS_OPT, IPS_HELP,
+ http_num_hdrs_params);
+}
+
+static const IpsApi num_trailers_api =
+{
+ {
+ PT_IPS_OPTION,
+ sizeof(IpsApi),
+ IPSAPI_VERSION,
+ 1,
+ API_RESERVED,
+ API_OPTIONS,
+ IPS_OPT,
+ IPS_HELP,
+ num_trailers_mod_ctor,
+ HttpRangeRuleOptModule::mod_dtor
+ },
+ OPT_TYPE_DETECTION,
+ 0, PROTO_BIT__TCP,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ HttpNumIpsOption<&HttpInspect::http_get_num_headers>::opt_ctor,
+ HttpRangeIpsOption::opt_dtor,
+ nullptr
+};
+
//-------------------------------------------------------------------------
// plugins
//-------------------------------------------------------------------------
+const BaseApi* ips_http_max_header_line = &max_header_line_api.base;
+const BaseApi* ips_http_max_trailer_line = &max_trailer_line_api.base;
+const BaseApi* ips_http_num_cookies = &num_cookies_api.base;
const BaseApi* ips_http_num_headers = &num_headers_api.base;
const BaseApi* ips_http_num_trailers = &num_trailers_api.base;
-const BaseApi* ips_http_num_cookies = &num_cookies_api.base;