Skip to content

Commit 46b3346

Browse files
committed
chg: Bump deps
1 parent 503a864 commit 46b3346

File tree

9 files changed

+306
-314
lines changed

9 files changed

+306
-314
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
exclude: "tests/data"
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.6.0
6+
rev: v5.0.0
77
hooks:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- id: check-yaml
1111
- id: check-added-large-files
1212
- repo: https://github.com/asottile/pyupgrade
13-
rev: v3.17.0
13+
rev: v3.20.0
1414
hooks:
1515
- id: pyupgrade
1616
args: [--py38-plus]

poetry.lock

Lines changed: 259 additions & 265 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pymisp/abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def __init__(self, **kwargs) -> None: # type: ignore[no-untyped-def]
383383

384384
def from_dict(self, **kwargs) -> None: # type: ignore[no-untyped-def]
385385
if kwargs.get('Tag'):
386-
kwargs = kwargs.get('Tag') # type: ignore[assignment]
386+
kwargs = kwargs.get('Tag')
387387
super().from_dict(**kwargs)
388388

389389
def _set_default(self) -> None:

pymisp/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def brotli_supported() -> bool:
129129
# urllib >= 1.25.1 includes brotli support
130130
version_splitted = version('urllib3').split('.') # noqa: F811
131131
if len(version_splitted) == 2:
132-
major, minor = version_splitted # type: ignore
132+
major, minor = version_splitted
133133
patch = 0
134134
else:
135-
major, minor, patch = version_splitted # type: ignore
135+
major, minor, patch = version_splitted
136136
major, minor, patch = int(major), int(minor), int(patch)
137137
urllib3_with_brotli = (major == 1 and ((minor == 25 and patch >= 1) or (minor >= 26))) or major >= 2
138138

