Skip to content

Commit

Permalink
Feat: Support send phishing email with email file path (#110)
Browse files Browse the repository at this point in the history
* Feat: Support send phishing email with email file path
  • Loading branch information
guysl10 authored Aug 8, 2023
1 parent 2e52aae commit 5f2132e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.18.7
______
- Support email file path for sending phishing email.

1.18.6
______
- Raise `FileTooLargeError` on analyzing file that is too large.
Expand Down
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.18.6'
__version__ = '1.18.7'
14 changes: 11 additions & 3 deletions intezer_sdk/alerts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import json
import time
from io import BytesIO
from typing import BinaryIO

import requests
Expand Down Expand Up @@ -227,16 +228,17 @@ def send(cls,

@classmethod
def send_phishing_email(cls,
raw_email: BinaryIO,
api: IntezerApiClient = None,
raw_email: Optional[BinaryIO] = None,
api: Optional[IntezerApiClient] = None,
environment: Optional[str] = None,
default_verdict: Optional[str] = None,
alert_sender: Optional[str] = None,
wait: bool = False,
timeout: Optional[int] = None,
):
email_path: Optional[str] = None):
"""
Send an alert for further investigation using the Intezer Analyze API.
Should pass either raw_email or email_path.
:param raw_email: The raw alert data.
:param api: The API connection to Intezer.
Expand All @@ -245,10 +247,16 @@ def send_phishing_email(cls,
:param alert_sender: The sender of the alert.
:param wait: Wait for the alert to finish processing before returning.
:param timeout: The timeout for the wait operation.
:param email_path: The path to the email file.
:raises: :class:`requests.HTTPError` if the request failed for any reason.
:return: The Alert instance, initialized with the alert id. when the `wait` parameter is set to True, the
resulting alert object will be initialized with the alert triage data.
"""
if not raw_email and not email_path:
raise ValueError('raw_email or email_path must be provided')
if email_path:
with open(email_path, 'rb') as email_file:
raw_email = BytesIO(email_file.read())
_api = IntezerApi(api or get_global_api())
if not bool(raw_email.getvalue()):
raise ValueError('alert cannot be empty')
Expand Down

0 comments on commit 5f2132e

Please sign in to comment.