]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1533 in SNORT/snort3 from ~BBANTWAL/snort3:gid_147 to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 5 Mar 2019 23:03:28 +0000 (18:03 -0500)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 5 Mar 2019 23:03:28 +0000 (18:03 -0500)
Squashed commit of the following:

commit 56bc9bf95cf604a1dad62e9681c3393a0ee3569c
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Mon Mar 4 10:31:24 2019 -0500

    snort2lua: comment gid 147 file rules

tools/snort2lua/rule_states/rule_gid_sid.cc

index e304d08720661f6fb43fe58b83482c489efc3fd5..951f5cbe1a156a3d6182e5706f670d17736b0ef7 100644 (file)
@@ -36,6 +36,10 @@ namespace rules
 {
 namespace
 {
+
+static const std::string removed_gids[] = { "146" , "147" };
+constexpr uint8_t MAX_GIDS = (sizeof(removed_gids) / sizeof(removed_gids[0]));
+
 class Gid : public ConversionState
 {
 public:
@@ -43,7 +47,7 @@ public:
     bool convert(std::istringstream& data_stream) override;
 
 private:
-    static bool rem_146;
+    static bool gids_seen[MAX_GIDS];
 };
 
 class Sid : public ConversionState
@@ -59,24 +63,29 @@ public:
 // Gid
 //
 
-bool Gid::rem_146 = false;
+bool Gid::gids_seen[MAX_GIDS];
 
 bool Gid::convert(std::istringstream& data_stream)
 {
     std::string gid = util::get_rule_option_args(data_stream);
     const std::string old_http_gid("120");
-    const std::string file_id = "146";
+    bool found = false;
 
-    if ( gid == file_id )
+    for ( int i = 0; i < MAX_GIDS; i++ )
     {
-        if ( !rem_146 )
+        if ( gid == removed_gids[i] )
         {
-            rule_api.add_comment("deleted all gid:" + file_id + " rules");
-            rem_146 = true;
+            if ( !gids_seen[i] )
+            {
+                rule_api.add_comment("deleted all gid:" + removed_gids[i] + " rules");
+                gids_seen[i] = true;
+            }
+            rule_api.make_rule_a_comment();
+            found = true;
+            break;
         }
-        rule_api.make_rule_a_comment();
     }
-    else if (gid.compare(old_http_gid) == 0)
+    if ( !found && gid.compare(old_http_gid) == 0)
     {
         const std::string nhi_gid("119");
         gid.assign(nhi_gid);