From: Jason Ish Date: Wed, 9 Sep 2020 19:27:40 +0000 (-0600) Subject: Handle deprecated sources in index. X-Git-Tag: 1.2.0rc2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1abaefb96bef6e043cd545e9a42d81b98ef3fbcd;p=thirdparty%2Fsuricata-update.git Handle deprecated sources in index. 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. --- diff --git a/suricata/update/commands/listsources.py b/suricata/update/commands/listsources.py index 7eb8d8a..2dc931f 100644 --- a/suricata/update/commands/listsources.py +++ b/suricata/update/commands/listsources.py @@ -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"]))) diff --git a/suricata/update/main.py b/suricata/update/main.py index 7737b04..5c24aee 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -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) diff --git a/suricata/update/util.py b/suricata/update/util.py index a888b08..50788d8 100644 --- a/suricata/update/util.py +++ b/suricata/update/util.py @@ -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)