]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Handle deprecated sources in index.
authorJason Ish <jason.ish@oisf.net>
Wed, 9 Sep 2020 19:27:40 +0000 (13:27 -0600)
committerJason Ish <jason.ish@oisf.net>
Wed, 9 Sep 2020 19:27:40 +0000 (13:27 -0600)
Handle sources that have been deprecated in the index.

Deprecated sources will not be display with "list-sources" unless
the (new) --all flag is provided.

Also, warn the user if they are using a deprecated source with
the reason.

suricata/update/commands/listsources.py
suricata/update/main.py
suricata/update/util.py

index 7eb8d8af11495d9c04fff65e09fabff51f92215b..2dc931ff84a3663564acf873f79c115f7f3b6c7d 100644 (file)
@@ -31,6 +31,8 @@ def register(parser):
                         default=False, help="List all freely available sources")
     parser.add_argument("--enabled", action="store_true",
                         help="List all enabled sources")
+    parser.add_argument("--all", action="store_true",
+                        help="List all sources (including deprecated)")
     parser.set_defaults(func=list_sources)
 
 def list_sources():
@@ -80,6 +82,9 @@ def list_sources():
         is_not_free = source.get("subscribe-url")
         if free_only and is_not_free:
             continue
+        deprecated = source.get("deprecated")
+        if deprecated is not None and not config.args().all:
+            continue
         print("%s: %s" % (util.bright_cyan("Name"), util.bright_magenta(name)))
         print("  %s: %s" % (
             util.bright_cyan("Vendor"), util.bright_magenta(source["vendor"])))
@@ -103,3 +108,7 @@ def list_sources():
             print("  %s: %s" % (
                 util.bright_cyan("Subscription"),
                 util.bright_magenta(source["subscribe-url"])))
+        if "deprecated" in source:
+            print("  %s: %s" % (
+                util.orange("Deprecated"),
+                util.bright_magenta(source["deprecated"])))
index 7737b0429e65966aec33f38280ba2d974194636d..5c24aeea9de3a011b59c23a730a24d45843a418f 100644 (file)
@@ -891,6 +891,9 @@ def load_sources(suricata_version):
                     checksum = True
                 url = (index.resolve_url(name, params), http_header,
                        checksum)
+                if "deprecated" in source_config:
+                    logger.warn("Source has been deprecated: %s: %s" % (
+                        name, source_config["deprecated"]))
                 logger.debug("Resolved source %s to URL %s.", name, url[0])
             urls.append(url)
 
index a888b08c8a07b4a4b5af14e467b0ad4e8dd8d305..50788d8d9ceb7ad31ff2b96db9a9221779b7654d 100644 (file)
@@ -93,3 +93,6 @@ def bright_magenta(msg):
 
 def bright_cyan(msg):
     return "%s%s%s" % (BRIGHT_CYAN, msg, RESET)
+
+def orange(msg):
+    return "%s%s%s" % (ORANGE, msg, RESET)