Skip to content

Commit e1f43de

Browse files
authored
Merge branch 'develop' into makefile-codestyle
2 parents 7604a36 + ac09db4 commit e1f43de

File tree

15 files changed

+70
-30
lines changed

15 files changed

+70
-30
lines changed

.github/workflows/python/github.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ def __init__(self):
3131

3232
def get_reviews(self):
3333
""" Get a list of reviews on a Github pull request as json object """
34-
reviews = self.session.get(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id))
34+
reviews = self.session.get(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews')
3535
reviews.raise_for_status()
3636
return reviews.json()
3737

3838
def update_review(self, review_id, body):
3939
""" Update a review given by `review_id` and set its body to `body` """
4040
payload = {'body': body}
41-
resp = self.session.put(self.api + 'repos/{}/pulls/{}/reviews/{}'.format(self.github_repository, self.pr_id, review_id), json=payload)
41+
resp = self.session.put(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews/{review_id}', json=payload)
4242
resp.raise_for_status()
4343
return resp.json()
4444

4545
def post_review(self, body):
4646
""" Post a pull request review containing `body` and requesting changes """
4747
payload = {'body': body, 'event': "REQUEST_CHANGES"}
48-
resp = self.session.post(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id), json=payload)
48+
resp = self.session.post(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews', json=payload)
4949
resp.raise_for_status()
5050
return resp.json()

.github/workflows/python/pycodestyle_comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def style_error_format(style_error_list) -> str:
3434
""" Format the list of pycodestyle errors and return them a one string. """
3535
ret = ''
3636
for error in style_error_list:
37-
ret += '* {}\n'.format(error)
37+
ret += f'* {error}\n'
3838
return ret
3939

4040

@@ -45,7 +45,7 @@ def style_error_format(style_error_list) -> str:
4545
style_errors = list_style_errors()
4646

4747
if style_errors:
48-
print("Found {} errors.".format(len(style_errors)))
48+
print(f"Found {len(style_errors)} errors.")
4949

5050
gh = github.Github()
5151

.github/workflows/scripts/setup-full.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# SPDX-FileCopyrightText: 2020 Birger Schacht
2+
# SPDX-FileCopyrightText: 2020 Birger Schacht, 2024 Institute for Common Good Technology
33
# SPDX-License-Identifier: AGPL-3.0-or-later
44

55
set -x
@@ -14,6 +14,14 @@ echo -e '-XX:+DisableExplicitGC\n-Djdk.io.permissionsUseCanonicalPath=true\n-Dlo
1414
sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch
1515
sudo systemctl start elasticsearch
1616

17+
sudo apt update
18+
if [ $python_version == '3.8' ]; then
19+
# for pymssql there are no wheels for 3.8 https://github.com/certtools/intelmq/issues/2539
20+
DEBIAN_FRONTEND="noninteractive" sudo -E apt install -y build-essential freetds-dev libssl-dev libkrb5-dev
21+
fi
22+
# for psql (used below)
23+
DEBIAN_FRONTEND="noninteractive" sudo -E apt install -y postgresql-client-14
24+
1725
# Install the dependencies of all the bots
1826
pip install wheel
1927
for file in intelmq/bots/*/*/REQUIREMENTS.txt; do
@@ -30,7 +38,16 @@ done
3038
# Setup sudo and install intelmq
3139
sudo sed -i '/^Defaults\tsecure_path.*$/ d' /etc/sudoers
3240
sudo pip install .
33-
sudo intelmqsetup --skip-ownership
41+
42+
intelmq_user_exists=$(getent passwd intelmq ||:)
43+
if [[ "$UID" -eq '0' && -z "$intelmq_user_exists" ]]; then
44+
# create an unprivileged user, if currently running as root. Otherwise dropping privileges won't work
45+
groupadd -r intelmq
46+
useradd -r -d /var/lib/intelmq/ -c "user running intelmq" -g intelmq -s /bin/bash intelmq
47+
sudo intelmqsetup
48+
else
49+
sudo intelmqsetup --skip-ownership
50+
fi
3451

3552
# Initialize the postgres database
3653
intelmq_psql_initdb

.github/workflows/unittests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
21+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
2222
type: ['full', 'basic']
2323

2424
services:
@@ -59,6 +59,7 @@ jobs:
5959
PGPORT: 5432
6060
PGUSER: intelmq
6161
PGPASSWORD: intelmq
62+
python_version: ${{ matrix.python-version }}
6263
run: bash .github/workflows/scripts/setup-full.sh
6364

6465
- name: Install test dependencies

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
### Configuration
1313

1414
### Core
15+
- Python 3.8 or newer is required (PR#2541 by Sebastian Wagner).
1516

1617
### Development
1718

1819
### Data Format
1920

2021
### Bots
2122
#### Collectors
23+
- `intelmq.bots.collectors.shadowserver.collector_reports_api.py`:
24+
- Fixed behaviour if parameter `types` value is empty string, behave the same way as not set, not like no type.
2225

2326
#### Parsers
2427
- `intelmq.bots.parsers.shadowserver._config`:
@@ -29,12 +32,20 @@
2932
#### Experts
3033

3134
#### Outputs
35+
- `intelmq.bots.outputs.cif3.output`:
36+
- The requirement can only be installed on Python version < 3.12.
37+
- Add a check on the Python version and exit if incompatible.
38+
- Add a deprecation warning (PR#2544 by Sebastian Wagner)
3239

3340
### Documentation
3441

3542
### Packaging
3643

3744
### Tests
45+
- Install build dependencies for `pymssql` on Python 3.8 as there are no wheels available for this Python version (PR#2542 by Sebastian Wagner).
46+
- Install `psql` explicitly for workflow support on other platforms such as act (PR#2542 by Sebastian Wagner).
47+
- Create intelmq user & group if running privileged to allow dropping privileges (PR#2542 by Sebastian Wagner).
48+
- `intelmq.tests.lib.test_pipeline.TestAmqp.test_acknowledge`: Also skip on Python 3.11 besides on 3.8 when running on CI (PR#2542 by Sebastian Wagner).
3849

3950
### Tools
4051

NEWS.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Please refer to the change log for a full list of changes.
1414
---------------------------------
1515

1616
### Requirements
17+
Python 3.8 or newer is required.
18+
19+
## Bots
20+
#### CIF 3 API
21+
The CIF 3 API Output bot is not compatible with Python version greater or equal to 3.12 and will be removed in the future due to lack of maintenance.
22+
See https://lists.cert.at/pipermail/intelmq-users/2024-December/000474.html for more information.
1723

1824
### Tools
1925

@@ -36,7 +42,7 @@ No changes are required by administrators.
3642
----------------------------------
3743

3844
### Documentation
39-
The documentation is now available at [docs.intelmq.org](https://docs.intelmq.org/). Documentation has been updated and restructured into User, Administrator and Developer Guide. It provides modern look with various quality of life improvements. Big thanks to to @gethvi.
45+
The documentation is now available at [docs.intelmq.org](https://docs.intelmq.org/). Documentation has been updated and restructured into User, Administrator and Developer Guide. It provides modern look with various quality of life improvements. Big thanks to to @gethvi.
4046
We now have a slick, modern mkdocs based documentation. Please do check it out!
4147

4248

@@ -55,7 +61,7 @@ Shadowserver adds new scans on a nearly weekly basis. IntelMQ's release cycle an
5561
We therefore (thanks to @eslif2) move the shadowserver reports collector and parser to a new, dynamic system. It can:
5662

5763
- fetch the shadowserver schema from shadowserver (https://interchange.shadowserver.org/intelmq/v1/schema)
58-
- dynamically collect new reports (see also https://docs.intelmq.org/latest/user/bots/?h=shadow#shadowserver-reports-api)
64+
- dynamically collect new reports (see also https://docs.intelmq.org/latest/user/bots/?h=shadow#shadowserver-reports-api)
5965
- parse the new reports
6066

6167
**Note well**: if your IntelMQ system runs in an airgapped environment or if it may only reach out to specific IPs/sites, you should read the notes here:
@@ -86,7 +92,7 @@ Quite a few changes (thanks to Kamil, @gethvi) on AMQP
8692
### General changes and bug fixes
8793

8894
Digital Trust Center fixed a bug where the config was loaded twice in intelmqctl which created quite some speedups. Thanks!
89-
This speeds up IntelMQ API calls.
95+
This speeds up IntelMQ API calls.
9096

9197
### Data Format
9298

contrib/example-extension-package/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
entry_point = '.'.join(file.with_suffix('').parts)
2929
file = Path(str(file).replace('intelmq/bots', 'mybots/bots'))
3030
module = '.'.join(file.with_suffix('').parts)
31-
BOTS.append('{0} = {1}:BOT.run'.format(entry_point, module))
31+
BOTS.append(f'{entry_point} = {module}:BOT.run')
3232

3333
setup(
3434
name='intelmq-example-extension',

intelmq/bots/collectors/rsync/collector_rsync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from intelmq.lib.bot import CollectorBot
1414

1515

16-
class Time(object):
16+
class Time:
1717
def __init__(self, delta=None):
1818
""" Delta is a datetime.timedelta JSON string, ex: '{days=-1}'. """
1919
self.time = datetime.now()

intelmq/bots/collectors/shadowserver/collector_reports_api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ShadowServerAPICollectorBot(CollectorBot, HttpMixin, CacheMixin):
3333
reports (list):
3434
A list of strings or a comma-separated list of the mailing lists you want to process.
3535
types (list):
36-
A list of strings or a string of comma-separated values with the names of reporttypes you want to process. If you leave this empty, all the available reports will be downloaded and processed (i.e. 'scan', 'drones', 'intel', 'sandbox_connection', 'sinkhole_combined').
36+
A list of strings or a string of comma-separated values with the names of report types you want to process. If you leave this empty, all the available reports will be downloaded and processed (i.e. 'scan', 'drones', 'intel', 'sandbox_connection', 'sinkhole_combined').
3737
"""
3838

3939
country = None
@@ -48,6 +48,7 @@ class ShadowServerAPICollectorBot(CollectorBot, HttpMixin, CacheMixin):
4848
redis_cache_ttl: int = 864000 # 10 days
4949
redis_cache_password: Optional[str] = None
5050
_report_list = []
51+
_type_list = []
5152

5253
def init(self):
5354
if not self.api_key:
@@ -62,7 +63,11 @@ def init(self):
6263
elif isinstance(self.reports, list):
6364
self._report_list = self.reports
6465
if isinstance(self.types, str):
65-
self.types = self.types.split(',')
66+
# if types is an empty string (or only contains whitespace), behave as if the parameter is not set and select all types
67+
types = self.types.strip()
68+
self._type_list = types.split(',') if types else []
69+
elif isinstance(self.types, list):
70+
self._type_list = self.types
6671
if self.country and self.country not in self._report_list:
6772
self.logger.warn("Deprecated parameter 'country' found. Please use 'reports' instead. The backwards-compatibility will be removed in IntelMQ version 4.0.0.")
6873
self._report_list.append(self.country)
@@ -111,8 +116,8 @@ def _reports_list(self, date=None):
111116
self.logger.debug('There was an error downloading the reports: %s', reports['error'])
112117
return None
113118

114-
if self.types:
115-
reports = [report for report in reports if any(report['type'] == rtype for rtype in self.types)]
119+
if self._type_list:
120+
reports = [report for report in reports if any(report['type'] == rtype for rtype in self._type_list)]
116121
return reports
117122

118123
def _report_download(self, reportid: str):

intelmq/bots/experts/modify/expert.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def is_re_pattern(value):
1717
"""
1818
Checks if the given value is a re compiled pattern
1919
"""
20-
if sys.version_info > (3, 7):
21-
return isinstance(value, re.Pattern)
22-
else:
23-
return hasattr(value, "pattern")
20+
return isinstance(value, re.Pattern)
2421

2522

2623
class MatchGroupMapping:

0 commit comments

Comments
 (0)