]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1403 in SNORT/snort3 from nuke_146 to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 26 Oct 2018 14:25:09 +0000 (10:25 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 26 Oct 2018 14:25:09 +0000 (10:25 -0400)
Squashed commit of the following:

commit bf14cb08701526cdba5040dffdf5322b4c67da5e
Author: Russ Combs <rucombs@cisco.com>
Date:   Thu Oct 25 12:40:34 2018 -0400

    snort2lua: tweak for style consistency

commit ca3fb174a817679df1f2085c91aacced499d86cc
Author: Russ Combs <rucombs@cisco.com>
Date:   Thu Oct 25 12:40:13 2018 -0400

    snort2lua: comment out deleted gid 146 rules

tools/snort2lua/data/dt_rule_api.cc
tools/snort2lua/rule_states/rule_gid_sid.cc

index e8bf89967bcc5478f8791f5892078d2953a6e5b9..b0443e6f086e8beca193c2b292be4ecdc6b4d21e 100644 (file)
 std::size_t RuleApi::error_count = 0;
 std::string RuleApi::remark;
 
-std::set<GidSid> RuleApi::address_anomaly_rules = {
-                                            {"116", "403"},
-                                            {"116", "411"},
-                                            {"116", "412"},
-                                            {"129", "9"},
-                                            {"129", "10"},
-                                        };
-
-RuleApi::RuleApi()
-    :   curr_rule(nullptr),
+std::set<GidSid> RuleApi::address_anomaly_rules =
+{
+    {"116", "403"},
+    {"116", "411"},
+    {"116", "412"},
+    {"129", "9"},
+    {"129", "10"},
+};
+
+RuleApi::RuleApi() :
+    curr_rule(nullptr),
     curr_data_bad(false)
 {
     bad_rules = new Comments(start_bad_rules, 0,
@@ -106,9 +107,10 @@ void RuleApi::make_rule_a_comment()
 bool RuleApi::enable_addr_anomaly_detection()
 {
     if (curr_rule != nullptr)
-        return address_anomaly_rules.count({curr_rule->get_option("gid"),
-                                          curr_rule->get_option("sid")}) != 0;
-
+    {
+        return address_anomaly_rules.count(
+            { curr_rule->get_option("gid"), curr_rule->get_option("sid") }) != 0;
+    }
     return false;
 }
 
index 66114b4db89711de2ed175daeb9c4640d12a886d..f10abe78b5ccab6b2011c60a632e9349e29ffab9 100644 (file)
@@ -41,6 +41,9 @@ class Gid : public ConversionState
 public:
     Gid(Converter& c) : ConversionState(c) { }
     bool convert(std::istringstream& data_stream) override;
+
+private:
+    static bool rem_146;
 };
 
 class Sid : public ConversionState
@@ -56,12 +59,24 @@ public:
 // Gid
 //
 
+bool Gid::rem_146 = false;
+
 bool Gid::convert(std::istringstream& data_stream)
 {
     std::string gid = util::get_rule_option_args(data_stream);
-
     const std::string old_http_gid("120");
-    if (gid.compare(old_http_gid) == 0)
+    const std::string file_id = "146";
+
+    if ( gid == file_id )
+    {
+        if ( !rem_146 )
+        {
+            rule_api.add_comment("deleted all gid:" + file_id + " rules");
+            rem_146 = true;
+        }
+        rule_api.make_rule_a_comment();
+    }
+    else if (gid.compare(old_http_gid) == 0)
     {
         const std::string nhi_gid("119");
         gid.assign(nhi_gid);
@@ -75,7 +90,6 @@ bool Gid::convert(std::istringstream& data_stream)
             rule_api.update_option("sid", sid);
         }
     }
-
     rule_api.add_option("gid", gid);
     return set_next_rule_state(data_stream);
 }