Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PreprocessEmail] Fix an issue in parsing images #33651

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9c1d6c2
[PreprocessEmail] Fix an issue in parsing images
mmhw Mar 31, 2024
0cb6dc5
Add RN
mmhw Mar 31, 2024
dc1fa22
review comment
mmhw Apr 1, 2024
9ac8a96
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 1, 2024
957b2fa
Update Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
mmhw Apr 2, 2024
f631e71
Add unit test
mmhw Apr 3, 2024
dd3a745
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 3, 2024
4221f90
Fix pre-commit
mmhw Apr 3, 2024
379e027
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 3, 2024
d7b1bf0
Merged master into current branch.
Apr 3, 2024
1e48409
Bump pack from version MicrosoftExchangeOnline to 1.2.47.
Apr 3, 2024
5f12ef4
Add return type
mmhw Apr 4, 2024
f988ea9
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 4, 2024
4581d15
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 4, 2024
2134fbe
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 7, 2024
1216e69
Merged master into current branch.
Apr 7, 2024
c99ff79
Bump pack from version Base to 1.33.50.
Apr 7, 2024
bc48cc0
Update docker image
mmhw Apr 7, 2024
89aa482
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 7, 2024
5dbc4ba
Merge remote-tracking branch 'origin/master' into MW/XSUP-33708/Prepr…
mmhw Apr 7, 2024
d8c35d6
Merge branch 'master' into MW/XSUP-33708/PreprocessEmail/Fix_issue_in…
mmhw Apr 7, 2024
cb169e6
Merged master into current branch.
Apr 7, 2024
b0cdabc
Bump pack from version MicrosoftExchangeOnline to 1.3.3.
Apr 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Packs/Base/ReleaseNotes/1_33_47.md
@@ -0,0 +1,6 @@

#### Scripts

##### CommonServerPython

Added FileAttachmentType Enum to used it in PreprocessEmail script to handle inline image attachments correctly.
8 changes: 8 additions & 0 deletions Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
Expand Up @@ -350,6 +350,14 @@ def is_valid_type(cls, _type):
)


class FileAttachmentType(object):
"""
Enum: contains the file attachment types,
Used to add information in the description of the attachment whether the image is inline or attached
mmhw marked this conversation as resolved.
Show resolved Hide resolved
"""
ATTACHED = "attached_file"


brands = {
'xfe': 'xfe',
'vt': 'virustotal',
Expand Down
4 changes: 2 additions & 2 deletions Packs/Base/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Base",
"description": "The base pack for Cortex XSOAR.",
"support": "xsoar",
"currentVersion": "1.33.46",
"currentVersion": "1.33.47",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand All @@ -25,4 +25,4 @@
"marketplacev2",
"xpanse"
]
}
}
7 changes: 7 additions & 0 deletions Packs/EmailCommunication/ReleaseNotes/2_0_27.md
@@ -0,0 +1,7 @@

#### Scripts

##### PreprocessEmail

- Fixed an issue where inline image attachments were not handled correctly by added description field to attachments to distinguish file attachments from inline images.
- Updated the Docker image to: *demisto/python3:3.10.14.91134*.
Expand Up @@ -88,7 +88,7 @@ def get_entry_id_list(attachments, files):
for attachment in attachments:
attachment_name = attachment.get('name', '')
for file in files:
if attachment_name == file.get('Name'):
if attachment_name == file.get('Name') and attachment.get('description', '') != FileAttachmentType.ATTACHED:
entry_id_list.append((attachment_name, file.get('EntryID')))

return entry_id_list
Expand Down
Expand Up @@ -33,7 +33,7 @@ tags:
- email
- preProcessing
type: python
dockerimage: demisto/python3:3.10.13.80593
dockerimage: demisto/python3:3.10.14.91134
runas: DBotRole
tests:
- No tests (auto formatted)
Expand Down
2 changes: 1 addition & 1 deletion Packs/EmailCommunication/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Email Communication",
"description": "Do you have to send multiple emails to end users? This content pack helps you streamline the process and automate updates, notifications and more.\n",
"support": "xsoar",
"currentVersion": "2.0.26",
"currentVersion": "2.0.27",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"videos": [
Expand Down
Expand Up @@ -1275,7 +1275,8 @@ def parse_incident_from_item(item, is_fetch): # pragma: no cover
# save attachment to incident
incident['attachment'].append({
'path': file_result['FileID'],
'name': get_attachment_name(attachment.name)
'name': get_attachment_name(attachment.name),
"description": FileAttachmentType.ATTACHED if not attachment.is_inline else ""
})
except TypeError as e:
if str(e) != "must be string or buffer, not None":
Expand Down Expand Up @@ -1323,12 +1324,14 @@ def parse_incident_from_item(item, is_fetch): # pragma: no cover
# save attachment to incident
incident['attachment'].append({
'path': file_result['FileID'],
'name': get_attachment_name(attachment.name) + ".eml"
'name': get_attachment_name(attachment.name) + ".eml",
"description": FileAttachmentType.ATTACHED if not attachment.is_inline else ""
})

else:
incident['attachment'].append({
'name': get_attachment_name(attachment.name) + ".eml"
'name': get_attachment_name(attachment.name) + ".eml",
"description": FileAttachmentType.ATTACHED if not attachment.is_inline else ""
})

labels.append({'type': label_attachment_type, 'value': get_attachment_name(attachment.name)})
Expand Down
6 changes: 6 additions & 0 deletions Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_2.md
@@ -0,0 +1,6 @@

#### Integrations

##### EWS v2

- Fixed an issue in **Fetch incident** with inline image attachments in *PreprocessEmail* script by adding description field to attachments to distinguish file attachments from inline images.
2 changes: 1 addition & 1 deletion Packs/MicrosoftExchangeOnPremise/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Microsoft Exchange On-Premise",
"description": "Exchange Web Services",
"support": "xsoar",
"currentVersion": "2.1.1",
"currentVersion": "2.1.2",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Expand Up @@ -2169,6 +2169,7 @@ def parse_incident_from_item(item): # pragma: no cover
{
"path": file_result["FileID"],
"name": get_attachment_name(attachment.name),
"description": FileAttachmentType.ATTACHED if not attachment.is_inline else "",
}
)
except TypeError as e:
Expand Down Expand Up @@ -2261,6 +2262,7 @@ def parse_incident_from_item(item): # pragma: no cover
{
"path": file_result["FileID"],
"name": get_attachment_name(attachment.name, eml_extension=True),
"description": FileAttachmentType.ATTACHED if not attachment.is_inline else "",
}
)

Expand Down
Expand Up @@ -959,7 +959,7 @@ script:
- description: Run this command if for some reason you need to rerun the authentication process.
name: ews-auth-reset
arguments: []
dockerimage: demisto/py3ews:1.0.0.88266
dockerimage: demisto/py3ews:1.0.0.91453
isfetch: true
script: ''
subtype: python3
Expand Down
7 changes: 7 additions & 0 deletions Packs/MicrosoftExchangeOnline/ReleaseNotes/1_2_46.md
@@ -0,0 +1,7 @@

#### Integrations

##### EWS O365

- Fixed an issue in **Fetch incident** with inline image attachments in *PreprocessEmail* script by adding description field to attachments to distinguish file attachments from inline images.
- Updated the Docker image to: *demisto/py3ews:1.0.0.91453*.
2 changes: 1 addition & 1 deletion Packs/MicrosoftExchangeOnline/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Microsoft Exchange Online",
"description": "Exchange Online and Office 365 (mail)",
"support": "xsoar",
"currentVersion": "1.2.45",
"currentVersion": "1.2.46",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down