]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2738 in SNORT/snort3 from ~DERAMADA/snort3:reputation_cleanup...
authorSteve Chew (stechew) <stechew@cisco.com>
Tue, 23 Feb 2021 15:49:02 +0000 (15:49 +0000)
committerSteve Chew (stechew) <stechew@cisco.com>
Tue, 23 Feb 2021 15:49:02 +0000 (15:49 +0000)
Squashed commit of the following:

commit 82c01b1afb0e625f836a7ae09ae0df5098024aff
Author: Deepak Ramadass <deramada@cisco.com>
Date:   Wed Feb 10 11:21:08 2021 -0500

    reputation: remove redundant terms

src/network_inspectors/reputation/reputation_module.cc
src/network_inspectors/reputation/reputation_parse.cc

index ba0693d276cfa7e643a6146626908a0f9ba3bfb8..44a3e4a3da6b5028f376c819ecc44da496c7ac8f 100644 (file)
@@ -54,9 +54,6 @@ static const Parameter s_params[] =
     { "blocklist", Parameter::PT_STRING, nullptr, nullptr,
       "blocklist file name with IP lists" },
 
-    { "blacklist", Parameter::PT_STRING, nullptr, nullptr,
-      "blacklist file name with IP lists" },
-
     { "list_dir", Parameter::PT_STRING, nullptr, nullptr,
       "directory for IP lists and manifest file" },
 
@@ -66,24 +63,18 @@ static const Parameter s_params[] =
     { "nested_ip", Parameter::PT_ENUM, "inner|outer|all", "inner",
       "IP to use when there is IP encapsulation" },
 
-    { "priority", Parameter::PT_ENUM, "blocklist|allowlist|blacklist|whitelist", "allowlist",
+    { "priority", Parameter::PT_ENUM, "blocklist|allowlist", "allowlist",
       "defines priority when there is a decision conflict during run-time" },
 
     { "scan_local", Parameter::PT_BOOL, nullptr, "false",
       "inspect local address defined in RFC 1918" },
 
-    { "allow", Parameter::PT_ENUM, "do_not_block|trust|unblack", "do_not_block",
+    { "allow", Parameter::PT_ENUM, "do_not_block|trust", "do_not_block",
       "specify the meaning of allowlist" },
 
-    { "white", Parameter::PT_ENUM, "do_not_block|trust|unblack", "do_not_block",
-      "specify the meaning of whitelist" },
-
     { "allowlist", Parameter::PT_STRING, nullptr, nullptr,
       "allowlist file name with IP lists" },
 
-    { "whitelist", Parameter::PT_STRING, nullptr, nullptr,
-      "whitelist file name with IP lists" },
-
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
@@ -129,7 +120,7 @@ ProfileStats* ReputationModule::get_profile() const
 
 bool ReputationModule::set(const char*, Value& v, SnortConfig*)
 {
-    if ( v.is("blocklist") or v.is("blacklist") )
+    if ( v.is("blocklist") )
         conf->blocklist_path = v.get_string();
 
     else if ( v.is("list_dir") )
@@ -142,34 +133,15 @@ bool ReputationModule::set(const char*, Value& v, SnortConfig*)
         conf->nested_ip = (NestedIP)v.get_uint8();
 
     else if ( v.is("priority") )
-    {
-        int priority = v.get_uint8() + 1;
-
-        if (priority == 3) // blacklist
-            priority = 1;
-
-        else if (priority == 4) // whitelist
-           priority = 2;
-
-        conf->priority = (IPdecision)(priority);
-
-    }
+        conf->priority = (IPdecision)(v.get_uint8() + 1);
 
     else if ( v.is("scan_local") )
         conf->scanlocal = v.get_bool();
 
-    else if ( v.is("allow") or v.is("white") )
-    {
-        int action = v.get_uint8();
-
-        if ( action == 2 ) // unblack
-            action = 0;
-
-        conf->allow_action = (AllowAction)action;
-
-    }
+    else if ( v.is("allow") )
+        conf->allow_action = (AllowAction)v.get_uint8();
 
-    else if ( v.is("allowlist") or v.is("whitelist") )
+    else if ( v.is("allowlist") )
         conf->allowlist_path = v.get_string();
 
     else
index 952b3fa2393f70a0a679a8c33bfee47301440c55..7128c77edaec5ed134f077ade99fa9854e1491eb 100644 (file)
@@ -57,7 +57,10 @@ static char block_info[] = "blocklist";
 static char allow_info[] = "allowlist";
 static char monitor_info[] = "monitorlist";
 
-#define ALLOW_TYPE_KEYWORD       "allow"
+// Support backward compatibility
+#define WHITE_TYPE_KEYWORD       "white"
+
+#define TRUST_TYPE_KEYWORD       "trust"
 #define BLOCK_TYPE_KEYWORD       "block"
 #define MONITOR_TYPE_KEYWORD     "monitor"
 
@@ -786,10 +789,15 @@ static int get_file_type(char* type_name)
 
     type_name = ignore_start_space(type_name);
 
-    if (strncasecmp(type_name, ALLOW_TYPE_KEYWORD, strlen(ALLOW_TYPE_KEYWORD)) == 0)
+    if (strncasecmp(type_name, TRUST_TYPE_KEYWORD, strlen(TRUST_TYPE_KEYWORD)) == 0)
+    {
+        type = ALLOW_LIST;
+        type_name += strlen(TRUST_TYPE_KEYWORD);
+    }
+    else if (strncasecmp(type_name, WHITE_TYPE_KEYWORD, strlen(WHITE_TYPE_KEYWORD)) == 0)
     {
         type = ALLOW_LIST;
-        type_name += strlen(ALLOW_TYPE_KEYWORD);
+        type_name += strlen(WHITE_TYPE_KEYWORD);
     }
     else if (strncasecmp(type_name, BLOCK_TYPE_KEYWORD, strlen(BLOCK_TYPE_KEYWORD)) == 0)
     {
@@ -868,8 +876,8 @@ static bool process_line_in_manifest(ListFile* list_item, const char* manifest,
             if (UNKNOWN_LIST == list_item->file_type)
             {
                 ErrorMessage(" %s(%d) => Unknown action specified (%s)."
-                    " Please specify a value: %s | %s | %s.\n", manifest, line_number, token,
-                    ALLOW_TYPE_KEYWORD, BLOCK_TYPE_KEYWORD, MONITOR_TYPE_KEYWORD);
+                    " Please specify a value: %s | %s | %s | %s.\n", manifest, line_number, token,
+                    WHITE_TYPE_KEYWORD, TRUST_TYPE_KEYWORD, BLOCK_TYPE_KEYWORD, MONITOR_TYPE_KEYWORD);
                 return false;
             }
             break;