Skip to content

Commit

Permalink
Add warning to update sources if no index found
Browse files Browse the repository at this point in the history
Don't automatically update the sources on list-sources if it does not exist. Instead just use the bundled version.
  • Loading branch information
TharushiJay committed Oct 13, 2020
1 parent 86e530c commit 0e3d4c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions suricata/update/commands/listsources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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()
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def delete(path):
# 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"])
Expand Down

0 comments on commit 0e3d4c5

Please sign in to comment.