Skip to content

Commit 45155b7

Browse files
authoredMar 24, 2025··
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

+1
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

+3-1
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

+5-5
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

‎intelmq/bots/outputs/file/output.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
from collections import defaultdict
99
from pathlib import Path
1010

11+
from intelmq import VAR_STATE_PATH
1112
from intelmq.lib.bot import OutputBot
1213

1314

1415
class FileOutputBot(OutputBot):
1516
"""Write events to a file"""
1617
_file = None
1718
encoding_errors_mode = 'strict'
18-
file: str = "/opt/intelmq/var/lib/bots/file-output/events.txt" # TODO: should be pathlib.Path
19+
file: str = f"{VAR_STATE_PATH}file-output/events.txt" # TODO: should be pathlib.Path
1920
format_filename: bool = False
2021
hierarchical_output: bool = False
2122
keep_raw_field: bool = False

‎intelmq/bots/outputs/files/output.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
import socket
1010
import time
1111
from os import path
12+
13+
from intelmq import VAR_STATE_PATH
1214
from intelmq.lib.bot import OutputBot
1315
from intelmq.lib.exceptions import ConfigurationError
1416

1517

1618
class FilesOutputBot(OutputBot):
1719
"""Write events lockfree into separate files"""
18-
dir: str = "/opt/intelmq/var/lib/bots/files-output/incoming" # TODO: could be path
20+
dir: str = f"{VAR_STATE_PATH}files-output/incoming" # TODO: could be path
1921
hierarchical_output: bool = False
2022
keep_raw_field: bool = False
2123
message_jsondict_as_string: bool = False
2224
message_with_type: bool = False
2325
single_key: bool = False
2426
suffix: str = ".json"
25-
tmp: str = "/opt/intelmq/var/lib/bots/files-output/tmp" # TODO: could be path
27+
tmp: str = f"{VAR_STATE_PATH}files-output/tmp" # TODO: could be path
2628

2729
def init(self):
2830
self.tmp = self._ensure_path(self.tmp)

‎intelmq/bots/outputs/misp/output_feed.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from uuid import uuid4
1010
import re
1111

12+
from intelmq import VAR_STATE_PATH
1213
from intelmq.lib.bot import OutputBot
1314
from intelmq.lib.exceptions import MissingDependencyError
1415
from intelmq.lib.utils import parse_relative
@@ -34,7 +35,7 @@ class MISPFeedOutputBot(OutputBot):
3435
interval_event: str = "1 hour"
3536
misp_org_name = None
3637
misp_org_uuid = None
37-
output_dir: str = "/opt/intelmq/var/lib/bots/mispfeed-output" # TODO: should be path
38+
output_dir: str = f"{VAR_STATE_PATH}mispfeed-output" # TODO: should be path
3839
_is_multithreadable: bool = False
3940

4041
@staticmethod

‎intelmq/bots/outputs/rpz_file/output.py

+2-1
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
RPZ_INDICATOR_MAP = {
@@ -30,7 +31,7 @@ class RpzFileOutputBot(OutputBot):
3031
_is_multithreadable = False
3132

3233
encoding_errors_mode = 'strict'
33-
file: str = "/opt/intelmq/var/lib/bots/file-output/rpz"
34+
file: str = f"{VAR_STATE_PATH}file-output/rpz"
3435

3536
cname: str = ""
3637
organization_name: str = ''

0 commit comments

Comments
 (0)
Please sign in to comment.