Skip to content

Commit 45155b7

Browse files
authored
Merge pull request #2587 from sebix/bots-varlibpaths
pkg: replace hardcoded /opt/intelmq/ paths with variables
2 parents a5f2f9c + cc1437e commit 45155b7

File tree

14 files changed

+33
-18
lines changed

14 files changed

+33
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o
3333
### Documentation
3434

3535
### Packaging
36+
- Replace `/opt/intelmq` example paths in bots with variable `VAR_STATE_PATH` for correct paths in LSB-path setups like with packages (PR#2587 by Sebastian Wagner).
3637

3738
### Tests
3839

debian/control

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Build-Depends: debhelper (>= 4.1.16),
2222
quilt,
2323
rsync,
2424
safe-rm,
25-
python3-pytest-cov
25+
python3-pytest-cov,
26+
findutils,
27+
sed
2628
X-Python3-Version: >= 3.7
2729
Standards-Version: 3.9.6
2830
Homepage: https://github.com/certtools/intelmq/

debian/sedfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
s/opt\/intelmq\/var\/run/var\/run\/intelmq/g
2-
s/opt\/intelmq\/var\/log/var\/log\/intelmq/g
3-
s/opt\/intelmq\/var\/lib/var\/lib\/intelmq/g
4-
s/opt\/intelmq\/etc\//etc\/intelmq\//g
5-
s/opt\/intelmq/etc\/intelmq/g
1+
s%opt/intelmq/var/run%var/run/intelmq%g
2+
s%opt/intelmq/var/log%var/log/intelmq%g
3+
s%opt/intelmq/var/lib%var/lib/intelmq%g
4+
s%opt/intelmq/etc%etc/intelmq%g
5+
s%opt/intelmq%etc/intelmq%g

intelmq/bots/experts/domain_valid/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import requests.exceptions
1818

19+
from intelmq import VAR_STATE_PATH
1920
from intelmq.lib.bot import ExpertBot
2021
from intelmq.lib.exceptions import MissingDependencyError, ConfigurationError
2122
from intelmq.lib.utils import get_bots_settings, create_request_session
@@ -24,7 +25,7 @@
2425

2526
class DomainValidExpertBot(ExpertBot):
2627
domain_field: str = 'source.fqdn'
27-
tlds_domains_list: str = '/opt/intelmq/var/lib/bots/domain_valid/tlds-alpha-by-domain.txt'
28+
tlds_domains_list: str = f"{VAR_STATE_PATH}domain_valid/tlds-alpha-by-domain.txt"
2829

2930
def init(self):
3031
if validators is None:

intelmq/bots/experts/maxmind_geoip/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import requests
1515
import tarfile
1616

17+
from intelmq import VAR_STATE_PATH
1718
from intelmq.lib.bot import ExpertBot
1819
from intelmq.lib.exceptions import MissingDependencyError
1920
from intelmq.lib.utils import get_bots_settings, create_request_session
@@ -27,7 +28,7 @@
2728

2829
class GeoIPExpertBot(ExpertBot):
2930
"""Add geolocation information from a local MaxMind database to events (country, city, longitude, latitude)"""
30-
database: str = "/opt/intelmq/var/lib/bots/maxmind_geoip/GeoLite2-City.mmdb" # TODO: should be pathlib.Path
31+
database: str = f"{VAR_STATE_PATH}maxmind_geoip/GeoLite2-City.mmdb" # TODO: should be pathlib.Path
3132
license_key: str = "<insert Maxmind license key>"
3233
overwrite: bool = False
3334
use_registered: bool = False

intelmq/bots/experts/modify/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import sys
1111

12+
from intelmq import VAR_STATE_PATH
1213
from intelmq.lib.bot import ExpertBot
1314
from intelmq.lib.utils import load_configuration
1415

@@ -37,7 +38,7 @@ def __getitem__(self, key):
3738
class ModifyExpertBot(ExpertBot):
3839
"""Perform arbitrary changes to event's fields based on regular-expression-based rules on different values. See the bot's documentation for some examples"""
3940
case_sensitive: bool = True
40-
configuration_path: str = "/opt/intelmq/var/lib/bots/modify/modify.conf" # TODO: should be pathlib.Path
41+
configuration_path: str = f"{VAR_STATE_PATH}modify/modify.conf" # TODO: should be pathlib.Path
4142
maximum_matches = None
4243
overwrite: bool = True
4344

intelmq/bots/experts/recordedfuture_iprisk/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pathlib
1515
import requests
1616

17+
from intelmq import VAR_STATE_PATH
1718
from intelmq.lib.bot import ExpertBot
1819
from intelmq.lib.utils import get_bots_settings, create_request_session
1920
from intelmq.bin.intelmqctl import IntelMQController
@@ -22,7 +23,7 @@
2223
class RecordedFutureIPRiskExpertBot(ExpertBot):
2324
"""Adds the Risk Score from RecordedFuture IPRisk associated with source.ip or destination.ip with a local database"""
2425
api_token: str = "<insert Recorded Future IPRisk API token>"
25-
database: str = "/opt/intelmq/var/lib/bots/recordedfuture_iprisk/rfiprisk.dat" # TODO: should be pathlib.Path
26+
database: str = f"{VAR_STATE_PATH}recordedfuture_iprisk/rfiprisk.dat" # TODO: should be pathlib.Path
2627
overwrite: bool = False
2728
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
2829

intelmq/bots/experts/sieve/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import Callable, Dict, Optional, Union
2121
from enum import Enum, auto
2222

23+
from intelmq import VAR_STATE_PATH
2324
import intelmq.lib.exceptions as exceptions
2425
from intelmq import HARMONIZATION_CONF_FILE
2526
from intelmq.lib import utils
@@ -55,7 +56,7 @@ class SieveExpertBot(ExpertBot):
5556

5657
_harmonization = None
5758
file: str = (
58-
"/opt/intelmq/var/lib/bots/sieve/filter.sieve" # TODO: should be pathlib.Path
59+
f"{VAR_STATE_PATH}sieve/filter.sieve" # TODO: should be pathlib.Path
5960
)
6061

6162
def init(self) -> None:

intelmq/bots/experts/tor_nodes/expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import pathlib
1212
import requests
1313

14+
from intelmq import VAR_STATE_PATH
1415
from intelmq.lib.bot import ExpertBot
1516
from intelmq.lib.utils import get_bots_settings, create_request_session
1617
from intelmq.bin.intelmqctl import IntelMQController
1718

1819

1920
class TorExpertBot(ExpertBot):
2021
"""Check if the IP address is a Tor Exit Node based on a local database of TOR nodes"""
21-
database: str = "/opt/intelmq/var/lib/bots/tor_nodes/tor_nodes.dat" # TODO: pathlib.Path
22+
database: str = f"{VAR_STATE_PATH}tor_nodes/tor_nodes.dat" # TODO: pathlib.Path
2223
overwrite: bool = False
2324
autoupdate_cached_database: bool = True # Activate/deactivate update-database functionality
2425

intelmq/bots/outputs/bro_file/output.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from collections import defaultdict
1111
from pathlib import Path
1212

13+
from intelmq import VAR_STATE_PATH
1314
from intelmq.lib.bot import OutputBot
1415

1516
BRO_INDICATOR_MAP = {
@@ -24,7 +25,7 @@
2425
class BroFileOutputBot(OutputBot):
2526
_file = None
2627
encoding_errors_mode = 'strict'
27-
file: str = "/opt/intelmq/var/lib/bots/file-output/bro"
28+
file: str = f"{VAR_STATE_PATH}file-output/bro"
2829
format_filename: bool = False
2930
hierarchical_output: bool = False
3031
keep_raw_field: bool = False

0 commit comments

Comments
 (0)