Skip to content

Commit

Permalink
Added exception for missing schema and added intelmq user to the cron…
Browse files Browse the repository at this point in the history
…tab suggestion.
  • Loading branch information
elsif2 committed Nov 4, 2023
1 parent a0b34cb commit 516d534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/user/bots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ The report configuration is stored in a `shadowserver-schema.json` file download

The parser will attempt to download a schema update on startup when the *auto_update* option is enabled.

Schema downloads can also be scheduled as a cron job:
Schema downloads can also be scheduled as a cron job for the `intelmq` user:

.. code-block:: bash
Expand Down
6 changes: 5 additions & 1 deletion intelmq/bots/parsers/shadowserver/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class __Container:
__config.schema_active = __config.schema_file
__config.schema_mtime = 0.0
__config.auto_update = False
__config.test_mode = False
__config.feedname_mapping = {}
__config.filename_mapping = {}

Expand All @@ -113,6 +114,7 @@ def set_logger(logger):

def enable_test_mode(enable):
""" Set which schema to load. """
__config.test_mode = enable
if enable:
__config.schema_active = __config.schema_base
else:
Expand Down Expand Up @@ -317,8 +319,10 @@ def reload():
mtime = os.path.getmtime(__config.schema_file)
if __config.schema_mtime == mtime:
return
elif __config.test_mode:
return
else:
__config.logger.info("The schema file does not exist.")
raise ValueError("The schema file does not exist.")

if __config.schema_mtime == 0.0 and mtime == 0.0 and __config.auto_update:
update_schema()
Expand Down

0 comments on commit 516d534

Please sign in to comment.