]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Make list-enabled-sources command as an option for list-sources
authorVagisha Gupta <vagisha@redpiranha.net>
Fri, 10 Apr 2020 15:08:49 +0000 (20:38 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 3 Sep 2020 15:51:33 +0000 (21:21 +0530)
Removed `list-enabled-sources` command  and made use of single
command `suricata-update list-sources --enabled` to list all
the enabled sources.

Redmine issue:
        https://redmine.openinfosecfoundation.org/issues/3248

doc/index.rst
doc/list-enabled-sources.rst [deleted file]
doc/list-sources.rst
suricata/update/commands/__init__.py
suricata/update/commands/listenabledsources.py [deleted file]
suricata/update/commands/listsources.py
suricata/update/parsers.py

index 9100d25006620081b5a65776016ea32395534a5c..a9268c9d6a5117f39539d18c5ef37f3eb0575eb6 100644 (file)
@@ -12,6 +12,5 @@ suricata-update - A Suricata Rule Update Tool
    enable-source
    disable-source
    remove-source
-   list-enabled-sources
    add-source
    check-versions
diff --git a/doc/list-enabled-sources.rst b/doc/list-enabled-sources.rst
deleted file mode 100644 (file)
index 0d8c9db..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-###########################################
-list-enabled-sources - List enabled sources
-###########################################
-
-Synopsis
-========
-
-::
-
-   suricata-update list-enabled-sources
-
-Description
-===========
-
-The ``list-enabled-sources`` command lists all the enabled sources.
-
-Options
-=======
-
-.. include:: common-options.rst
index 12161e9b9d10d8e90db9bbe7fdba2fd970ce6889..f4b36eb619d3f1666d43dc06960a1cf102986542 100644 (file)
@@ -22,3 +22,7 @@ Options
 .. option:: --free
 
    List all freely available sources.
+
+.. option:: --enabled
+
+   Lists all the enabled sources.
index 5d36fc77dfa49c922de73ffd70b85aab8c4aee0c..e75c80aeef45efc1a381ab2b30e2a31042d0ba3e 100644 (file)
@@ -14,7 +14,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
-from suricata.update.commands import listenabledsources
 from suricata.update.commands import addsource
 from suricata.update.commands import listsources
 from suricata.update.commands import updatesources
diff --git a/suricata/update/commands/listenabledsources.py b/suricata/update/commands/listenabledsources.py
deleted file mode 100644 (file)
index 5c03efb..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (C) 2017 Open Information Security Foundation
-#
-# You can copy, redistribute or modify this Program under the terms of
-# the GNU General Public License version 2 as published by the Free
-# Software Foundation.
-#
-# 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
-# version 2 along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-from __future__ import print_function
-
-import logging
-
-from suricata.update import config
-from suricata.update import sources
-
-logger = logging.getLogger()
-
-def register(parser):
-    parser.set_defaults(func=list_enabled_sources)
-
-def list_enabled_sources():
-
-    found = False
-
-    # First list sources from the main config.
-    config_sources = config.get("sources")
-    if config_sources:
-        found = True
-        print("From %s:" % (config.filename))
-        for source in config_sources:
-            print("  - %s" % (source))
-
-    # And local files.
-    local = config.get("local")
-    if local:
-        found = True
-        print("Local files/directories:")
-        for filename in local:
-            print("  - %s" % (filename))
-
-    enabled_sources = sources.get_enabled_sources()
-    if enabled_sources:
-        found = True
-        print("Enabled sources:")
-        for source in enabled_sources.values():
-            print("  - %s" % (source["source"]))
-
-    # If no enabled sources were found, log it.
-    if not found:
-        logger.warning("No enabled sources.")
index 144f24408488f7be2493d65cfb45d38de1594912..5d969147bf034b5bcc0eb3692cf96e360bc595fb 100644 (file)
@@ -29,9 +29,43 @@ logger = logging.getLogger()
 def register(parser):
     parser.add_argument("--free", action="store_true",
                         default=False, help="List all freely available sources")
+    parser.add_argument("--enabled", action="store_true",
+                        help="List all enabled sources")
     parser.set_defaults(func=list_sources)
 
 def list_sources():
+    enabled = config.args().enabled
+    if enabled:
+        found = False
+
+        # First list sources from the main config.
+        config_sources = config.get("sources")
+        if config_sources:
+            found = True
+            print("From %s:" % (config.filename))
+            for source in config_sources:
+                print("  - %s" % (source))
+
+        # And local files.
+        local = config.get("local")
+        if local:
+            found = True
+            print("Local files/directories:")
+            for filename in local:
+                print("  - %s" % (filename))
+
+        enabled_sources = sources.get_enabled_sources()
+        if enabled_sources:
+            found = True
+            print("Enabled sources:")
+            for source in enabled_sources.values():
+                print("  - %s" % (source["source"]))
+
+        # If no enabled sources were found, log it.
+        if not found:
+            logger.warning("No enabled sources.")
+        return 0
+
     free_only = config.args().free
     if not sources.source_index_exists(config):
         logger.info("No source index found, running update-sources")
index d76acd489ad5c671926f571722fcf34a57840327..76882919fc05a735052ce8d2e29e51d0b17e09b1 100644 (file)
@@ -185,8 +185,6 @@ def parse_update(subparsers, global_parser):
 def parse_commands(subparsers, global_parser):
     commands.listsources.register(subparsers.add_parser(
         "list-sources", parents=[global_parser]))
-    commands.listenabledsources.register(subparsers.add_parser(
-        "list-enabled-sources", parents=[global_parser]))
     commands.addsource.register(subparsers.add_parser(
         "add-source", parents=[global_parser]))
     commands.updatesources.register(subparsers.add_parser(
@@ -223,7 +221,6 @@ def parse_arg():
     enable-source              Enable a source from the index
     disable-source             Disable an enabled source
     remove-source              Remove an enabled or disabled source
-    list-enabled-sources       List all enabled sources
     add-source                 Add a new source by URL
     check-versions             Check version of suricata-update
 """