1 //--------------------------------------------------------------------------
2 // Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 //
4 // This program is free software; you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License Version 2 as published
6 // by the Free Software Foundation.  You may not use, modify or distribute
7 // this program under any other version of the GNU General Public License.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 //--------------------------------------------------------------------------
18 // http_msg_request.h author Tom Peters <thopeter@cisco.com>
19 
20 #ifndef HTTP_MSG_REQUEST_H
21 #define HTTP_MSG_REQUEST_H
22 
23 #include "http_common.h"
24 #include "http_enum.h"
25 #include "http_msg_start.h"
26 #include "http_query_parser.h"
27 #include "http_str_to_code.h"
28 #include "http_uri.h"
29 #include "http_uri_norm.h"
30 
31 //-------------------------------------------------------------------------
32 // HttpMsgRequest class
33 //-------------------------------------------------------------------------
34 
35 class HttpMsgRequest : public HttpMsgStart
36 {
37 public:
38     HttpMsgRequest(const uint8_t* buffer, const uint16_t buf_size, HttpFlowData* session_data_,
39         HttpCommon::SourceId source_id_, bool buf_owner, snort::Flow* flow_,
40         const HttpParaList* params_);
41     ~HttpMsgRequest() override;
42     void gen_events() override;
43     void update_flow() override;
44     void publish() override;
get_method()45     const Field& get_method() { return method; }
46     const Field& get_uri();
47     const Field& get_uri_norm_classic();
48     std::string get_aux_ip();
get_http_uri()49     HttpUri* get_http_uri() { return uri; }
50     ParameterMap& get_query_params();
51     ParameterMap& get_body_params();
52 
is_webdav(HttpEnums::MethodId method)53     static bool is_webdav(HttpEnums::MethodId method)
54     {
55         if(method > HttpEnums::MethodId::METH__WEBDAV_LOW and
56            method < HttpEnums::MethodId::METH__WEBDAV_HIGH)
57         {
58             return true;
59         }
60 
61         return false;
62     }
63 
64 #ifdef REG_TEST
65     void print_section(FILE* output) override;
66 #endif
67 
68 private:
69     static const StrCode method_list[];
70 
71     void parse_start_line() override;
72     bool http_name_nocase_ok(const uint8_t* start);
73     bool handle_zero_nine();
74 
75     Field method;
76     HttpUri* uri = nullptr;
77 
78     ParameterMap* query_params = nullptr;
79     ParameterMap* body_params = nullptr;
80 };
81 
82 #endif
83 
84