@@ -1050,7 +1050,7 @@ def add_attribute(self, event: MISPEvent | int | str | UUID, attribute: MISPAttr
10501050
# At this point, we assume the user tried to add an attribute on an event they don't own
10511051
# Re-try with a proposal
10521052
if isinstance(attribute, (MISPAttribute, dict)):
1053-
return self.add_attribute_proposal(event_id, attribute, pythonify) # type: ignore
1053+
return self.add_attribute_proposal(event_id, attribute, pythonify)
10541054
if not (self.global_pythonify or pythonify) or 'errors' in new_attribute:
10551055
return new_attribute
10561056
a = MISPAttribute()
@@ -1563,7 +1563,7 @@ def toggle_warninglist(self, warninglist_id: str | int | list[int] | None = None
15631563
if isinstance(warninglist_id, list):
15641564
query['id'] = warninglist_id
15651565
else:
1566-
query['id'] = [warninglist_id] # type: ignore
1566+
query['id'] = [warninglist_id]
15671567
if warninglist_name is not None:
15681568
if isinstance(warninglist_name, list):
15691569
query['name'] = warninglist_name
@@ -3032,7 +3032,7 @@ def search(self, controller: str = 'events', return_format: str = 'json', # typ
30323032
if return_format == 'csv':
30333033
normalized_response_text = self._check_response(response)
30343034
if (self.global_pythonify or pythonify) and not headerless:
3035-
return self._csv_to_dict(normalized_response_text) # type: ignore
3035+
return self._csv_to_dict(normalized_response_text)
30363036
else:
30373037
return normalized_response_text
30383038
elif return_format not in ['json', 'yara-json']:
@@ -3060,7 +3060,7 @@ def search(self, controller: str = 'events', return_format: str = 'json', # typ
30603060
to_return.append(me)
30613061
elif controller == 'attributes':
30623062
# FIXME: obvs, this is hurting my soul. We need something generic.
3063-
for a in normalized_response['Attribute']: # type: ignore[call-overload]
3063+
for a in normalized_response['Attribute']:
30643064
ma = MISPAttribute()
30653065
ma.from_dict(**a)
30663066
if 'Event' in ma:

pymisp/mispevent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _make_datetime(value: int | float | str | datetime | date) -> datetime:
126126
# faster
127127
value = datetime.fromisoformat(value)
128128
except Exception:
129-
value = parse(value) # type: ignore[arg-type]
129+
value = parse(value)
130130
elif isinstance(value, datetime):
131131
pass
132132
elif isinstance(value, date): # NOTE: date has to be *after* datetime, or it will be overwritten
@@ -399,7 +399,7 @@ def _prepare_data(self, data: Path | str | bytes | BytesIO | None) -> None:
399399
if self.type == 'malware-sample':
400400
try:
401401
# Ignore type, if data is None -> exception
402-
with ZipFile(self.data) as f: # type: ignore
402+
with ZipFile(self.data) as f:
403403
if not self.__is_misp_encrypted_file(f):
404404
raise PyMISPError('Not an existing malware sample')
405405
for name in f.namelist():
@@ -488,7 +488,7 @@ def malware_binary(self) -> BytesIO | None:
488488
return self._malware_binary
489489
elif hasattr(self, 'malware_filename'):
490490
# Have a binary, but didn't decrypt it yet
491-
with ZipFile(self.data) as f: # type: ignore
491+
with ZipFile(self.data) as f:
492492
for name in f.namelist():
493493
if not name.endswith('.filename.txt'):
494494
with f.open(name, pwd=b'infected') as unpacked:
@@ -1871,7 +1871,7 @@ def set_date(self, d: str | int | float | datetime | date | None = None, ignore_
18711871
:param ignore_invalid: if True, assigns current date if d is not an expected type
18721872
"""
18731873
if isinstance(d, (str, int, float, datetime, date)):
1874-
self.date = d # type: ignore
1874+
self.date = d
18751875
elif ignore_invalid:
18761876
self.date = date.today()
18771877
else:
@@ -1938,7 +1938,7 @@ def from_dict(self, **kwargs) -> None: # type: ignore[no-untyped-def]
19381938
for rel_event in kwargs.pop('RelatedEvent'):
19391939
sub_event = MISPEvent()
19401940
sub_event.load(rel_event)
1941-
self.RelatedEvent.append({'Event': sub_event}) # type: ignore[arg-type]
1941+
self.RelatedEvent.append({'Event': sub_event})
19421942
if kwargs.get('Tag'):
19431943
[self.add_tag(tag) for tag in kwargs.pop('Tag')]
19441944
if kwargs.get('Object'):

pymisp/tools/emailobject.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from email.message import EmailMessage
1111
from io import BytesIO
1212
from pathlib import Path
13-
from typing import cast, Any
13+
from typing import Any
1414

1515
from extract_msg import openMsg
1616
from extract_msg.msg_classes import MessageBase
@@ -50,7 +50,6 @@ def parse_email(self) -> EmailMessage:
5050
eml = message_from_bytes(content_in_bytes,
5151
_class=EmailMessage,
5252
policy=policy.default)
53-
eml = cast(EmailMessage, eml) # Only needed to quiet mypy
5453
if len(eml) != 0:
5554
self.raw_emails['eml'] = self.__pseudofile
5655
return eml
@@ -73,7 +72,6 @@ def parse_email(self) -> EmailMessage:
7372
eml_bytes = content_in_bytes.decode("utf_8_sig").encode("utf-8")
7473
eml = email.message_from_bytes(eml_bytes,
7574
policy=policy.default)
76-
eml = cast(EmailMessage, eml) # Only needed to quiet mypy
7775
if len(eml) != 0:
7876
self.raw_emails['eml'] = BytesIO(eml_bytes)
7977
return eml
@@ -99,15 +97,15 @@ def create_pseudofile(filepath: Path | str | None = None,
9997
def _msg_to_eml(self, msg_bytes: bytes) -> EmailMessage:
10098
"""Converts a msg into an eml."""
10199
# NOTE: openMsg returns a MessageBase, not a MSGFile
102-
msg_obj: MessageBase = openMsg(msg_bytes) # type: ignore
100+
msg_obj: MessageBase = openMsg(msg_bytes)
103101
# msg obj stores the original raw header here
104102
message, body, attachments = self._extract_msg_objects(msg_obj)
105103
eml = self._build_eml(message, body, attachments)
106104
return eml
107105

108106
def _extract_msg_objects(self, msg_obj: MessageBase) -> tuple[EmailMessage, dict[str, Any], list[AttachmentBase] | list[SignedAttachment]]:
109107
"""Extracts email objects needed to construct an eml from a msg."""
110-
message: EmailMessage = email.message_from_string(msg_obj.header.as_string(), policy=policy.default) # type: ignore
108+
message: EmailMessage = email.message_from_string(msg_obj.header.as_string(), policy=policy.default)
111109
body = {}
112110
if msg_obj.body is not None:
113111
body['text'] = {"obj": msg_obj.body,

pymisp/tools/peobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def generate_attributes(self) -> None:
202202
self.add_attribute('digest_algorithm', value=str(self.__signer.digest_algorithm))
203203
self.add_attribute('encryption_algorithm', value=str(self.__signer.encryption_algorithm))
204204
self.add_attribute('digest-base64', value=b64encode(self.__signer.encrypted_digest))
205-
info: lief.PE.SpcSpOpusInfo = self.__signer.get_attribute(lief.PE.Attribute.TYPE.SPC_SP_OPUS_INFO) # type: ignore[assignment]
205+
info: lief.PE.SpcSpOpusInfo = self.__signer.get_attribute(lief.PE.Attribute.TYPE.SPC_SP_OPUS_INFO)
206206
if info:
207207
self.add_attribute('program-name', value=info.program_name)
208208
self.add_attribute('url', value=info.more_info)

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ requires-python = ">=3.9.2,<4.0"
1212
dynamic = [ "classifiers" ]
1313

1414
dependencies = [
15-
"requests (>=2.32.3)",
15+
"requests (>=2.32.4)",
1616
"python-dateutil (>=2.9.0.post0)",
1717
"deprecated (>=1.2.18)"
1818
]
@@ -27,7 +27,7 @@ documentation = "https://pymisp.readthedocs.io"
2727
fileobjects = [
2828
"python-magic (>=0.4.27)",
2929
"pydeep2 (>=0.5.1)",
30-
"lief (>=0.16.5)"
30+
"lief (>=0.16.6)"
3131
]
3232

3333
openioc = [ "beautifulsoup4 (>=4.13.4)" ]
@@ -41,7 +41,7 @@ docs = [
4141
"myst-parser (>=4.0.1) ; python_version >= \"3.11\""
4242
]
4343

44-
pdfexport = [ "reportlab (>=4.4.0)" ]
44+
pdfexport = [ "reportlab (>=4.4.1)" ]
4545

4646
url = [ "pyfaup (>=1.2)" ]
4747

@@ -80,9 +80,9 @@ include = [
8080

8181
[tool.poetry.group.dev.dependencies]
8282
requests-mock = "^1.12.1"
83-
mypy = "^1.15.0"
84-
types-requests = "^2.32.0.20250328"
85-
types-python-dateutil = "^2.9.0.20241206"
83+
mypy = "^1.16.0"
84+
types-requests = "^2.32.0.20250602"
85+
types-python-dateutil = "^2.9.0.20250516"
8686
types-redis = "^4.6.0.20241004"
8787
types-Flask = "^1.1.6"
8888
pytest-cov = "^6.1.1"

tests/test_mispevent.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def test_event_galaxy(self) -> None:
8080

8181
def test_attribute(self) -> None:
8282
self.init_event()
83-
a: MISPAttribute = self.mispevent.add_attribute('filename', 'bar.exe') # type: ignore[assignment]
83+
a: MISPAttribute = self.mispevent.add_attribute('filename', 'bar.exe')
8484
del a.uuid
85-
a = self.mispevent.add_attribute_tag('osint', 'bar.exe') # type: ignore[assignment]
85+
a = self.mispevent.add_attribute_tag('osint', 'bar.exe')
8686
attr_tags = self.mispevent.get_attribute_tag('bar.exe')
8787
self.assertEqual(self.mispevent.attributes[0].tags[0].name, 'osint')
8888
self.assertEqual(attr_tags[0].name, 'osint')
@@ -123,17 +123,17 @@ def test_to_dict_json_format(self) -> None:
123123

124124
def test_object_tag(self) -> None:
125125
self.mispevent.add_object(name='file', strict=True)
126-
a: MISPAttribute = self.mispevent.objects[0].add_attribute('filename', value='') # type: ignore[assignment]
126+
a: MISPAttribute = self.mispevent.objects[0].add_attribute('filename', value='')
127127
self.assertEqual(a, None)
128-
a = self.mispevent.objects[0].add_attribute('filename', value=None) # type: ignore[assignment]
128+
a = self.mispevent.objects[0].add_attribute('filename', value=None)
129129
self.assertEqual(a, None)
130-
a = self.mispevent.objects[0].add_attribute('filename', value='bar', Tag=[{'name': 'blah'}]) # type: ignore[assignment]
130+
a = self.mispevent.objects[0].add_attribute('filename', value='bar', Tag=[{'name': 'blah'}])
131131
del a.uuid
132132
self.assertEqual(self.mispevent.objects[0].attributes[0].tags[0].name, 'blah')
133133
self.assertTrue(self.mispevent.objects[0].has_attributes_by_relation(['filename']))
134134
self.assertEqual(len(self.mispevent.objects[0].get_attributes_by_relation('filename')), 1)
135135
self.mispevent.add_object(name='url', strict=True)
136-
a = self.mispevent.objects[1].add_attribute('url', value='https://www.circl.lu') # type: ignore[assignment]
136+
a = self.mispevent.objects[1].add_attribute('url', value='https://www.circl.lu')
137137
del a.uuid
138138
self.mispevent.objects[0].uuid = 'a'
139139
self.mispevent.objects[1].uuid = 'b'
@@ -175,7 +175,7 @@ def test_malware(self) -> None:
175175
with open('tests/mispevent_testfiles/simple.json', 'rb') as f:
176176
pseudofile = BytesIO(f.read())
177177
self.init_event()
178-
a: MISPAttribute = self.mispevent.add_attribute('malware-sample', 'bar.exe', data=pseudofile) # type: ignore[assignment]
178+
a: MISPAttribute = self.mispevent.add_attribute('malware-sample', 'bar.exe', data=pseudofile)
179179
del a.uuid
180180
attribute = self.mispevent.attributes[0]
181181
self.assertEqual(attribute.malware_binary, pseudofile)
@@ -217,7 +217,7 @@ def test_shadow_attributes(self) -> None:
217217
self.init_event()
218218
p = self.mispevent.add_proposal(type='filename', value='baz.jpg')
219219
del p.uuid
220-
a: MISPAttribute = self.mispevent.add_attribute('filename', 'bar.exe') # type: ignore[assignment]
220+
a: MISPAttribute = self.mispevent.add_attribute('filename', 'bar.exe')
221221
del a.uuid
222222
p = self.mispevent.attributes[0].add_proposal(type='filename', value='bar.pdf')
223223
del p.uuid
@@ -227,13 +227,13 @@ def test_shadow_attributes(self) -> None:
227227

228228
def test_default_attributes(self) -> None:
229229
self.mispevent.add_object(name='file', strict=True)
230-
a: MISPAttribute = self.mispevent.objects[0].add_attribute('filename', value='bar', Tag=[{'name': 'blah'}]) # type: ignore[assignment]
230+
a: MISPAttribute = self.mispevent.objects[0].add_attribute('filename', value='bar', Tag=[{'name': 'blah'}])
231231
del a.uuid
232-
a = self.mispevent.objects[0].add_attribute('pattern-in-file', value='baz') # type: ignore[assignment]
232+
a = self.mispevent.objects[0].add_attribute('pattern-in-file', value='baz')
233233
self.assertEqual(a.category, 'Artifacts dropped')
234234
del a.uuid
235235
self.mispevent.add_object(name='file', strict=False, default_attributes_parameters=self.mispevent.objects[0].attributes[0])
236-
a = self.mispevent.objects[1].add_attribute('filename', value='baz') # type: ignore[assignment]
236+
a = self.mispevent.objects[1].add_attribute('filename', value='baz')
237237
del a.uuid
238238
self.mispevent.objects[0].uuid = 'a'
239239
self.mispevent.objects[1].uuid = 'b'
@@ -245,13 +245,13 @@ def test_default_attributes(self) -> None:
245245
def test_obj_default_values(self) -> None:
246246
self.init_event()
247247
self.mispevent.add_object(name='whois', strict=True)
248-
a: MISPAttribute = self.mispevent.objects[0].add_attribute('registrar', value='registar.example.com') # type: ignore[assignment]
248+
a: MISPAttribute = self.mispevent.objects[0].add_attribute('registrar', value='registar.example.com')
249249
del a.uuid
250-
a = self.mispevent.objects[0].add_attribute('domain', value='domain.example.com') # type: ignore[assignment]
250+
a = self.mispevent.objects[0].add_attribute('domain', value='domain.example.com')
251251
del a.uuid
252-
a = self.mispevent.objects[0].add_attribute('nameserver', value='ns1.example.com') # type: ignore[assignment]
252+
a = self.mispevent.objects[0].add_attribute('nameserver', value='ns1.example.com')
253253
del a.uuid
254-
a = self.mispevent.objects[0].add_attribute('nameserver', value='ns2.example.com', disable_correlation=False, to_ids=True, category='External analysis') # type: ignore[assignment]
254+
a = self.mispevent.objects[0].add_attribute('nameserver', value='ns2.example.com', disable_correlation=False, to_ids=True, category='External analysis')
255255
del a.uuid
256256
self.mispevent.objects[0].uuid = 'a'
257257
with open('tests/mispevent_testfiles/def_param.json') as f:
@@ -353,16 +353,16 @@ def test_userdefined_object_custom_template(self) -> None:
353353
self.mispevent.to_json(sort_keys=True, indent=2)
354354
self.assertEqual(e.exception.message, '{\'member3\'} are required.')
355355

356-
a: MISPAttribute = self.mispevent.objects[0].add_attribute('member3', value='foo') # type: ignore[assignment]
356+
a: MISPAttribute = self.mispevent.objects[0].add_attribute('member3', value='foo')
357357
del a.uuid
358358
with self.assertRaises(InvalidMISPObject) as e:
359359
# Fail on requiredOneOf
360360
self.mispevent.to_json(sort_keys=True, indent=2)
361361
self.assertEqual(e.exception.message, 'At least one of the following attributes is required: member1, member2')
362362

363-
a = self.mispevent.objects[0].add_attribute('member1', value='bar') # type: ignore[assignment]
363+
a = self.mispevent.objects[0].add_attribute('member1', value='bar')
364364
del a.uuid
365-
a = self.mispevent.objects[0].add_attribute('member1', value='baz') # type: ignore[assignment]
365+
a = self.mispevent.objects[0].add_attribute('member1', value='baz')
366366
del a.uuid
367367
with self.assertRaises(InvalidMISPObject) as e:
368368
# member1 is not a multiple
@@ -384,16 +384,16 @@ def test_userdefined_object_custom_dir(self) -> None:
384384
self.mispevent.to_json(sort_keys=True, indent=2)
385385
self.assertEqual(e.exception.message, '{\'member3\'} are required.')
386386

387-
a: MISPAttribute = self.mispevent.objects[0].add_attribute('member3', value='foo') # type: ignore[assignment]
387+
a: MISPAttribute = self.mispevent.objects[0].add_attribute('member3', value='foo')
388388
del a.uuid
389389
with self.assertRaises(InvalidMISPObject) as e:
390390
# Fail on requiredOneOf
391391
self.mispevent.to_json(sort_keys=True, indent=2)
392392
self.assertEqual(e.exception.message, 'At least one of the following attributes is required: member1, member2')
393393

394-
a = self.mispevent.objects[0].add_attribute('member1', value='bar') # type: ignore[assignment]
394+
a = self.mispevent.objects[0].add_attribute('member1', value='bar')
395395
del a.uuid
396-
a = self.mispevent.objects[0].add_attribute('member1', value='baz') # type: ignore[assignment]
396+
a = self.mispevent.objects[0].add_attribute('member1', value='baz')
397397
del a.uuid
398398
with self.assertRaises(InvalidMISPObject) as e:
399399
# member1 is not a multiple
@@ -410,15 +410,15 @@ def test_userdefined_object_custom_dir(self) -> None:
410410
def test_first_last_seen(self) -> None:
411411
me = MISPEvent()
412412
me.info = 'Test First and Last Seen'
413-
me.date = '2020.01.12' # type: ignore[assignment]
413+
me.date = '2020.01.12'
414414
self.assertEqual(me.date.day, 12)
415415
me.add_attribute('ip-dst', '8.8.8.8', first_seen='06-21-1998', last_seen=1580213607.469571)
416416
self.assertEqual(me.attributes[0].first_seen.year, 1998)
417417
self.assertEqual(me.attributes[0].last_seen.year, 2020)
418418
now = datetime.now().astimezone()
419419
me.attributes[0].last_seen = now
420420
today = date.today()
421-
me.attributes[0].first_seen = today # type: ignore[assignment]
421+
me.attributes[0].first_seen = today
422422
self.assertEqual(me.attributes[0].first_seen.year, today.year)
423423
self.assertEqual(me.attributes[0].last_seen, now)
424424

0 commit comments

Comments
 (0)