From: Josh Date: Thu, 3 Jul 2014 19:07:20 +0000 (-0400) Subject: Merge branch 'snort2lua' of /nfs/home/jrosenba/mac into snort2lua X-Git-Tag: 3.0.0-233~1175^2~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=005ed2618ca8544505be8925cefbc1ec2279f109;p=thirdparty%2Fsnort3.git Merge branch 'snort2lua' of /nfs/home/jrosenba/mac into snort2lua --- 005ed2618ca8544505be8925cefbc1ec2279f109 diff --cc tools/snort2lua/conversion_state.h index 881eb91cd,e96019534..7a78f29bc --- a/tools/snort2lua/conversion_state.h +++ b/tools/snort2lua/conversion_state.h @@@ -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); diff --cc tools/snort2lua/data/dt_rule.cc index 000000000,e816f090d..932439be7 mode 000000,100644..100644 --- a/tools/snort2lua/data/dt_rule.cc +++ b/tools/snort2lua/data/dt_rule.cc @@@ -1,0 -1,147 +1,147 @@@ + /* + ** 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 + + + #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; + } + -std::ostream &operator<<( std::ostream& out, const Rule &r) ++std::ostream &operator<<( std::ostream& out, const Rule &rule) + { + bool first_line = true; + + - if (r.is_bad_rule) ++ if (rule.is_bad_rule) + out << "#FAILED TO CONVERT THE FOLLOWING RULE:" << "\n"; + - for (std::string s : r.comments) ++ for (std::string s : rule.comments) + out << s << "\n"; + - if (r.is_bad_rule || r.is_comment) ++ if (rule.is_bad_rule || rule.is_comment) + out << "#"; + - for(int i = 0; i < r.num_hdr_data; i++) ++ for(int i = 0; i < rule.num_hdr_data; i++) + { + if (first_line) + first_line = false; + else + out << " "; + - out << r.hdr_data[i]; ++ out << rule.hdr_data[i]; + } + + out << " ("; + first_line = true; + - for (auto* r : r.options) ++ for (auto* r : rule.options) + { + if (first_line) + first_line = false; + else + out << ";"; + out << " " << (*r); + } + + out << " )"; + + + return out; + } diff --cc tools/snort2lua/preprocessor_states/pps_frag3_engine.cc index baba42548,045f3f1bd..7b94718eb --- a/tools/snort2lua/preprocessor_states/pps_frag3_engine.cc +++ b/tools/snort2lua/preprocessor_states/pps_frag3_engine.cc @@@ -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 *********** **************************/