Skip to content

Commit 5f2132e

Browse files
authored
Feat: Support send phishing email with email file path (#110)
* Feat: Support send phishing email with email file path
1 parent 2e52aae commit 5f2132e

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

CHANGES

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.18.7
2+
______
3+
- Support email file path for sending phishing email.
4+
15
1.18.6
26
______
37
- Raise `FileTooLargeError` on analyzing file that is too large.

intezer_sdk/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.18.6'
1+
__version__ = '1.18.7'

intezer_sdk/alerts.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hashlib
22
import json
33
import time
4+
from io import BytesIO
45
from typing import BinaryIO
56

67
import requests
@@ -227,16 +228,17 @@ def send(cls,
227228

228229
@classmethod
229230
def send_phishing_email(cls,
230-
raw_email: BinaryIO,
231-
api: IntezerApiClient = None,
231+
raw_email: Optional[BinaryIO] = None,
232+
api: Optional[IntezerApiClient] = None,
232233
environment: Optional[str] = None,
233234
default_verdict: Optional[str] = None,
234235
alert_sender: Optional[str] = None,
235236
wait: bool = False,
236237
timeout: Optional[int] = None,
237-
):
238+
email_path: Optional[str] = None):
238239
"""
239240
Send an alert for further investigation using the Intezer Analyze API.
241+
Should pass either raw_email or email_path.
240242
241243
:param raw_email: The raw alert data.
242244
:param api: The API connection to Intezer.
@@ -245,10 +247,16 @@ def send_phishing_email(cls,
245247
:param alert_sender: The sender of the alert.
246248
:param wait: Wait for the alert to finish processing before returning.
247249
:param timeout: The timeout for the wait operation.
250+
:param email_path: The path to the email file.
248251
:raises: :class:`requests.HTTPError` if the request failed for any reason.
249252
:return: The Alert instance, initialized with the alert id. when the `wait` parameter is set to True, the
250253
resulting alert object will be initialized with the alert triage data.
251254
"""
255+
if not raw_email and not email_path:
256+
raise ValueError('raw_email or email_path must be provided')
257+
if email_path:
258+
with open(email_path, 'rb') as email_file:
259+
raw_email = BytesIO(email_file.read())
252260
_api = IntezerApi(api or get_global_api())
253261
if not bool(raw_email.getvalue()):
254262
raise ValueError('alert cannot be empty')

0 commit comments

Comments
 (0)