]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge branch 'snort2lua' of /nfs/home/jrosenba/mac into snort2lua
authorJosh <jrosenba@cisco.com>
Thu, 3 Jul 2014 19:07:20 +0000 (15:07 -0400)
committerJosh <jrosenba@cisco.com>
Thu, 3 Jul 2014 19:11:45 +0000 (15:11 -0400)
1  2 
tools/snort2lua/conversion_state.h
tools/snort2lua/data/dt_rule.cc
tools/snort2lua/preprocessor_states/pps_frag3_engine.cc

index 881eb91cd7a843bdb345d8239c66adb54990b5dd,e96019534d6e58b9a3cb125e4d226e9b60f2174f..7a78f29bc5d9906a0fa7d4ac1a8439ee28883e33
@@@ -39,24 -66,25 +66,25 @@@ public
  
  protected:
      Converter* cv;
+     LuaData* ld;
  
  #if 0
--    List of forward parsing methods. Placing these here so you don't need to
--    search through the file
++    Forward declaration fo parsing methods. Since these are all inline,
++    unable to forward declare in regular code.
  
-     inline bool eat_option(std::stringstream& stream);
+     inline bool eat_option(std::istringstream& stream);
      inline bool parse_string_option(std::string opt_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool parse_int_option(std::string opt_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool parse_curly_bracket_list(std::string list_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool parse_yn_bool_option(std::string opt_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool parse_bracketed_byte_list(std::string list_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool parse_bracketed_unsupported_list(std::string list_name,
-                                         std::stringstream& stream);
+                                         std::istringstream& stream);
      inline bool open_table_add_option(std::string table_name,
                                          std::string opt_name,
                                          std::string val);
index 0000000000000000000000000000000000000000,e816f090d5cc2a0870bd27c83823c79d9f69192b..932439be767d99ee1b84690fb9b0f5fb5f6fcedc
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,147 +1,147 @@@
 -std::ostream &operator<<( std::ostream& out, const Rule &r)
+ /*
+ ** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+  * Copyright (C) 2002-2013 Sourcefire, Inc.
+  *
+  * This program is free software; you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License Version 2 as
+  * published by the Free Software Foundation.  You may not use, modify or
+  * distribute this program under any other version of the GNU General
+  * Public License.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  */
+ // dt_rule.cc author Josh Rosenbaum <jorosenba@cisco.com>
+ #include "data/dt_rule.h"
+ Rule::Rule() :  num_hdr_data(0),
+                 is_bad_rule(false),
+                 is_comment(false)
+ {
+ }
+ Rule::~Rule(){};
+ bool Rule::add_hdr_data(std::string data)
+ {
+     if (num_hdr_data < hdr_data.size())
+     {
+         hdr_data[num_hdr_data] = data;
+         num_hdr_data++;
+         return true;
+     }
+     else
+     {
+         is_bad_rule = true;
+         return false;
+     }
+ }
+ void Rule::bad_rule()
+ {
+     is_bad_rule = true;
+ }
+ bool Rule::add_option(std::string keyword)
+ {
+     RuleOption* r = new RuleOption(keyword);
+     options.push_back(r);
+     return true;
+ }
+ bool Rule::add_option(std::string keyword, std::string data)
+ {
+     RuleOption* r = new RuleOption(keyword, data);
+     options.push_back(r);
+     return true;
+ }
+ bool Rule::add_option_before_selected(RuleOption* selected_opt,
+                                         std::string keyword,
+                                         std::string val)
+ {
+     for (auto r = options.begin(); r != options.end(); ++r)
+     {
+         if ((*r) == selected_opt)
+         {
+             RuleOption* new_opt = new RuleOption(keyword, val);
+             options.insert(r, new_opt);
+             return true;
+         }
+     }
+     // impossible to occur.  Since a rule is already selected, we found this rule once.
+     return false;
+ }
+ RuleOption* Rule::select_option(std::string opt_name)
+ {
+     for (auto r = options.rbegin(); r != options.rend(); ++r)
+         if (!opt_name.compare((*r)->get_name()))
+             return (*r);
+     return nullptr;
+ }
+ void Rule::add_comment(std::string new_comment)
+ {
+     comments.push_back("# " + new_comment);
+ }
+ void Rule::make_comment()
+ {
+     is_comment = true;
+ }
 -    if (r.is_bad_rule)
++std::ostream &operator<<( std::ostream& out, const Rule &rule)
+ {
+     bool first_line = true;
 -    for (std::string s : r.comments)
++    if (rule.is_bad_rule)
+         out << "#FAILED TO CONVERT THE FOLLOWING RULE:" << "\n";
 -    if (r.is_bad_rule || r.is_comment)
++    for (std::string s : rule.comments)
+         out << s << "\n";
 -    for(int i = 0; i < r.num_hdr_data; i++)
++    if (rule.is_bad_rule || rule.is_comment)
+         out << "#";
 -        out << r.hdr_data[i];
++    for(int i = 0; i < rule.num_hdr_data; i++)
+     {
+         if (first_line)
+             first_line = false;
+         else
+             out << " ";
 -    for (auto* r : r.options)
++        out << rule.hdr_data[i];
+     }
+     out << " (";
+     first_line = true;
++    for (auto* r : rule.options)
+     {
+         if (first_line)
+             first_line = false;
+         else
+             out << ";";
+         out << " " << (*r);
+     }
+     out << " )";
+     return out;
+ }
index baba4254817163df43cdfa3bebf9eabab39f7e67,045f3f1bdc4fe1b651df8a066ecc3fc06d149222..7b94718eb39eea1bfe40de74183b421bad06ba1c
@@@ -123,18 -123,18 +123,6 @@@ bool Frag3Engine::convert(std::istrings
      return retval;    
  }
  
--#if 0
--bool alert_test.rebuilt = false: include type:count where type is S for stream and F for frag
--enum hosts[].frag_policy = linux: defragmentation policy { first | linux | bsd | bsd_right |last | windows | solaris }
--bool normalize.ip4.df = false: clear don't frag flag
--bool packets.vlan_agnostic = false: determines whether VLAN info is used to track fragments and connections
--enum stream_ip.policy = linux: fragment reassembly policy { first | linux | bsd | bsd_right |last | windows | solaris }
--
--
--     192.1.2.7/24
--
--#endif
--
  /**************************
   *******  A P I ***********
   **************************/