Skip to content

Commit 79cae29

Browse files
committed
ENH: new parameter autoupdate_cached_database
New parameter `autoupdate_cached_database` to disable automatic updates (downloads) of cached databases
1 parent cef39c1 commit 79cae29

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ CHANGELOG
8080
- `intelmq.bots.experts.asn_lookup.expert`: Fixes update-database script on the last few days of a month (PR#2121 by Filip Pokorný, fixes #2088).
8181
- `intelmq.bots.experts.threshold.expert`: Correctly use the standard parameter `redis_cache_ttl` instead of the previously used parameter `timeout` (PR#2155 by Karl-Johan Karlsson).
8282
- `intelmq.bots.experts.jinja2.expert`: Lift restriction on requirement jinja2 < 3 (PR#2158 by Sebastian Wagner).
83+
- `intelmq.bots.experts.asn_lookup.expert`, `intelmq.bots.experts.domain_suffix.expert`, `intelmq.bots.experts.maxmind_geoip.expert`, `intelmq.bots.experts.recordedfuture_iprisk.expert`, `intelmq.bots.experts.tor_nodes.expert`: New parameter `autoupdate_cached_database` to disable automatic updates (downloads) of cached databases (PR#2180 by Sebastian Wagner).
8384

8485
#### Outputs
8586
- Removed `intelmq.bots.outputs.postgresql`: this bot was marked as deprecated in 2019 announced to be removed in version 3 of IntelMQ (PR#2045 by Birger Schacht).

intelmq/bots/experts/asn_lookup/expert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class ASNLookupExpertBot(ExpertBot):
2727
"""Add ASN and netmask information from a local BGP dump"""
2828
database = None # TODO: should be pathlib.Path
29+
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
2930

3031
def init(self):
3132
if pyasn is None:
@@ -96,15 +97,15 @@ def update_database(cls, verbose=False):
9697
runtime_conf = get_bots_settings()
9798
try:
9899
for bot in runtime_conf:
99-
if runtime_conf[bot]["module"] == __name__:
100+
if runtime_conf[bot]["module"] == __name__ and runtime_conf[bot]['parameters'].get('autoupdate_cached_database', True):
100101
bots[bot] = runtime_conf[bot]["parameters"]["database"]
101102

102103
except KeyError as e:
103104
sys.exit(f"Database update failed. Your configuration of {bot} is missing key {e}.")
104105

105106
if not bots:
106107
if verbose:
107-
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf.")
108+
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf or database update disabled with parameter 'autoupdate_cached_database'.")
108109
sys.exit(0)
109110

110111
# we only need to import now. If there are no asn_lookup bots, this dependency does not need to be installed

intelmq/bots/experts/domain_suffix/expert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class DomainSuffixExpertBot(ExpertBot):
3232
"""Extract the domain suffix from a domain and save it in the the domain_suffix field. Requires a local file with valid domain suffixes"""
3333
field: str = None
3434
suffix_file: str = None # TODO: should be pathlib.Path
35+
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
3536

3637
def init(self):
3738
if self.field not in ALLOWED_FIELDS:
@@ -84,15 +85,15 @@ def update_database(cls, verbose=False):
8485
runtime_conf = get_bots_settings()
8586
try:
8687
for bot in runtime_conf:
87-
if runtime_conf[bot]["module"] == __name__:
88+
if runtime_conf[bot]["module"] == __name__ and runtime_conf[bot]['parameters'].get('autoupdate_cached_database', True):
8889
bots[bot] = runtime_conf[bot]["parameters"]["suffix_file"]
8990

9091
except KeyError as e:
9192
sys.exit(f"Database update failed. Your configuration of {bot} is missing key {e}.")
9293

9394
if not bots:
9495
if verbose:
95-
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf.")
96+
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf or database update disabled with parameter 'autoupdate_cached_database'.")
9697
sys.exit(0)
9798

9899
# we only need to import now. If there are no asn_lookup bots, this dependency does not need to be installed

intelmq/bots/experts/maxmind_geoip/expert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GeoIPExpertBot(ExpertBot):
3131
license_key: str = "<insert Maxmind license key>"
3232
overwrite: bool = False
3333
use_registered: bool = False
34+
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
3435

3536
def init(self):
3637
if geoip2 is None:
@@ -113,7 +114,7 @@ def update_database(cls, verbose=False):
113114
runtime_conf = get_bots_settings()
114115
try:
115116
for bot in runtime_conf:
116-
if runtime_conf[bot]["module"] == __name__:
117+
if runtime_conf[bot]["module"] == __name__ and runtime_conf[bot]['parameters'].get('autoupdate_cached_database', True):
117118
license_key = runtime_conf[bot]["parameters"]["license_key"]
118119
bots[bot] = runtime_conf[bot]["parameters"]["database"]
119120

@@ -129,7 +130,7 @@ def update_database(cls, verbose=False):
129130

130131
if not bots:
131132
if verbose:
132-
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf.")
133+
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf or database update disabled with parameter 'autoupdate_cached_database'.")
133134
sys.exit(0)
134135

135136
# we only need to import now, if there are no maxmind_geoip bots, this dependency does not need to be installed

intelmq/bots/experts/recordedfuture_iprisk/expert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class RecordedFutureIPRiskExpertBot(ExpertBot):
2424
api_token: str = "<insert Recorded Future IPRisk API token>"
2525
database: str = "/opt/intelmq/var/lib/bots/recordedfuture_iprisk/rfiprisk.dat" # TODO: should be pathlib.Path
2626
overwrite: bool = False
27+
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
2728

2829
_database = dict()
2930

@@ -77,7 +78,7 @@ def update_database(cls, verbose=False):
7778
runtime_conf = get_bots_settings()
7879
try:
7980
for bot in runtime_conf:
80-
if runtime_conf[bot]["module"] == __name__:
81+
if runtime_conf[bot]["module"] == __name__ and runtime_conf[bot]['parameters'].get('autoupdate_cached_database', True):
8182
api_token = runtime_conf[bot]["parameters"]["api_token"]
8283
bots[bot] = runtime_conf[bot]["parameters"]["database"]
8384

@@ -86,7 +87,7 @@ def update_database(cls, verbose=False):
8687

8788
if not bots:
8889
if verbose:
89-
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf.")
90+
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf or database update disabled with parameter 'autoupdate_cached_database'.")
9091
sys.exit(0)
9192

9293
try:

intelmq/bots/experts/tor_nodes/expert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TorExpertBot(ExpertBot):
2020
"""Check if the IP address is a Tor Exit Node based on a local database of TOR nodes"""
2121
database: str = "/opt/intelmq/var/lib/bots/tor_nodes/tor_nodes.dat" # TODO: pathlib.Path
2222
overwrite: bool = False
23+
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
2324

2425
_database = set()
2526

@@ -78,15 +79,15 @@ def update_database(cls, verbose=False):
7879
runtime_conf = get_bots_settings()
7980
try:
8081
for bot in runtime_conf:
81-
if runtime_conf[bot]["module"] == __name__:
82+
if runtime_conf[bot]["module"] == __name__ and runtime_conf[bot]['parameters'].get('autoupdate_cached_database', True):
8283
bots[bot] = runtime_conf[bot]["parameters"]["database"]
8384

8485
except KeyError as e:
8586
sys.exit(f"Database update failed. Your configuration of {bot} is missing key {e}.")
8687

8788
if not bots:
8889
if verbose:
89-
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf.")
90+
print(f"Database update skipped. No bots of type {__name__} present in runtime.conf or database update disabled with parameter 'autoupdate_cached_database'.")
9091
sys.exit(0)
9192

9293
try:

0 commit comments

Comments
 (0)