From: Vagisha Gupta Date: Wed, 10 Jul 2019 05:31:01 +0000 (+0530) Subject: Log a warning if index is old X-Git-Tag: 1.1.0rc1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d68ab5dcf3762123322666d2690e386fe4de796;p=thirdparty%2Fsuricata-update.git Log a warning if index is old If the index is older than 2 weeks, logged a warning that the index is old and user needs to update it by running `suricata-update update-sources`. --- diff --git a/suricata/update/main.py b/suricata/update/main.py index 60881ee..254b5e9 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -88,6 +88,8 @@ DEFAULT_SURICATA_VERSION = "4.0.0" # single file concatenating all input rule files together. DEFAULT_OUTPUT_RULE_FILENAME = "suricata.rules" +INDEX_EXPIRATION_TIME = 60 * 60 * 24 * 14 + class AllRuleMatcher(object): """Matcher object to match all rules. """ @@ -977,6 +979,11 @@ def load_sources(suricata_version): if not os.path.exists(index_filename): logger.warning("No index exists, will use bundled index.") logger.warning("Please run suricata-update update-sources.") + if os.path.exists(index_filename) and time.time() - \ + os.stat(index_filename).st_mtime > INDEX_EXPIRATION_TIME: + logger.warning( + "Source index is older than 2 weeks. " + "Please update with suricata-update update-sources.") index = sources.Index(index_filename) for (name, source) in enabled_sources.items():