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

Fix gmail get mail context output #31342

Merged
merged 12 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
8 changes: 7 additions & 1 deletion Packs/Gmail/Integrations/Gmail/Gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,9 +1478,15 @@ def get_mail_command():
user_id = args.get('user-id', ADMIN_EMAIL)
_id = args.get('message-id')
_format = args.get('format')
should_run_get_attachments = argToBoolean(args.get('run-get-attachments-command', 'false'))

mail = get_mail(user_id, _id, _format)
return emails_to_entry('Email:', [mail], _format, user_id)
email_entry = emails_to_entry('Email:', [mail], _format, user_id)
results = [email_entry]
if should_run_get_attachments:
get_attachments_command_results = get_attachments_command()
results.append(get_attachments_command_results) # type: ignore
return results


def get_mail(user_id, _id, _format, service=None):
Expand Down
68 changes: 62 additions & 6 deletions Packs/Gmail/Integrations/Gmail/Gmail.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Email

Check failure on line 1 in Packs/Gmail/Integrations/Gmail/Gmail.yml

View workflow job for this annotation

GitHub Actions / pre-commit

Validation Error BC102

Possible backwards compatibility break, You've changed the context in the file,please undo. the command is: gmail-get-mail
sectionOrder:
- Connect
- Collect
Expand Down Expand Up @@ -207,6 +207,28 @@
required: true
description: Retrieves attachments from a sent Gmail message.
name: gmail-get-attachments
outputs:
- contextPath: File.MD5
description: The MD5 hash of the file.
type: String
- contextPath: File.SHA1
description: The SHA1 hash of the file.
type: String
- contextPath: File.SHA256
description: The SHA256 hash of the file.
type: String
- contextPath: File.Name
description: The name of the file.
type: String
- contextPath: File.SSDeep
description: The SSDeep hash of the file (same as displayed in file entries).
type: String
- contextPath: File.Type
description: 'File type, for example: "PE".'
type: string
- contextPath: File.Size
description: File size.
type: number
- arguments:
- default: true
description: The user's email address. The "me" special value can be used to indicate the authenticated user.
Expand All @@ -224,6 +246,13 @@
- metadata
- minimal
- raw
- auto: PREDEFINED
defaultValue: False
description: Wether ro run gmail-get-attachments as well or not.
YuvHayun marked this conversation as resolved.
Show resolved Hide resolved
name: run-get-attachments-command
YuvHayun marked this conversation as resolved.
Show resolved Hide resolved
predefined:
- 'False'
- 'True'
description: Retrieves the Gmail message sent to a specified user.
name: gmail-get-mail
outputs:
Expand Down Expand Up @@ -257,9 +286,12 @@
- contextPath: Gmail.Body
description: The content of the email.
type: string
- contextPath: Gmail.Attachments
YuvHayun marked this conversation as resolved.
Show resolved Hide resolved
description: The attachments of the email. Attachments IDs are separated by commas.
type: unknown
- contextPath: Gmail.Attachments.ID
description: The email attachment ID (as appear in gmail).
type: Unknown
- contextPath: Gmail.Attachments.Name
description: The email attachment name.
type: Unknown
- contextPath: Gmail.Headers
description: All headers of the specific email (list).
type: unknown
Expand Down Expand Up @@ -293,12 +325,36 @@
- contextPath: Email.Headers
description: The headers of the email.
type: String
- contextPath: Email.Attachments.entryID
YuvHayun marked this conversation as resolved.
Show resolved Hide resolved
description: Comma-separated email attachment IDs.
- contextPath: Email.Attachments.ID
description: The email attachment ID (as appear in gmail).
type: Unknown
- contextPath: Email.Attachments.Name
description: The email attachment name.
type: Unknown
- contextPath: Email.Date
description: The date the email was received.
type: String
- contextPath: File.MD5
description: Relevant only when run-get-attachments-command is set to True. The MD5 hash of the file.
type: String
- contextPath: File.SHA1
description: Relevant only when run-get-attachments-command is set to True. The SHA1 hash of the file.
type: String
- contextPath: File.SHA256
description: Relevant only when run-get-attachments-command is set to True. The SHA256 hash of the file.
type: String
- contextPath: File.Name
description: Relevant only when run-get-attachments-command is set to True. The name of the file.
type: String
- contextPath: File.SSDeep
description: Relevant only when run-get-attachments-command is set to True. The SSDeep hash of the file (same as displayed in file entries).
type: String
- contextPath: File.Type
description: 'Relevant only when run-get-attachments-command is set to True. File type, for example: "PE".'
type: string
- contextPath: File.Size
description: Relevant only when run-get-attachments-command is set to True. File size.
type: number
- arguments:
- default: true
description: The user's email address. The "me" special value can be used to indicate the authenticated user.
Expand Down Expand Up @@ -1659,7 +1715,7 @@
- contextPath: Gmail.ForwardingAddress.verificationStatus
description: Indicates whether this address has been verified and is usable for forwarding.
type: String
dockerimage: demisto/google-api-py3:1.0.0.77314
dockerimage: demisto/google-api-py3:1.0.0.82605
isfetch: true
runonce: false
script: '-'
Expand Down
29 changes: 23 additions & 6 deletions Packs/Gmail/Integrations/Gmail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,16 @@ Retrieves attachments from a sent Gmail message.

