]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1185 in SNORT/snort3 from snort2lua_ftp_data3 to master
authorHui Cao (huica) <huica@cisco.com>
Tue, 10 Apr 2018 14:56:18 +0000 (10:56 -0400)
committerHui Cao (huica) <huica@cisco.com>
Tue, 10 Apr 2018 14:56:18 +0000 (10:56 -0400)
Squashed commit of the following:

commit f1b8fe018aba47bc898ffbc1560eccad2fcec361
Author: Steve Chew <stechew@cisco.com>
Date:   Tue Apr 10 09:39:16 2018 -0400

    Snort2lua: Add ftp_data to multiple files when needed, once per file.

tools/snort2lua/helpers/converter.h
tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc

index 4fa2d9d7575524806297e5f5729d18bcb824ac49..162c8d3e8a913313f4cc88c345d24a3ccc058de6 100644 (file)
@@ -111,6 +111,12 @@ public:
     inline RuleApi& get_rule_api()
     { return rule_api; }
 
+    bool added_ftp_data() const
+    { return ftp_data_is_added; }
+
+    void set_added_ftp_data()
+    { ftp_data_is_added = true; }
+
 private:
     static std::string ips_pattern;
     static bool parse_includes;
@@ -119,6 +125,8 @@ private:
     static bool empty_args;
     static bool bind_wizard;
 
+    bool ftp_data_is_added = false;
+
     DataApi data_api;
 
     // For the top-level file in an include chain.
index 96deb6ea589306c5d709a88078ade89204860559..bbefc22e16ec78994cd411b57e11f830ba0e7755 100644 (file)
@@ -54,7 +54,6 @@ private:
 
     static const int command_default_len = -1;
     static int ftpserver_binding_id;
-    static bool added_ftp_data;
     std::vector<Command> commands;
 
     bool parse_alt_max_cmd(std::istringstream& data_stream);
@@ -113,7 +112,6 @@ private:
 }  // namespace
 
 int FtpServer::ftpserver_binding_id = 1;
-bool FtpServer::added_ftp_data = false;
 
 std::vector<FtpServer::Command>::iterator FtpServer::get_command(
     const std::string& cmd_name,
@@ -326,7 +324,7 @@ bool FtpServer::convert(std::istringstream& data_stream)
     bool ports_set = false;
 
     // Set up ftp_data whenever we have ftp_server configured.
-    if(!added_ftp_data)
+    if(!cv.added_ftp_data())
     {
         auto& ftp_data_bind = cv.make_binder();
         ftp_data_bind.set_use_type("ftp_data");
@@ -335,7 +333,7 @@ bool FtpServer::convert(std::istringstream& data_stream)
         table_api.open_table("ftp_data");
         table_api.close_table();
 
-        added_ftp_data = true;
+        cv.set_added_ftp_data();
     }
 
     auto& bind = cv.make_binder();