From: Shivani Bhardwaj Date: Mon, 24 Aug 2020 08:30:25 +0000 (+0530) Subject: allow re-enabling disabled sources X-Git-Tag: 1.2.0rc2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49f39d518e17a4b8460c436bdbb84669979459b9;p=thirdparty%2Fsuricata-update.git allow re-enabling disabled sources Closes redmine ticket 3843. --- diff --git a/suricata/update/commands/enablesource.py b/suricata/update/commands/enablesource.py index 45a8598..53bb68a 100644 --- a/suricata/update/commands/enablesource.py +++ b/suricata/update/commands/enablesource.py @@ -62,7 +62,7 @@ def enable_source(): source_index = sources.load_source_index(config) - if not name in source_index.get_sources(): + if not name in source_index.get_sources() and not name in sources.get_sources_from_dir(): logger.error("Unknown source: %s", name) return 1 diff --git a/suricata/update/sources.py b/suricata/update/sources.py index 1cef09b..651a4d6 100644 --- a/suricata/update/sources.py +++ b/suricata/update/sources.py @@ -44,6 +44,14 @@ def get_source_directory(): def get_index_filename(): return os.path.join(config.get_cache_dir(), SOURCE_INDEX_FILENAME) +def get_sources_from_dir(): + """Return names of all files existing in the sources dir""" + source_dir = get_source_directory() + source_names = [] + (_, _, fnames) = next(os.walk(source_dir)) + source_names = [".".join(fname.split('.')[:-1]) for fname in fnames] + return source_names + def get_enabled_source_filename(name): return os.path.join(get_source_directory(), "%s.yaml" % ( safe_filename(name)))