Skip to content

Commit

Permalink
Fix gmail get mail context output (#31342)
Browse files Browse the repository at this point in the history
* update context path

* added RN

* updated readme

* update docker

* added run get attachments argument

* pre commit fixes

* pre commit fixes

* cr fixes

* cr fixes

* cr fixes

* update RN

* update docker
  • Loading branch information
YuvHayun committed Dec 10, 2023
1 parent 09d4282 commit 5ce21b9
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 14 deletions.
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('include-attachments', '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
Expand Up @@ -207,6 +207,28 @@ script:
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 @@ script:
- metadata
- minimal
- raw
- auto: PREDEFINED
defaultValue: False
description: Whether to include the attachment entries in the result or not.
name: include-attachments
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 @@ script:
- contextPath: Gmail.Body
description: The content of the email.
type: string
- contextPath: Gmail.Attachments
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 @@ script:
- contextPath: Email.Headers
description: The headers of the email.
type: String
- contextPath: Email.Attachments.entryID
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 include-attachments is set to True. The MD5 hash of the file.
type: String
- contextPath: File.SHA1
description: Relevant only when include-attachments is set to True. The SHA1 hash of the file.
type: String
- contextPath: File.SHA256
description: Relevant only when include-attachments is set to True. The SHA256 hash of the file.
type: String
- contextPath: File.Name
description: Relevant only when include-attachments is set to True. The name of the file.
type: String
- contextPath: File.SSDeep
description: Relevant only when include-attachments 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 include-attachments is set to True. File type, for example: "PE".'
type: string
- contextPath: File.Size
description: Relevant only when include-attachments 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 @@ script:
- 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.82944
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 |

| include-attachments | Whether to include the attachment entries in the result 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 include-attachments is set to True. The file name. |
| File.MD5 | String | Relevant only when include-attachments is set to True. The MD5 hash of the file. |
| File.SHA1 | String | Relevant only when include-attachments is set to True. The SHA1 hash of the file. |
| File.SHA256 | String | Relevant only when include-attachments is set to True. The SHA256 hash of the file. |
| File.Type | String | Relevant only when include-attachments is set to True. The file type, as determined by libmagic \(same as displayed in file entries\). |
| File.Size | Number | Relevant only when include-attachments is set to True. The size of the file in bytes. |
| File.SSDeep | String | Relevant only when include-attachments is set to True. The SSDeep hash of the file \(same as displayed in file entries\). |

#### Command Example

Expand Down
4 changes: 4 additions & 0 deletions Packs/Gmail/ReleaseNotes/1_3_15.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"breakingChanges":true,
"breakingChangesNotes":"Removed the **Email.Attachments.entryID**, **Gmail.Attachments** context entries from the **gmail-get-mail** command."
}
10 changes: 10 additions & 0 deletions Packs/Gmail/ReleaseNotes/1_3_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#### Integrations

##### Gmail

- Updated the Docker image to: *demisto/google-api-py3:1.0.0.82944*.
- 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.
- **Note**: Removed the **Email.Attachments.entryID**, **Gmail.Attachments** context entries from the **gmail-get-mail** command.
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

0 comments on commit 5ce21b9

Please sign in to comment.