#### Context Output

There is no context output for this command.

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| File.Name | String | The file name. |
| File.MD5 | String | The MD5 hash of the file. |
| File.SHA1 | String | The SHA1 hash of the file. |
| File.SHA256 | String | The SHA256 hash of the file. |
| File.Type | String | The file type, as determined by libmagic \(same as displayed in file entries\). |
| File.Size | Number | The size of the file in bytes. |
| File.SSDeep | String | The SSDeep hash of the file \(same as displayed in file entries\). |


#### Command Example
Expand All @@ -450,7 +459,7 @@ Retrieves the Gmail message sent to a specified user.
| user-id | The user's email address. The "me" special value can be used to indicate the authenticated user. | Required |
| message-id | The ID of the email to retrieve. You can get the ID by running the gmail-search command, or by fetching mails and copy the incident.labels.Email/ID value from the fetched incident context. | Required |
| format | The format to return the message. Can be: "full": Returns the full email message data with body content parsed in the payload field; the raw field is not used. (default) / "metadata": Returns only the email message ID, labels, and email headers / "minimal": Returns only the email message ID and labels; does not return the email headers, body, or payload / "raw": Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used. Possible values are: full, metadata, minimal, raw. Default is full. | Optional |

| run-get-attachments-command | Wether ro run gmail-get-attachments as well or not. (Default: false). Possible values are: False, True. Default is False. | Optional |

#### Context Output

Expand All @@ -466,7 +475,8 @@ Retrieves the Gmail message sent to a specified user.
| Gmail.Bcc | string | The additional recipient email address \(BCC\). |
| Gmail.Subject | string | The subject of the email. |
| Gmail.Body | string | The content of the email. |
| Gmail.Attachments | unknown | The attachments of the email. Attachments IDs are separated by commas. |
| Gmail.Attachments.ID | String | The email attachment ID (as appear in gmail). |
| Gmail.Attachments.Name | String | The email attachment name. |
| Gmail.Headers | unknown | All headers of the specific email \(list\). |
| Gmail.Mailbox | string | The email mailbox. |
| Email.To | String | The recipient of the email. |
Expand All @@ -478,9 +488,16 @@ Retrieves the Gmail message sent to a specified user.
| Email.Body/Text | String | The plain-text version of the email. |
| Email.Subject | String | The subject of the email. |
| Email.Headers | String | The headers of the email. |
| Email.Attachments.entryID | Unknown | Comma-separated email attachment IDs. |
| Email.Date | String | The date the email was received. |

| Email.Attachments.ID | String | The email attachment ID (as appear in gmail). |
| Email.Attachments.Name | String | The email attachment name. |
| Email.Date | String | The date the email was received. |
| File.Name | String | Relevant only when run-get-attachments-command is set to True. The file name. |
| File.MD5 | String | Relevant only when run-get-attachments-command is set to True. The MD5 hash of the file. |
| File.SHA1 | String | Relevant only when run-get-attachments-command is set to True. The SHA1 hash of the file. |
| File.SHA256 | String | Relevant only when run-get-attachments-command is set to True. The SHA256 hash of the file. |
| File.Type | String | Relevant only when run-get-attachments-command is set to True. The file type, as determined by libmagic \(same as displayed in file entries\). |
| File.Size | Number | Relevant only when run-get-attachments-command is set to True. The size of the file in bytes. |
| File.SSDeep | String | Relevant only when run-get-attachments-command is set to True. The SSDeep hash of the file \(same as displayed in file entries\). |

#### Command Example

Expand Down
9 changes: 9 additions & 0 deletions Packs/Gmail/ReleaseNotes/1_3_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#### Integrations

##### Gmail

- Updated the Docker image to: *demisto/google-api-py3:1.0.0.82605*.
- Added the argument **run-get-attachments-command** to **gmail-get-mail** to determine wether to retrieve the attachments with the **gmail-get-mail** command or not.
- Updated the **gmail-get-mail** command context path to support attachment ids & names.
- Updated the **gmail-get-attachments** command context path to support file entry context output.
2 changes: 1 addition & 1 deletion Packs/Gmail/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Gmail",
"description": "Gmail API and user management (This integration replaces the Gmail functionality in the GoogleApps API and G Suite integration).",
"support": "xsoar",
"currentVersion": "1.3.14",
"currentVersion": "1.3.15",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down