From: Tharushi Jayasekara Date: Thu, 8 Oct 2020 16:46:21 +0000 (+0530) Subject: Add warning to update sources if no index found X-Git-Tag: 1.3.0rc1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb2df52d16ab54f9aac0ec872aac1eeeba3325cb;p=thirdparty%2Fsuricata-update.git Add warning to update sources if no index found Don't automatically update the sources on list-sources if it does not exist. Instead just use the bundled version. Ticket #3249. --- diff --git a/suricata/update/commands/listsources.py b/suricata/update/commands/listsources.py index 103d77b..d35c3cd 100644 --- a/suricata/update/commands/listsources.py +++ b/suricata/update/commands/listsources.py @@ -21,7 +21,6 @@ import logging from suricata.update import config from suricata.update import sources from suricata.update import util -from suricata.update.commands.updatesources import update_sources from suricata.update import exceptions logger = logging.getLogger() @@ -72,11 +71,9 @@ def list_sources(): free_only = config.args().free if not sources.source_index_exists(config): - logger.info("No source index found, running update-sources") - try: - update_sources() - except exceptions.ApplicationError as err: - logger.warning("%s: will use bundled index.", err) + logger.warning("Source index does not exist, will use bundled one.") + logger.warning("Please run suricata-update update-sources.") + index = sources.load_source_index(config) for name, source in index.get_sources().items(): is_not_free = source.get("subscribe-url") diff --git a/tests/integration_tests.py b/tests/integration_tests.py index b32e714..8970585 100755 --- a/tests/integration_tests.py +++ b/tests/integration_tests.py @@ -84,8 +84,7 @@ assert (os.path.exists(os.path.join(DATA_DIR, "update", "cache", # the index. delete(os.path.join(DATA_DIR, "update", "cache", "index.yaml")) run(common_args + ["list-sources"]) -assert (os.path.exists(os.path.join(DATA_DIR, "update", "cache", - "index.yaml"))) +assert(not os.path.exists(os.path.join(DATA_DIR, "update", "cache", "index.yaml"))) # Enable a source. run(common_args + ["enable-source", "oisf/trafficid"])