From b534a9888cc5da5eb103640dfa3c06545c3dff15 Mon Sep 17 00:00:00 2001 From: Sapir Malka <44067957+itssapir@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:08:35 +0300 Subject: [PATCH] Ciac 9334 smime messaging enhancement (#35765) * SMIME Messaging Enhancement (CIAC-9334) - smime-sign-and-encrypt modified to the new design - Multi recipient support added (to, cc, bcc) - Support for mail attachments - Support for html as well as plain-text - Added mail headers, now gets correctly displayed by email clients - Added file output - Updated encryption cipher to 'aes_256_cbc' - Updated signature algorithm to sha256 - smime-verify - added warning regarding no CA verification to the description - added message/attachments/images parsing before output - added tags and raw_output input arguments - smime-encrypt - added message/attachments/images parsing before output if possible - added tags and raw_output input arguments - Deprecated 'smime-encrypt-email-body' - Deprecated 'smime-sign-email' --- .../Integrations/SMIME_Messaging/README.md | 1007 +++++++---------- .../SMIME_Messaging/SMIME_Messaging.py | 592 ++++++++-- .../SMIME_Messaging/SMIME_Messaging.yml | 95 +- .../SMIME_Messaging_description.md | 17 +- .../SMIME_Messaging/SMIME_Messaging_test.py | 512 ++++++++- .../SMIME_Messaging/test_data/attachment1.txt | 1 + .../SMIME_Messaging/test_data/attachment2.txt | 1 + .../test_data/encrypted-binary-format.p7m | Bin 0 -> 641 bytes .../SMIME_Messaging/test_data/recipient2.pem | 17 + .../test_data/recipient2_key.pem | 16 + .../test_data/signed-binary-format.p7m | Bin 0 -> 1369 bytes Packs/SMIME_Messaging/ReleaseNotes/2_0_0.md | 19 + .../TestPlaybooks/SMIME_Messaging-Test.yml | 260 +++++ Packs/SMIME_Messaging/pack_metadata.json | 2 +- Tests/conf.json | 11 + 15 files changed, 1822 insertions(+), 728 deletions(-) create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment1.txt create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment2.txt create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/encrypted-binary-format.p7m create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2.pem create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2_key.pem create mode 100644 Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/signed-binary-format.p7m create mode 100644 Packs/SMIME_Messaging/ReleaseNotes/2_0_0.md create mode 100644 Packs/SMIME_Messaging/TestPlaybooks/SMIME_Messaging-Test.yml diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/README.md b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/README.md index 9df2bc8fb997..981cf8738de6 100644 --- a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/README.md +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/README.md @@ -1,611 +1,424 @@ -

Use the S/MIME (Secure Multipurpose Internet Mail Extensions) integration to send and receive secure MIME data. +This integration was integrated and tested with version 0.40.1 of M2Crypto. -

-

Use Cases

- - -

Usage

-

-In order to send signed/encrypted messages using the S/MIME Messaging and Mail Sender (New) perform the following steps. - -1. Run the required command in the S/MIME Messaging integration (e.g., `smime-sign-and-encrypt`). -2. Enter the output of the command executed from step 1 as the input for the `raw_message` argument of the `send-mail` command in the Mail Sender (New) integration (e.g. the value stored in the Context Data under `SMIME.SignedAndEncrypted.Message`). -3. Run the `send-mail` command with the `raw_message` argument (as described in step 2), with any of the optional arguments `to`, `cc` and `bcc` (e.g., `!send-mail to=user@email.com raw_message=${SMIME.SignedAndEncrypted.Message}`). -

- -

Configure SMIME Messaging on Cortex XSOAR

-
    -
  1. Navigate to Settings > Integrations -  > Servers & Services.
  2. -
  3. Search for SMIME Messaging.
  4. -
  5. - Click Add instance to create and configure a new integration instance. - -
  6. -
  7. - Click Test to validate the new instance. -
  8. -
-

Commands

-

- You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook. - After you successfully execute a command, a DBot message appears in the War Room with the command details. -

-
    -
  1. smime-sign-email: smime-sign-email
  2. -
  3. smime-encrypt-email-body: smime-encrypt-email-body
  4. -
  5. smime-verify-sign: smime-verify-sign
  6. -
  7. smime-decrypt-email-body: smime-decrypt-email-body
  8. -
  9. smime-sign-and-encrypt: smime-sign-and-encrypt
  10. -
-

1. smime-sign-email

-
-

Retrieves items from the service.

-
Base Command
-

- smime-sign-email -

- -
Required Permissions
-

The following permissions are required for this command.

- -
Input
- - - - - - - - - - - - - - - - - - - - -
- Argument Name - - Description - - Required -
message_bodyThe message body to send.Required
use_transport_encodingSet 'true' to use content transfer encoding.Optional
- -

 

-
Context Output
- - - - - - - - - - - - - - - - - - - - -
- Path - - Type - - Description -
SMIME.Signed.MessageStringThe signed message body.
SMIME.Signed.HeadersStringThe S/MIME signing headers.
- -

 

-
Command Example
-

- !smime-sign-email message_body="Hello World" -

-
Context Example
-
+## Use Cases
+
+- Send an S/MIME-signed message.
+- Send an S/MIME-encrypted message.
+- Send an S/MIME-signed and encrypted message.
+- Decrypt an S/MIME message.
+
+## Usage
+
+- In order to send signed/encrypted messages using the S/MIME Messaging and Mail Sender (New) perform the following steps:
+
+    1. Run the `smime-sign-and-encrypt` command with the required parameters.
+    2. Enter the output message from step 1 as the input for the `raw_message` argument of the `send-mail` command in the Mail Sender (New) integration (e.g., the value stored in the Context Data under `SMIME.SignedAndEncrypted.Message`).
+    3. Run the `send-mail` command with the `raw_message` argument (as described in step 2), with any of the optional arguments `to`, `cc` and `bcc` (e.g., `!send-mail to=user@email.com raw_message=${SMIME.SignedAndEncrypted.Message}`).
+
+- While decrypting or verifying a message, S/MIME Messaging will attempt to parse the message into readable text, as well as extract any attachments and images if present. If you wish to get the raw message instead, use the raw_output argument.
+
+## Configure SMIME Messaging on Cortex XSOAR
+
+1. Navigate to **Settings** > **Integrations** > **Servers & Services**.
+2. Search for SMIME Messaging.
+3. Click **Add instance** to create and configure a new integration instance.
+
+    | **Parameter** | **Description** | **Required** |
+    | --- | --- | --- |
+    | Public Key | Sender public key required for signing emails. | True |
+    | Private Key | Sender private key required for decrypting and signing emails. | True |
+
+4. Click **Test** to validate the URLs, token, and connection.
+
+## Commands
+
+You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook.
+After you successfully execute a command, a DBot message appears in the War Room with the command details.
+
+### smime-verify-sign
+
+***
+Verifies the signature.
+
+Warning: This function does not check the CA chain. Ensure the certificate chain is validated separately to avoid security risks.
+
+#### Base Command
+
+`smime-verify-sign`
+
+#### Input
+
+| **Argument Name** | **Description** | **Required** |
+| --- | --- | --- |
+| signed_message | Entity ID of the file with a .p7 extension containing the signed message. | Required | 
+| public_key | Sender's public key to verify. Default is instancePublicKey. | Optional | 
+| raw_output | Whether to get the full raw output of the email. Possible values are: false, true. | Optional | 
+| tag | A comma-separated list of tags to be included in the War Room output. | Optional | 
+
+#### Context Output
+
+| **Path** | **Type** | **Description** |
+| --- | --- | --- |
+| SMIME.Verified.Message | String | The decoded signed message. | 
+
+#### Command example
+
+```!smime-verify-sign signed_message=454@6cc2adad-6d3b-4fec-8b98-99b1b1770bc5```
+
+#### Context Example
+
+```json
+{
+    "SMIME": {
+        "Verified": {
+            "Message": "This is a message to sign"
+        }
+    }
+}
+```
+
+#### Human Readable Output
+
+>### The signature verified, message is: 
+>
+>***
+> This is a message to sign
+
+### smime-decrypt-email-body
+
+***
+Decrypts the message body.
+
+#### Base Command
+
+`smime-decrypt-email-body`
+
+#### Input
+
+| **Argument Name** | **Description** | **Required** |
+| --- | --- | --- |
+| encrypt_message | Entity ID of the file with a .p7 extension containing the encrypted email. | Required | 
+| encoding | The encoding code to use when decoding the message body, e.g., 'ISO-8859-2''. | Optional | 
+| raw_output | Whether to get the full raw output of the email. Possible values are: false, true. | Optional | 
+| tag | A comma-separated list of tags to be included in the War Room output. | Optional | 
+
+#### Context Output
+
+| **Path** | **Type** | **Description** |
+| --- | --- | --- |
+| SMIME.Decrypted.Message | String | The decrypted message. | 
+
+#### Command example
+
+```!smime-decrypt-email-body encrypt_message=451@6cc2adad-6d3b-4fec-8b98-99b1b1770bc5```
+
+#### Context Example
+
+```json
 {
-    "SMIME.Signed": {
-        "Headers": "MIME-Version=1.0,Content-Type=multipart/signed; protocol=\"application/x-pkcs7-signature\"; micalg=\"sha1\"; boundary=\"----5DAD2A4AC7C108E6B3D263AADB9D2BDB\"",
-        "Message": "MIME-Version: 1.0\nContent-Type: multipart/signed; protocol=\"application/x-pkcs7-signature\"; micalg=\"sha1\"; boundary=\"----5DAD2A4AC7C108E6B3D263AADB9D2BDB\"\n\nThis is an S/MIME signed message\n\n------5DAD2A4AC7C108E6B3D263AADB9D2BDB\nContent-Type: text/plain\r\n\r\nHello World\n------5DAD2A4AC7C108E6B3D263AADB9D2BDB\nContent-Type: application/x-pkcs7-signature; name=\"smime.p7s\"\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename=\"smime.p7s\"\n\nMIIGEQYJKoZIhvcNAQcCoIIGAjCCBf4CAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3\nDQEHAaCCA1wwggNYMIICQAIJAO117pJfuoxMMA0GCSqGSIb3DQEBCwUAMG4xCzAJ\nBgNVBAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBu\nZXR3b3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWlj\ncm9zb2Z0LmNvbTAeFw0xOTEwMTcxOTMxMThaFw0yMDEwMTYxOTMxMThaMG4xCzAJ\nBgNVBAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBu\nZXR3b3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWlj\ncm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKOg9k/f\noKdoYZpVwxy6vdFEy7Bo7DLBHUf5WSmyO88kjtv2HGTZKPwCDbuZfi4643nkEtFp\nbPWFwIBbfICsOxdL6P4Oj1IOcVnIN0ohT7DEsgb69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hkiG9w0DAgIBQDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEF\nAASCAQCSXAiT+9rmR964OgTOWgebTU2KooxChBAoKUOWXJDi1/25uTjs8OJcrfDy\nN4OAGaP/mjfDEYbkEXMYC6lDcSErYdGGegACNURJlh+fIh3ZBrbdWnh8B672g9Zx\nFIDM7MxtDEdt9ScNAaqKiZCKsZlk4bcXGLK6oI8PUUsLupgUhdTiKHplKbrsUBC8\nJckJ+xSbRHP2dQTAYr0LW87lvVQgi05hmKecICuTDU3/qSqTZbh/ajQk7HHB9XtI\nPmizUK2s+F3OazeJx0IFpeEeK4YIVxV+tbYQkNrZTxwe7sKFkcyfiJ2QGcw8hzly\nfRciC1z2msLtmgPUH81DqLx+B+pY\n\n------5DAD2A4AC7C108E6B3D263AADB9D2BDB--\n\n"
+    "SMIME": {
+        "Decrypted": {
+            "Message": "This is a message to encrypt"
+        }
     }
 }
-
-
Human Readable Output
-

-

-MIME-Version: 1.0 -Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha1"; boundary="----5DAD2A4AC7C108E6B3D263AADB9D2BDB" - -This is an S/MIME signed message - -------5DAD2A4AC7C108E6B3D263AADB9D2BDB -Content-Type: text/plain - -Hello World -------5DAD2A4AC7C108E6B3D263AADB9D2BDB -Content-Type: application/x-pkcs7-signature; name="smime.p7s" -Content-Transfer-Encoding: base64 -Content-Disposition: attachment; filename="smime.p7s" - -MIIGEQYJKoZIhvcNAQcCoIIGAjCCBf4CAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3 -DQEHAaCCA1wwggNYMIICQAIJAO117pJfuoxMMA0GCSqGSIb3DQEBCwUAMG4xCzAJ -BgNVBAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBu -ZXR3b3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWlj -cm9zb2Z0LmNvbTAeFw0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ZIhvcNAQkBFiJh -dmlzaGFpQGRlbWlzdG9kZXYub25taWNyb3NvZnQuY29tAgkA7XXukl+6jEwwCQYF -Kw4DAhoFAKCB2DAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJ -BTEPFw0xOTEwMjkwOTA0NTRaMCMGCSqGSIb3DQEJBDEWBBRTe/xmyOR/ymt0oatw -pHauxOm1STB5BgkqhkiG9w0BCQ8xbDBqMAsGCWCGSAFlAwQBKjALBglghkgBZQME -ARYwCwYJYIZIAWUDBAECMAoGCCqGSIb3DQMHMA4GCCqGSIb3DQMCAgIAgDANBggq -hkiG9w0DAgIBQDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEF -AASCAQCSXAiT+9rmR964OgTOWgebTU2KooxChBAoKUOWXJDi1/25uTjs8OJcrfDy -N4OAGaP/mjfDEYbkEXMYC6lDcSErYdGGegACNURJlh+fIh3ZBrbdWnh8B672g9Zx -FIDM7MxtDEdt9ScNAaqKiZCKsZlk4bcXGLK6oI8PUUsLupgUhdTiKHplKbrsUBC8 -JckJ+xSbRHP2dQTAYr0LW87lvVQgi05hmKecICuTDU3/qSqTZbh/ajQk7HHB9XtI -PmizUK2s+F3OazeJx0IFpeEeK4YIVxV+tbYQkNrZTxwe7sKFkcyfiJ2QGcw8hzly -fRciC1z2msLtmgPUH81DqLx+B+pY - -------5DAD2A4AC7C108E6B3D263AADB9D2BDB-- -

-

- -

2. smime-encrypt-email-body

-
-

Encrypts an email message with S/MIME protocol by using a public RSA certificate.

-
Base Command
-

- smime-encrypt-email-body -

- -
Required Permissions
-

The following permissions are required for this command.

- -
Input
- - - - - - - - - - - - - - - -
- Argument Name - - Description - - Required -
messageThe message body to encrypt.Required
- -

 

-
Context Output
- - - - - - - - - - - - - - - - - - - - -
- Path - - Type - - Description -
SMIME.Encrypted.MessageStringThe encrypted message.
SMIME.Encrypted.HeadersStringThe encryption headers.
- -

 

-
Command Example
-

- !smime-encrypt-email-body message="Hello World" -

-
Context Example
-
+```
+
+#### Human Readable Output
+
+>### The decrypted message is: 
+>
+>***
+> This is a message to encrypt
+
+### smime-sign-and-encrypt
+
+***
+Encrypts and signs an email message with S/MIME protocol by using a public RSA certificate.
+
+#### Base Command
+
+`smime-sign-and-encrypt`
+
+#### Input
+
+| **Argument Name** | **Description** | **Required** |
+| --- | --- | --- |
+| message | The message body to encrypt and sign. | Required | 
+| recipients | JSON dict of recipients and their public keys
Format: {"recipient@email":"cert", "other@email":"cert"}
Use "instancePublicKey" in the cert field to use the instance certificate. | Optional | +| cc | JSON dict of cc recipients and their public keys
Format: {"cc@email":"cert", "othercc@email":"cert"}
Use "instancePublicKey" in the cert field to use the instance certificate. | Optional | +| bcc | JSON dict of bcc recipients and their public keys
Format: {"bcc@email":"cert", "otherbcc@email":"cert"}
Use "instancePublicKey" in the cert field to use the instance certificate. | Optional | +| attachment_entry_id | List of War Room entry IDs of files to attach to the mail. | Optional | +| signed | Whether the mail should be signed. Possible values are: true, false. Default is true. | Optional | +| encrypted | Whether the mail should be encrypted. Possible values are: true, false. Default is true. | Optional | +| sender | Sender email address. | Optional | +| subject | Email subject. | Optional | +| create_file_p7 | Whether to create a file with the encrypted/signed content. Possible values are: false, true. | Optional | + +#### Context Output + +| **Path** | **Type** | **Description** | +| --- | --- | --- | +| SMIME.SignedAndEncrypted.Message | String | The raw message to send. | +| SMIME.SignedAndEncrypted.RecipientIds | String | Address of the recipient. | +| SMIME.SignedAndEncrypted.FileName | String | Name of the file output if create_file_p7 is used. | + +#### Command example + +```!smime-sign-and-encrypt message="This is a message to sign" encrypted=false``` + +#### Context Example + +```json { - "SMIME.Encrypted": { - "Headers": "MIME-Version=1.0,Content-Disposition=attachment; filename=\"smime.p7m\",Content-Type=application/x-pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m\",Content-Transfer-Encoding=base64", - "Message": "MIME-Version: 1.0\nContent-Disposition: attachment; filename=\"smime.p7m\"\nContent-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m\"\nContent-Transfer-Encoding: base64\n\nMIIB5gYJKoZIhvcNAQcDoIIB1zCCAdMCAQAxggGXMIIBkwIBADB7MG4xCzAJBgNV\nBAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBuZXR3\nb3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWljcm9z\nb2Z0LmNvbQIJAO117pJfuoxMMA0GCSqGSIb3DQEBAQUABIIBAHIauLY6zZviXMfo\ngiAH00ugmMrOf8kWXyXzTtY8ujb0q3FWCLjm3SQvozuiyH+hfpFAaCqq2WLviHx7\ne1f+NtdDuaJuoANHl0WfYUNW2UUhzQkRFUVJZRnsr9W8uhhRNYPv5SD/g7G/xWMs\n+cfrJOAd2q3AwRHvcEVFW+xNNHoQDCk2KcjLiE5Vr2q5Fly2Gyxhs1iZ5Yq1bq2O\nczqUdgV8Uh6pxJ8t+n31GvrBSLA3xo1MwV6Nvj1AGYTQx53jDp9H0NSjqw8/LURP\n6jeH8uuF7/0flJmPfJigx/fYXfg2tCRdI75UMIm+0zywG0NDCk4l3PLM3iqi+sej\nNG8dZ3YwMwYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAhJHDbFpz5R94AQ6QST/8pU\nijTpyt7V40F8Pg==\n\n" + "SMIME": { + "SignedAndEncrypted": { + "FileName": "", + "Message": "Date: Mon, 05 Aug 2024 08:56:00 +0000\r\nMIME-Version: 1.0\nContent-Disposition: attachment; filename=\"smime.p7m\"\nContent-Type: application/x-pkcs7-mime; smime-type=signed-data; name=\"smime.p7m\"\nContent-Transfer-Encoding: base64\n\nMIIJ4gYJKoZIhvcNAQcCoIIJ0zCCCc8CAQExDzANBglghkgBZQMEAgEFADCCAUkG\nCSqGSIb3DQEHAaCCAToEggE2Q29udGVudC1UeXBlOiBtdWx0aXBhcnQvbWl4ZWQ7\nIGJvdW5kYXJ5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iWoAo/F4X9fEOm5dMVHzjYxTA0R0+Dzny4\nSmKlkzd3gUH4kEtgTBo8slRkO5dfg8Ik64qnQNvSidLWp9PmKkGb2069czQCyKIj\nme4sPRRl8TJQ12xVuOmlRpQ4+rUxhMfZKyyYZ0isoVNYsmeFPQ8=\n\n", + "RecipientIds": { + "bcc": [], + "cc": [], + "to": [] + } + } } } -
-
Human Readable Output
-

-

-MIME-Version: 1.0 -Content-Disposition: attachment; filename="smime.p7m" -Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m" -Content-Transfer-Encoding: base64 - -MIIB5gYJKoZIhvcNAQcDoIIB1zCCAdMCAQAxggGXMIIBkwIBADB7MG4xCzAJBgNV -BAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBuZXR3 -b3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWljcm9z -b2Z0LmNvbQIJAO117pJfuoxMMA0GCSqGSIb3DQEBAQUABIIBAHIauLY6zZviXMfo -giAH00ugmMrOf8kWXyXzTtY8ujb0q3FWCLjm3SQvozuiyH+hfpFAaCqq2WLviHx7 -e1f+NtdDuaJuoANHl0WfYUNW2UUhzQkRFUVJZRnsr9W8uhhRNYPv5SD/g7G/xWMs -+cfrJOAd2q3AwRHvcEVFW+xNNHoQDCk2KcjLiE5Vr2q5Fly2Gyxhs1iZ5Yq1bq2O -czqUdgV8Uh6pxJ8t+n31GvrBSLA3xo1MwV6Nvj1AGYTQx53jDp9H0NSjqw8/LURP -6jeH8uuF7/0flJmPfJigx/fYXfg2tCRdI75UMIm+0zywG0NDCk4l3PLM3iqi+sej -NG8dZ3YwMwYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAhJHDbFpz5R94AQ6QST/8pU -ijTpyt7V40F8Pg== -

-

- -

3. smime-verify-sign

-
-

Verifies the signature.

-
Base Command
-

- smime-verify-sign -

- -
Required Permissions
-

The following permissions are required for this command.

- -
Input
- - - - - - - - - - - - - - - -
- Argument Name - - Description - - Required -
signed_messageThe signed email with .p7 extension.Required
- -

 

-
Context Output
-There are no context output for this command. -

 

-
Command Example
-

- !smime-verify-sign signed_message=3828@09847cac-04e1-459f-8b56-9385b4fcb06e -

-
Context Example
-
-{}
-
-
Human Readable Output
-

-

-The signature verified -b'a sign of our times' -

-

- -

4. smime-decrypt-email-body

-
-

Decrypts the message body. Please note we are using chardet module to find the correct encoding for the given text. Detected types are shown here. - If you need to use different encoding to decode the message body, you can use the encoding argument when executing command. -

-
Base Command
-

- smime-decrypt-email-body -

- -
Required Permissions
-

The following permissions are required for this command.

- -
Input
- - - - - - - - - - - - - - - - - - - - -
- Argument Name - - Description - - Required -
encrypt_messageThe encrypted message with .p7 extension.Required
encodingThe encoding code to use when decode the message body, e.g 'ISO-8859-2'. You can find description of the different encoding types here.
- -

 

-
Context Output
- - - - - - - - - - - - - - - -
- Path - - Type - - Description -
SMIME.Decrypted.MessageStringThe decrypted message.
- -

 

-
Command Example
-

- !smime-decrypt-email-body encrypt_message=3833@09847cac-04e1-459f-8b56-9385b4fcb06e -

-
Context Example
-
+```
+
+#### Human Readable Output
+
+>Date: Mon, 05 Aug 2024 08:56:00 +0000
+>MIME-Version: 1.0
+>Content-Disposition: attachment; filename="smime.p7m"
+>Content-Type: application/x-pkcs7-mime; smime-type=signed-data; name="smime.p7m"
+>Content-Transfer-Encoding: base64
+>
+>MIIJ4gYJKoZIhvcNAQcCoIIJ0zCCCc8CAQExDzANBglghkgBZQMEAgEFADCCAUkG
+>CSqGSIb3DQEHAaCCAToEggE2Q29udGVudC1UeXBlOiBtdWx0aXBhcnQvbWl4ZWQ7
+>IGJvdW5kYXJ5PSI9PT09PT09PT09PT09PT0wNTEzMzU2NzMxMDg3NTk4NjkxPT0i
+>DQpNSU1FLVZlcnNpb246IDEuMA0KDQotLT09PT09PT09PT09PT09PTA1MTMzNTY3
+>MzEwODc1OTg2OTE9PQ0KQ29udGVudC1Ue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czQCyKIj
+>me4sPRRl8TJQ12xVuOmlRpQ4+rUxhMfZKyyYZ0isoVNYsmeFPQ8=
+>
+
+
+#### Command example
+
+```!smime-sign-and-encrypt message="This is a message to encrypt" signed=false```
+
+#### Context Example
+
+```json
 {
-    "SMIME.Decrypted": {
-        "Message": "Hello World"
+    "SMIME": {
+        "SignedAndEncrypted": {
+            "FileName": "",
+            "Message": "Date: Mon, 05 Aug 2024 08:56:03 +0000\r\nMIME-Version: 1.0\nContent-Disposition: attachment; filename=\"smime.p7m\"\nContent-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m\"\nContent-Transfer-Encoding: base64\n\nMIIDPwYJKoZIhvcNAQcDoIIDMDCCAywCAQAxggGzMIIBrwIBADCBljCBgTELMAkG\nA1UEBhMCSVQxEDAOBgNVBAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQ\naWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMgUy5wLkEuMSwwKgYDVQQDDCNBY3RhbGlz\nIENsaWVudCBBdXRoZW50aWNhdGlvbiBDQSBHMwIQFo0YjQrVtn3Qa4LqvkOmkzAN\nBgkqhkiG9w0BAQEFAASCAQDFnrTvu16smUFbTBoLJLdM+0hIcsMq66ssFc0BtihR\n6+XQXkE+VRJ6Zn1L+qfUWVUYuZvWwT9TV8CpJV4zJftqcGpyrHSsdA9HNPYMsO/c\nbnWWPfrWeqxcJrnfABIk2f8G+Tar2PcPLRn/DEs10j1ZtKGW0b6veBQowi6zHvto\nc+jY3lRqTLFxBJlvL5PpHItV3GrEorAKN+pR/nwey/xYApdQeIMOF2zt/X5sRaM0\nzaxJ7q+rlfRboxKoQIROsJGP3f7vlcKZx6VF5A3VH0B4/Wu82PNQO7NGXZymCwTo\ntz+twA72J0Dt5wRKY2NDZZnunWGnfSkrX78q9ygdLfuAMIIBbgYJKoZIhvcNAQcB\nMB0GCWCGSAFlAwQBKgQQDnYKpZW9arvx/5zUCivAq4CCAUBM+/9WJMmbRGW6btBo\nIe4S2Yp+RVOWjMSXwJF3I8ugZJ5XMsUUhssmOpIpBrGnDDq/5bn74j+tIIO9UjQm\nODnV2mxradfmh4Xpw215SY+6UcgtvhwoYkqK8X3de+jca07ER8ig0ubzXke1HPd5\n0/qYPL8FmvI2HWML1rx95Z/n07h8KRNcjKX/u5c9kaBa+CayS6T2JqWPXsjCgiuL\nZa1plhvecAWwW4RllCyiyBSQNaOV5PyMZWAd7VOqK7wD3mp9Qo9pffcOzGhB9PMr\nQZzXsSyB78JxSkXCQA+fU7E+EL4B/U04iPjaj9IxrrEN4m3Pxi8i5xG8YrzfMHE0\nKJu33MeFXApz/qZ3OwmmdYl7l8zs12LArs813yMhOpu2vicjrZ+S5BYygM1oOvr+\n+Mmk+dI+iwm16cO4MWhY6szJRQ==\n\n",
+            "RecipientIds": {
+                "bcc": [],
+                "cc": [],
+                "to": []
+            }
+        }
     }
 }
-
-
Human Readable Output
-

-

-The decrypted message is: -Hello World -

-

- -

5. smime-sign-and-encrypt

-
-

Encrypts and signs an email message with S/MIME protocol by using a public RSA certificate.

-
Base Command
-

- smime-sign-and-encrypt -

- -
Required Permissions
-

The following permissions are required for this command.

- -
Input
- - - - - - - - - - - - - - - -
- Argument Name - - Description - - Required -
messageThe message body to encrypt and sign.Required
- -

 

-
Context Output
- - - - - - - - - - - - - - - -
- Path - - Type - - Description -
SMIME.SignedAndEncrypted.MessageStringThe raw message to send.
- -

 

-
Command Example
-

- !smime-sign-and-encrypt message="Hello" -

-
Context Example
-
+```
+
+#### Human Readable Output
+
+>Date: Mon, 05 Aug 2024 08:56:03 +0000
+>MIME-Version: 1.0
+>Content-Disposition: attachment; filename="smime.p7m"
+>Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
+>Content-Transfer-Encoding: base64
+>
+>MIIDPwYJKoZIhvcNAQcDoIIDMDCCAywCAQAxggGzMIIBrwIBADCBljCBgTELMAkG
+>A1UEBhMCSVQxEDAOBgNVBAgMB0J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Y6szJRQ==
+>
+
+
+#### Command example
+
+```!smime-sign-and-encrypt message="This is a message to sign and encrypt"```
+
+#### Context Example
+
+```json
 {
-    "SMIME.SignedAndEncrypted": {
-        "Message": "MIME-Version: 1.0\nContent-Disposition: attachment; filename=\"smime.p7m\"\nContent-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m\"\nContent-Transfer-Encoding: base64\n\nMIILMgYJKoZIhvcNAQcDoIILIzCCCx8CAQAxggGXMIIBkwIBADB7MG4xCzAJBgNV\nBAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBuZXR3\nb3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWljcm9z\nb2Z0LmNvbQIJAO117pJfuoxMMA0GCSqGSIb3DQEBAQUABIIBADkQkpoDZ0C/RR5t\n5kr45rHLv/rJNK17PHEfGl2RgomIZlZnz6MkNayNIV8jKNSHZ91aISw4EBL3Ccvu\nUx21wFi119Yv4c3J0L3ZG4I+WNHV+PL0IyVQOH4yPrY3JB884qSwrxAWNwW/inof\nYccR2xGWYpp9CwlFeEZmEiyxQz2v23Sx9exMkwQLrR+ljQu8/niSyv0dXlZX54LH\nvUdPkFkqW1N4KTJDtsHo/eiyax2a9x1z82oaUA0xzwCbzysAhBoi77SRWbNGlelB\nJ0ppKfiBll7V5NevmpeiRzieoJP7anTCsgrcak/ZsAwLBjd8GPD/u4LPB4Xl0v8u\nX06D5x4wggl9BgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECP+fhmJhEmD1gIIJWAPs\n8y7tmYjd/I7ZJeB9lULcCcwIjD74Hm0FyXREzFKXHa6uXLYGK9X5HdkQKT0X4oYg\n7YR+5qvsv4eHwzOVMgMVpvuh2f7VZduP2t83cxJsOs7SigYX/uUqBnu1Vs2eQjHc\navFPTvA6W1sAGpAi/Dwex0oP4bs5xIGF9swO1iT+RdL5hbSrqiuBmO5FKTwebjdf\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sY\n8Rxv4XEhS671o99JszrjvVEW84wDY6i6wqBwHUU8IushaRVEOPTOfuuMJwLajLvg\no938uJPnYeUoMCvtofAh0rFviD9n0JxtjbRiyHOEnBoR2Q/omMCuzjCiBQqBxeP8\nmVViH+ZUXCRM7CIQfC68Knmw00FpIoPQ70meksfGEIT296UFC4wFfGoQuJrfqNMP\nSKEi8WknEA4HAJMXbGm6A7mHD7IE6u17xsfqGLuNANAsv2DyiVkZkHFjqOuJvCHL\nr2VpujD7Ybu2M1TKcXAVv9zzPa9eMczjsJA1k7oK3qW28MzNWnIA8D9Vj/d+/1vQ\nYYucElb8Q3kC/ryVlzRLxactuF7qne1D0snXgUspfDPuWUi+Gr9A0ruMHyfdK1Dt\nxblNpNLIeuTZ7YdJhL4udTe2TTgGK0tGkM4rFG32egnn2lfMrLzkz3uwPet3XmPw\nrYfqeOsiqqSUEjV/TIzyYWUFUkSLjhwNfkidJA9lMjTzANvUfzV21id87+3inQoJ\nG1/341oGZ446BwtHoCrD/yc8xBJyEXEE+ZCaWwFL6qiMziRZrmKgqS5TYke7FfYg\nmyd7rNFhRbvkv225U5FknQ5jfHTIzOMqVF8Pk2lQJgumu15iNI8lMvKarBUHHMpW\nUzD+MET/SUl0MHmMdtOd83BY13jq0yFv5vwi3+2rwK+kA7KM5dq7KRG0uurdbpyX\ngf6pE3DFgX+nunWGGQtS6duaep4GmL5eMq+SkoT5Ihzsot1y+BGG3IxHVLdCX/nK\nOrYEe/V1r7qTUFqpQNXWwpLTh8OcHUgEPGdnzkKhUPK2m2uOF3fhaylJPXFjmgL/\nd5hGZU1Co8XSQdF0jGGAvFUXYNmKsKgqiXlgutJ5a5PxaPVQhCs=\n\n"
+    "SMIME": {
+        "SignedAndEncrypted": {
+            "FileName": "",
+            "Message": "Date: Mon, 05 Aug 2024 08:56:06 +0000\r\nMIME-Version: 1.0\nContent-Disposition: attachment; filename=\"smime.p7m\"\nContent-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name=\"smime.p7m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u0Gb7E6neDSqDzFBKAwR2aIuKv\nt2QrqwU0jbjm/wnvG5ARmrUMBusHCogQ5WwSQTiQI61XPLIFUwfZVHARDjMN2Gaf\nOnk3DGg9g2/UvcITxMKNceo9PokY8g1KQKPsx9ocEoBZidlGDRQAFzY4Re9qXgnW\n3agqSXh20gZamnuchQ6dyWFYxROHi6minMOZWQbvmk3lVVu8/sw+7D3UCMwirqeF\nGecXBJXJ2nsEBwCG5C7lHnc8FekCE3Op8Est75x4TWtmhjeunToRHImgt7etlbNS\nK5CAkQ0EAgcev3eK87dn2Ow05k5bPwMBFQklUwYjv3cW6FjHQLiYjt63SbXhpAKu\nay/in1V4j9/FAZNbg8m5hYgEtwbl1p/CyT7xN5u92HxPftqWRvlJhFwqdk3yeTkr\nbInc/R7JrBNTGmj/EVWf9OOxLEqO1wbTXKlOW4etDik5uz9TL+4JLlmRAzB4HJkC\nkuj3\n\n",
+            "RecipientIds": {
+                "bcc": [],
+                "cc": [],
+                "to": []
+            }
+        }
     }
 }
-
-
Human Readable Output
-

-

-MIME-Version: 1.0 -Content-Disposition: attachment; filename="smime.p7m" -Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m" -Content-Transfer-Encoding: base64 - -MIILMgYJKoZIhvcNAQcDoIILIzCCCx8CAQAxggGXMIIBkwIBADB7MG4xCzAJBgNV -BAYTAklMMQ8wDQYDVQQIDAZJc3JhZWwxGzAZBgNVBAoMElBhbG8gYWx0byBuZXR3 -b3JrczExMC8GCSqGSIb3DQEJARYiYXZpc2hhaUBkZW1pc3RvZGV2Lm9ubWljcm9z -b2Z0LmNvbQIJAO117pJfuoxMMA0GCSqGSIb3DQEBAQUABIIBADkQkpoDZ0C/RR5t -5kr45rHLv/rJNK17PHEfGl2RgomIZlZnz6MkNayNIV8jKNSHZ91aISw4EBL3Ccvu -Ux21wFi119Yv4c3J0L3ZG4I+WNHV+PL0IyVQOH4yPrY3JB884qSwrxAWNwW/inof -YccR2xGWYpp9CwlFeEZ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Y13jq0yFv5vwi3+2rwK+kA7KM5dq7KRG0uurdbpyX -gf6pE3DFgX+nunWGGQtS6duaep4GmL5eMq+SkoT5Ihzsot1y+BGG3IxHVLdCX/nK -OrYEe/V1r7qTUFqpQNXWwpLTh8OcHUgEPGdnzkKhUPK2m2uOF3fhaylJPXFjmgL/ -d5hGZU1Co8XSQdF0jGGAvFUXYNmKsKgqiXlgutJ5a5PxaPVQhCs= -

- -

-

Additional Information

-

For the S/MIME Messaging integration, you will need an RSA key pair -(this consists of a public key and a private key) and an X.509 certificate of said public key.

-

The public key parameter will start and end as the following: - ------BEGIN CERTIFICATE----- - -key - ------END CERTIFICATE-----

- -The private key parameter will start and end as the following: - ------BEGIN RSA PRIVATE KEY----- - -key - ------END RSA PRIVATE KEY----- -

+``` + +#### Human Readable Output + +>Date: Mon, 05 Aug 2024 08:56:06 +0000 +>MIME-Version: 1.0 +>Content-Disposition: attachment; filename="smime.p7m" +>Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m" +>Content-Transfer-Encoding: base64 +> +>MIIQfwYJKoZIhvcNAQcDoIIQcDCCEGwCAQAxggGzMIIBrwIBADCBljCBgTELMAkG +>A1UEBhMCSVQxEDAOBgNVBAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQ +>aWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMgUy5wLkEuMSwwKgYDVQQDDCNBY3RhbGlz +>IENsaWVudCBBdXRoZW50aWNhdGlvbiBDQSBHMwIQFo0YjQrVtn3Qa4LqvkOmkzAN +>BgkqhkiG9w0BAQEFAASCAQCMwdqh6Hxh2R1k05lDSvfBp2p6jow6vjwCzlEYEoVG +>vp0j/7V3hHPU3cIU8Y0RsPapvTHHGD2WLB/Ekyrnsb+lSMGfty8LoM13SqQp3DzW +>iWjakxn7S1rpjdrKzrV1PmAxTxrMRu+v6io9ox67SQC/j3tpeo2SWDinD1cq4IM9 +>dCZIWQ0B4IM/+5OiBiEdGPLhEv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ME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.py b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.py index 5b215c19ef38..f5eadb0c8a6b 100644 --- a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.py +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.py @@ -4,12 +4,19 @@ ''' IMPORTS ''' -from M2Crypto import BIO, SMIME, X509, m2 -from typing import Dict, Tuple +from M2Crypto import BIO, SMIME, X509 from tempfile import NamedTemporaryFile from charset_normalizer import from_bytes import quopri +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText +from email.mime.base import MIMEBase +from email import encoders, message_from_string +from email.message import Message +import pytz +import mimetypes +import uuid ''' HELPER FUNCTIONS ''' @@ -19,6 +26,250 @@ def makebuf(text): return BIO.MemoryBuffer(text) +def create_pem_string(base64_cert: str) -> str: + """Converts a base64 encoded certificate string to a PEM format. + + Args: + base64_cert (str): certificate string with no BEGIN or END markers + + Returns: + pemstring (str): PEM-formatted certificate string + """ + pem_header = '-----BEGIN CERTIFICATE-----\n' + pem_footer = '-----END CERTIFICATE-----\n' + + # Split the base64 certificate into lines of 64 characters each + pem_body = '\n'.join(base64_cert[i:i + 64] for i in range(0, len(base64_cert), 64)) + + return f"{pem_header}{pem_body}\n{pem_footer}" + + +def handle_attachment(attachment_part: Message) -> None: + """ + Extracts and saves the attachment file to the context. + p7 files will be ignored. + + Args: + attachment_part (Message): attachment message part + + """ + + file_name = attachment_part.get_filename() + if not file_name: + demisto.debug('Got nameless attachment, generating file name') + mime_type = attachment_part.get_content_type() + extension = mimetypes.guess_extension(mime_type) or '.bin' + file_name = f'attachment_{uuid.uuid4()}{extension}' + + # ignore p7 file types and subtypes (e.g. p7m) + if (file_name.lower().endswith('.p7') + or file_name.lower().endswith('.p7', 0, -1)): + demisto.debug(f'Skipping p7 file: {file_name}') + return + # create the attachment + file_result = fileResult(file_name, attachment_part.get_payload(decode=True)) + + # check for error + if file_result['Type'] == entryTypes['error']: + raise Exception(file_result['Contents']) + + # return the attachment to war room + return_results(file_result) + + +def handle_image(image_part: Message, payload: Any) -> tuple[str, str, str] | None: + """ + Handles the payload for an image, extracting the cid and image data + + Args: + image_part (Message): Image message part + payload (Any): Message part payload + + Returns: + (cid, content_type, image_data): Complete image data to allow embedding into the message, None if no cid is found + + """ + content_type = image_part.get_content_type() + image_data_base64 = base64.b64encode(payload).decode('utf-8') + + cid = image_part.get('Content-Id') + if not cid: + return None + + # Remove angle brackets if present around CID + cid = re.sub(r'<(.*?)>', r'\1', cid) + + return cid, content_type, image_data_base64 + + +def extract_email_body(text_part: Message, payload: Any) -> tuple[str, str]: + """ + Handles the payload for the email body part + + Args: + text_part (Message): Text message part + payload (Any): Message part payload + + Returns: + (email_body, body_type): Strings containing the email body and the body type (text or html) + + """ + email_body = payload.decode(text_part.get_content_charset('utf-8'), errors='ignore') + if text_part.get_content_type() == 'text/html': + body_type = 'html' + # Clean up whitespaces between and tags + email_body = re.sub(r'\s*', '', email_body) + else: + body_type = 'text' + + return email_body, body_type + + +def patch_cid_with_urls(email_body: str, images: list[tuple[str, str, str]]) -> str: + """ + Replaces HTML image references with their data URLs + + Args: + email_body (str): The html email message to patch + images (list): List of images found in the message, each containing (cid, type, data) + + Returns: + patched_body (str): email body with patched URLs + + """ + patched_body = email_body + for cid, content_type, image_data_base64 in images: + cid_reference = f'cid:{cid}' + data_url = f'data:{content_type};base64,{image_data_base64}' + patched_body = patched_body.replace(cid_reference, data_url) + + return patched_body + + +def parse_multipart_message(msg: str) -> tuple[str, str]: + """ + Extracts the contents from a MIME message. + Images (if any exist) will be added to the html email_body, + attachments will be added to the context directly. + + Args: + msg (str): Message to parse + + Returns: + (email_body, body_type): Strings containing the parsed email, and the message type (text or html) + + """ + email_message = message_from_string(msg) + if email_message.get_content_type() == 'multipart/signed': + # The message is signed + return ('', '') + email_body = '' + body_type = '' + images: list[tuple[str, str, str]] = [] + + for part in email_message.walk(): + if part.is_multipart(): + continue + + content_type = part.get_content_type() + if content_type in {'application/pkcs7-signature', 'application/pkcs7-mime', 'application/x-pkcs7-mime'}: + # The message is signed + return ('', '') + + if part.get_content_disposition() == 'attachment': + handle_attachment(part) + continue + + payload = part.get_payload(decode=True) + if not isinstance(payload, bytes): + raise TypeError(f'Error in message.get_payload(decode=True), expected bytes, got: {type(payload)}') + + if part.get_content_maintype() == 'image': + if image := handle_image(part, payload): + images.append(image) + + elif part.get_content_maintype() == 'text' and body_type != 'html': + email_body, body_type = extract_email_body(part, payload) + + if body_type == 'html': + email_body = patch_cid_with_urls(email_body, images) + + return (email_body, body_type) + + +def create_message_with_attachments(message: str, attach_ids: list[str]) -> str: + """ + Creates a MIMEMultipart formatted message with message body and attachments + + Args: + message (str): Message body + attach_ids (list): list of war room entries containing files to attach + + Returns: + msg (str): Formatted mime message with attachments added + + """ + msg = MIMEMultipart() + + is_html = bool(re.search(r'<.*?>', message)) + if is_html: + msg.attach(MIMEText(message, 'html')) + else: + msg.attach(MIMEText(message, 'plain')) + + # Add attachments to message + for attach_id in attach_ids: + try: + fp = demisto.getFilePath(attach_id) + file_path = fp['path'] + attach_name = fp['name'] + except Exception as ex: + raise Exception(f'Error while opening attachment id {attach_id}: {str(ex)}') + if isinstance(attach_name, list): + attach_name = attach_name[0] + part = MIMEBase('application', 'octet-stream') + with open(file_path, 'rb') as f: + part.set_payload(f.read()) + encoders.encode_base64(part) + part.add_header('Content-Disposition', f'attachment; filename={attach_name}') + msg.attach(part) + + return msg.as_string() + + +def create_email_header(sender: str, subject: str, recipients: list[str], cc: list[str], bcc: list[str]) -> BIO.MemoryBuffer: + """ + Creates a memory buffer with email headers + + Args: + sender (str): Sender email + subject (str): Email subject + recipients (list): List of recipient emails + cc (list): List of cc emails + bcc (list): List of bcc emails + + Returns: + header (MemoryBuffer): memory buffer containing email headers + + """ + header = BIO.MemoryBuffer() + + current_time = datetime.now(pytz.timezone('UTC')).strftime('%a, %d %b %Y %H:%M:%S %z') + header.write(f'Date: {current_time}\r\n') + if sender: + header.write(f'From: {sender}\r\n') + if recipients: + header.write(f'To: {", ".join(recipients)}\r\n') + if cc: + header.write(f'CC: {", ".join(cc)}\r\n') + if bcc: + header.write(f'BCC: {", ".join(bcc)}\r\n') + if subject: + header.write(f'Subject: {subject}\r\n') + + return header + + class Client: def __init__(self, private_key, public_key): self.smime = SMIME.SMIME() @@ -34,10 +285,43 @@ def __init__(self, private_key, public_key): private_key_file.close() +def set_encryption_params(client: Client, certs: list[str]) -> None: + """ + Sets the smime cipher and X509 certificate stack + + Args: + client: Client + certs: List of recipient certificates to use for the encryption + + """ + client.smime.set_cipher(SMIME.Cipher('aes_256_cbc')) + + # Create and set certificate stack + cert_stack = X509.X509_Stack() + if not certs: + demisto.debug('No certs given, using instance cert') + cert_stack.push(X509.load_cert(client.public_key_file)) + for cert in certs: + if cert == 'instancePublicKey': + cert_stack.push(X509.load_cert(client.public_key_file)) + continue + if ('-----BEGIN CERTIFICATE-----') not in cert: + demisto.debug('No ---BEGIN CERTIFICATE--- tag, creating pem from cert') + cert = create_pem_string(cert) + + with NamedTemporaryFile(delete=False) as public_key_file: + public_key_file.write(bytes(cert, 'utf-8')) + public_key_file.close() + cert_stack.push(X509.load_cert(public_key_file.name)) + os.unlink(public_key_file.name) + + client.smime.set_x509_stack(cert_stack) + + ''' COMMANDS ''' -def sign_email(client: Client, args: Dict): +def sign_email(client: Client, args: dict): """ send a S/MIME-signed message via SMTP. """ @@ -70,17 +354,17 @@ def sign_email(client: Client, args: Dict): signed = out.read().decode('utf-8') signed_message = signed.split('\n\n') headers = signed_message[0].replace(': ', '=').replace('\n', ',') - context = { - 'SMIME.Signed': { - 'Message': signed, - 'Headers': headers - } - } - return signed, context + return CommandResults( + readable_output=signed, + outputs_prefix='SMIME.Signed', + outputs={'Message': signed, + 'Headers': headers, + } + ) -def encrypt_email_body(client: Client, args: Dict): +def encrypt_email_body(client: Client, args: dict): """ generate an S/MIME-encrypted message Args: @@ -105,53 +389,96 @@ def encrypt_email_body(client: Client, args: Dict): headers = message[0] new_headers = headers.replace(': ', '=').replace('\n', ',') - entry_context = { - 'SMIME.Encrypted': { - 'Message': encrypted_message, - 'Headers': new_headers - } - } - return encrypted_message, entry_context + return CommandResults( + readable_output=encrypted_message, + outputs_prefix='SMIME.Encrypted', + outputs={'Message': encrypted_message, + 'Headers': new_headers, + } + ) -def verify(client: Client, args: Dict): +def verify(client: Client, args: dict) -> List[CommandResults]: """ Verify the signature Args: - client: Client - args: Dict + client (Client): The client instance. + args (dict): The arguments for verification. """ signed_message = demisto.getFilePath(args.get('signed_message')) + cert = args.get('public_key', 'instancePublicKey') + raw_output = argToBoolean(args.get('raw_output', 'false')) + tags = argToList(args.get('tag', '')) - x509 = X509.load_cert(client.public_key_file) sk = X509.X509_Stack() - sk.push(x509) - client.smime.set_x509_stack(sk) - st = X509.X509_Store() - st.load_info(client.public_key_file) + if cert == 'instancePublicKey': + sk.push(X509.load_cert(client.public_key_file)) + st.load_info(client.public_key_file) + elif cert: + with NamedTemporaryFile(delete=False) as public_key_file: + public_key_file.write(cert.encode('utf-8')) + public_key_file_name = public_key_file.name + + sk.push(X509.load_cert(public_key_file_name)) + st.load_info(public_key_file_name) + os.unlink(public_key_file_name) + + client.smime.set_x509_stack(sk) client.smime.set_x509_store(st) try: - p7, data = SMIME.smime_load_pkcs7(signed_message['path']) - v = client.smime.verify(p7, data, flags=SMIME.PKCS7_NOVERIFY) - human_readable = f'The signature verified\n\n{v}' + result = SMIME.smime_load_pkcs7(signed_message['path']) + if not isinstance(result, tuple): + raise DemistoException('SMIME error while loading message') + p7, data = result + verified_data = client.smime.verify(p7, data, flags=SMIME.PKCS7_NOVERIFY) + human_readable = f'The signature verified\n\n{verified_data}' except SMIME.SMIME_Error as e: - if str(e) == 'no content type': # If no content type; see if we can process as DER format - with open(signed_message['path'], "rb") as message_file: + if str(e) == 'no content type': + demisto.debug('No content type found in message, testing if it is in DER format (binary)') + with open(signed_message['path'], 'rb') as message_file: p7data = message_file.read() p7bio = BIO.MemoryBuffer(p7data) - p7 = SMIME.PKCS7(m2.pkcs7_read_bio_der(p7bio._ptr())) - v = client.smime.verify(p7, flags=SMIME.PKCS7_NOVERIFY) - return_results(fileResult('unwrapped-' + signed_message.get('name'), v)) + p7 = SMIME.load_pkcs7_bio_der(p7bio) + verified_data = client.smime.verify(p7, flags=SMIME.PKCS7_NOVERIFY) + return_results(fileResult(f'unwrapped-{signed_message["name"]}', verified_data)) human_readable = 'The signature verified\n\n' + else: + raise e + + if not verified_data: + raise ValueError('Unknown error: failed to verify message') + msg = verified_data.decode('utf-8') + msg_out = msg + if not raw_output: # Return message after parsing html/images/attachments + demisto.debug(f'Parsing message:\n\n{msg}') + msg_out, email_type = parse_multipart_message(msg) + if email_type == 'html': + human_readable = 'The signature verified' + else: + human_readable = f'### The signature verified, message is: \n ___ \n {msg_out}' - return human_readable, {} + results = [CommandResults( + readable_output=human_readable, + outputs_prefix='SMIME.Verified', + outputs={'Message': msg_out}, + tags=tags, + )] + if email_type == 'html': + results.append(CommandResults( + raw_response=msg_out, + content_format=EntryFormat.HTML, + entry_type=EntryType.NOTE, + )) -def decode_str(decrypted_text: bytes, encoding: str) -> Tuple[str, str]: + return results + + +def decode_str(decrypted_text: bytes, encoding: str) -> tuple[str, str]: """ Detect encoding type using chardet, if the confidence of the detected encoding is lower than 0.9 we will add a message indicates it. If encoding is given, will use it. @@ -173,112 +500,179 @@ def decode_str(decrypted_text: bytes, encoding: str) -> Tuple[str, str]: return out, msg -def decrypt_email_body(client: Client, args: Dict, file_path=None): - """ Decrypt the message +def decrypt_email_body(client: Client, args: dict) -> List[CommandResults]: + """Decrypt the message Args: - client: Client - args: Dict - file_path: relevant for the test module + client (Client): The client instance. + args (Dict): The arguments for decryption. """ - if file_path: - encrypt_message = file_path + if 'test_file_path' in args: # test module + encrypt_message = {'path': args.get('test_file_path', '')} else: - encrypt_message = demisto.getFilePath(args.get('encrypt_message')) + encrypt_message = demisto.getFilePath(args.get('encrypt_message', '')) + demisto.debug(f'File Name:{encrypt_message["name"]}; Type:{type(encrypt_message["name"])}') encoding = args.get('encoding', '') + raw_output = argToBoolean(args.get('raw_output', 'false')) + tags = argToList(args.get('tag', '')) + msg = '' client.smime.load_key(client.private_key_file, client.public_key_file) try: - p7, data = SMIME.smime_load_pkcs7(encrypt_message['path']) + p7 = SMIME.smime_load_pkcs7(encrypt_message['path']) + if isinstance(p7, tuple): + p7 = p7[0] decrypted_text = client.smime.decrypt(p7) + if not decrypted_text: + raise ValueError('Unknown error: failed to decrypt message') out, msg = decode_str(decrypted_text, encoding) except SMIME.SMIME_Error as e: if str(e) == 'no content type': # If no content type; see if we can process as DER format - with open(encrypt_message['path'], "rb") as message_file: + demisto.debug('No content type found in message, testing if it is in DER format (binary)') + with open(encrypt_message['path'], 'rb') as message_file: p7data = message_file.read() p7bio = BIO.MemoryBuffer(p7data) - p7 = SMIME.PKCS7(m2.pkcs7_read_bio_der(p7bio._ptr())) + p7 = SMIME.load_pkcs7_bio_der(p7bio) decrypted_text = client.smime.decrypt(p7, flags=SMIME.PKCS7_NOVERIFY) + if not decrypted_text: + raise ValueError('Unknown error: failed to decrypt message') out, msg = decode_str(decrypted_text, encoding) else: raise - entry_context = { - 'SMIME.Decrypted': { - 'Message': out - } - } + msg_out = out human_readable = f'{msg}The decrypted message is: \n{out}' + if not raw_output: # Return message after parsing html/images/attachments + demisto.debug(f'parsing message:\n\n{out}') + email_body, email_type = parse_multipart_message(out) + if email_type == 'html': + msg_out = email_body + human_readable = f'{msg}Message decrypted successfully' + elif email_type == 'text': + msg_out = email_body + human_readable = f'### {msg}The decrypted message is: \n ___ \n {msg_out}' + else: + human_readable = f'### {msg}The decrypted message is signed, verify to get the original message\n ___ \n{out}' + + results = [CommandResults( + readable_output=human_readable, + outputs_prefix='SMIME.Decrypted', + outputs={'Message': msg_out}, + tags=tags, + )] - return human_readable, entry_context + if email_type == 'html': + results.append(CommandResults( + raw_response=msg_out, + content_format=EntryFormat.HTML, + entry_type=EntryType.NOTE, + )) + return results -def sign_and_encrypt(client: Client, args: Dict): - message = args.get('message', '').encode('utf-8') - msg_bio = BIO.MemoryBuffer(message) - sign = client.private_key_file - encrypt = client.public_key_file +def sign_and_encrypt(client: Client, args: dict) -> CommandResults: + """Sign and encrypt the message + + Args: + client (Client): The client instance. + args (Dict): The arguments for signing and encrypting. + """ + message = args.get('message', '') + sign = argToBoolean(args.get('signed', 'true')) + encrypt = argToBoolean(args.get('encrypted', 'true')) + sender = args.get('sender', '') + subject = args.get('subject', '') + create_file = argToBoolean(args.get('create_file_p7', 'false')) + attachment_ids = argToList(args.get('attachment_entry_id', '')) # type: list[str] + + recipients = safe_load_json(args.get('recipients', {}) or '{}') + if not isinstance(recipients, dict): + raise DemistoException('Failed to parse recipients. (format `{"recipient@email":"cert", "other@email":"cert"}`)') + + cc = safe_load_json(args.get('cc', {}) or '{}') + if not isinstance(cc, dict): + raise DemistoException('Failed to parse cc. (format `{"recipient@email":"cert", "other@email":"cert"}`)') + + bcc = safe_load_json(args.get('bcc', {}) or '{}') + if not isinstance(bcc, dict): + raise DemistoException('Failed to parse bcc. (format `{"recipient@email":"cert", "other@email":"cert"}`)') + + msg_str = create_message_with_attachments(message, attachment_ids) + demisto.debug(f'\n\nMessage:\n\n {msg_str} \n\nMessage end\n') if sign: + msg_bio = BIO.MemoryBuffer(msg_str.encode('utf-8')) client.smime.load_key(client.private_key_file, client.public_key_file) - if encrypt: - p7 = client.smime.sign(msg_bio, flags=SMIME.PKCS7_TEXT) - else: - p7 = client.smime.sign(msg_bio, flags=SMIME.PKCS7_TEXT | SMIME.PKCS7_DETACHED) - msg_bio = BIO.MemoryBuffer(message) # Recreate coz sign() has consumed it. + p7 = client.smime.sign(msg_bio, algo='sha256') if encrypt: - x509 = X509.load_cert(client.public_key_file) - sk = X509.X509_Stack() - sk.push(x509) - client.smime.set_x509_stack(sk) + pub_certs = [cert for dest in [recipients, cc, bcc] for cert in dest.values()] # Consolidate all recipient certificates + set_encryption_params(client, pub_certs) - client.smime.set_cipher(SMIME.Cipher('des_ede3_cbc')) - tmp_bio = BIO.MemoryBuffer() + msg_bio = BIO.MemoryBuffer() if sign: - client.smime.write(tmp_bio, p7) + client.smime.write(msg_bio, p7) else: - tmp_bio.write(message) - p7 = client.smime.encrypt(tmp_bio) + msg_bio.write(msg_str) + p7 = client.smime.encrypt(msg_bio) - out = BIO.MemoryBuffer() - if encrypt: - client.smime.write(out, p7) + # Prepare output + out_bio = create_email_header(sender, subject, list(recipients.keys()), list(cc.keys()), list(bcc.keys())) + if encrypt or sign: + client.smime.write(out_bio, p7) else: - if sign: - client.smime.write(out, p7, msg_bio, SMIME.PKCS7_TEXT) - else: - out.write('\r\n') - out.write(message) - - msg = out.read().decode('utf-8') - entry_context = { - 'SMIME.SignedAndEncrypted': { - 'Message': msg - } - } - - return msg, entry_context + out_bio.write(msg_str) + + msg_out = out_bio.read().decode('utf-8') + + file_results = {} + if create_file: + file_results = fileResult(filename=f'SMIME-{demisto.uniqueFile()[:8]}.p7', data=msg_out, file_type=EntryType.FILE) + return_results(file_results) + + return CommandResults( + readable_output=msg_out, + outputs_prefix='SMIME.SignedAndEncrypted', + outputs={ + 'Message': msg_out, + 'RecipientIds': { + 'to': list(recipients.keys()), + 'cc': list(cc.keys()), + 'bcc': list(bcc.keys()), + }, + 'FileName': file_results.get('File', ''), + }, + ) def test_module(client, *_): message_body = 'testing' try: - encrypt_message = encrypt_email_body(client, {'message': message_body}) - if encrypt_message: - test_file = NamedTemporaryFile(delete=False) - test_file.write(bytes(encrypt_message[0], 'utf-8')) - test_file.close() - decrypt_message = decrypt_email_body(client, {}, file_path={'path': test_file.name}) - if decrypt_message: - demisto.results('ok') + # Encrypt the message + encrypted_out = sign_and_encrypt(client, {'message': message_body, 'signed': 'false'}).to_context() + encrypted_msg = encrypted_out['EntryContext']['SMIME.SignedAndEncrypted']['Message'] + + # Write the encrypted message to a temporary file + with NamedTemporaryFile(delete=False) as test_file: + test_file.write(bytes(encrypted_msg, 'utf-8')) + test_file_name = test_file.name + + # Decrypt the message + decrypt_out = decrypt_email_body(client, {'test_file_path': test_file_name})[0].to_context() + decrypted_msg = decrypt_out['HumanReadable'] + if message_body in decrypted_msg: + demisto.results('ok') + else: + raise Exception + except Exception: - return_error('Verify that you provided valid keys.') + return_error('''Failed to encrypt->decrypt using the provided credentials. + Verify that the provided keys are valid and matching.''') finally: os.unlink(test_file.name) @@ -301,7 +695,7 @@ def main(): # pragma: no cover try: command = demisto.command() if command in commands: - return_outputs(*commands[command](client, demisto.args())) # type: ignore + return_results(commands[command](client, demisto.args())) # type: ignore except Exception as e: return_error(str(e)) diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.yml b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.yml index 8d9aa1090fb2..8326e6cd3366 100644 --- a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.yml +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging.yml @@ -7,10 +7,12 @@ configuration: name: public_key required: true type: 12 + additionalinfo: Sender public key required for signing emails. - display: Private Key name: private_key required: true type: 14 + additionalinfo: Sender private key required for decrypting and signing emails. description: Use the S/MIME (Secure Multipurpose Internet Mail Extensions) integration to send and receive secure MIME data. display: SMIME Messaging name: SMIME Messaging @@ -26,7 +28,9 @@ script: predefined: - 'false' - 'true' - description: Retrieves items from the service. + description: |- + Deprecated. Use smime-sign-and-encrypt instead. + Retrieves items from the service. name: smime-sign-email outputs: - contextPath: SMIME.Signed.Message @@ -35,11 +39,14 @@ script: - contextPath: SMIME.Signed.Headers description: The S/MIME signing headers. type: String + deprecated: true - arguments: - description: The message body to encrypt. name: message required: true - description: Encrypts an email message with S/MIME protocol by using a public RSA certificate. + description: |- + Deprecated. Use smime-sign-and-encrypt instead. + Encrypts an email message with S/MIME protocol by using a public RSA certificate. name: smime-encrypt-email-body outputs: - contextPath: SMIME.Encrypted.Message @@ -48,18 +55,45 @@ script: - contextPath: SMIME.Encrypted.Headers description: The encryption headers. type: String + deprecated: true - arguments: - - description: The signed email with .p7 extension. + - description: Entity ID of the file with a .p7 extension containing the signed message. name: signed_message required: true - description: Verifies the signature. + - description: Sender's public key to verify. + name: public_key + defaultValue: instancePublicKey + - auto: PREDEFINED + description: Whether to get the full raw output of the email. + name: raw_output + predefined: + - 'false' + - 'true' + - description: A comma-separated list of tags to be included in the War Room output. + name: tag + description: |- + Verifies the signature. + + Warning: This function does not check the CA chain. Ensure the certificate chain is validated separately to avoid security risks. name: smime-verify-sign + outputs: + - contextPath: SMIME.Verified.Message + description: The decoded signed message. + type: String - arguments: - - description: The encrypted message with .p7 extension. + - description: Entity ID of the file with a .p7 extension containing the encrypted email. name: encrypt_message required: true - description: The encoding code to use when decode the message body, e.g 'ISO-8859-2''. name: encoding + - auto: PREDEFINED + description: Whether to get the full raw output of the email. + name: raw_output + predefined: + - 'false' + - 'true' + - description: A comma-separated list of tags to be included in the War Room output. + name: tag description: Decrypts the message body. name: smime-decrypt-email-body outputs: @@ -70,17 +104,66 @@ script: - description: The message body to encrypt and sign. name: message required: true + - description: |- + JSON dict of recipients and their public keys + Format: {"recipient@email":"cert", "other@email":"cert"} + Use "instancePublicKey" in the cert field to use the instance certificate. + name: recipients + - description: |- + JSON dict of cc recipients and their public keys + Format: {"cc@email":"cert", "othercc@email":"cert"} + Use "instancePublicKey" in the cert field to use the instance certificate. + name: cc + - description: |- + JSON dict of bcc recipients and their public keys + Format: {"bcc@email":"cert", "otherbcc@email":"cert"} + Use "instancePublicKey" in the cert field to use the instance certificate. + name: bcc + - description: List of War Room entry IDs of files to attach to the mail. + name: attachment_entry_id + isArray: true + - auto: PREDEFINED + description: Whether the mail should be signed. + name: signed + defaultValue: 'true' + predefined: + - 'true' + - 'false' + - auto: PREDEFINED + description: Whether the mail should be encrypted. + name: encrypted + defaultValue: 'true' + predefined: + - 'true' + - 'false' + - description: Sender email address. + name: sender + - description: Email subject. + name: subject + - auto: PREDEFINED + description: Whether to create a file with the encrypted/signed content. + name: 'create_file_p7' + predefined: + - 'false' + - 'true' description: Encrypts and signs an email message with S/MIME protocol by using a public RSA certificate. name: smime-sign-and-encrypt outputs: - contextPath: SMIME.SignedAndEncrypted.Message description: The raw message to send. type: String - dockerimage: demisto/m2crypto:1.0.0.79505 + - contextPath: SMIME.SignedAndEncrypted.RecipientIds + description: Address of the recipient. + type: String + - contextPath: SMIME.SignedAndEncrypted.FileName + description: Name of the file output if create_file_p7 is used. + type: String + dockerimage: demisto/m2crypto:1.0.0.108031 runonce: false script: '-' type: python subtype: python3 tests: - EWS V2 Send Mail Test 3 +- SMIME_Messaging-Test fromversion: 5.0.0 diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_description.md b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_description.md index c9786cb2d85a..35618bee6025 100644 --- a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_description.md +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_description.md @@ -1,9 +1,20 @@ -## Configure an RSA Key and Certificate +## Configure an RSA Key and Certificate + 1. Run the following command: `openssl req -newkey rsa:1024 -nodes -x509 -days 365 -out CERTIFICATE -keyout PRIVATE` - - **CERTIFICATE** is the out public certificate file name. - - **PRIVATE** is the out private key file name. + + - **CERTIFICATE** is the out public certificate file name. + - **PRIVATE** is the out private key file name. 2. Copy the text from CERTIFICATE to the **Public Key** field when configuring the integration instance. 3. copy the text from PRIVATE to **Private Key** field when configuring the integration instance. +## Certificate usage + +- Signing emails uses the public/private keys from the instance parameters. +- Email encryption requires the public certificate of the receiver. + - Provided on command call, use `instancePublicKey` to use the instance params. +- Decrypting emails uses the private key from the instance parameters. +- Verifying emails looks for the certificate in the signed message. + - A different certificate can be provided if needed. + See [here for more information](https://m2crypto.readthedocs.io/en/latest/howto.smime.html#howto-smime). diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_test.py b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_test.py index c73a8d54ec65..fc9f34eacaeb 100644 --- a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_test.py +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/SMIME_Messaging_test.py @@ -1,8 +1,10 @@ import pytest - from SMIME_Messaging import Client, sign_email, encrypt_email_body, verify, decrypt_email_body, sign_and_encrypt, \ decode_str +from CommonServerPython import EntryFormat, entryTypes import demistomock as demisto +import json +import os with open('./test_data/signer_key.pem') as f: @@ -13,13 +15,7 @@ client = Client(private_key, public_key) note_msg = 'Note: encoding detection ended with warning: Trying to detect encoding from a tiny portion' -test_data = [ - ( - b'Za\xbf\xf3\xb3\xe6 g\xea\xb6l\xb1 ja\xbc\xf1', - 'Zaæó³ę gź¶l± ja¼ń', - '', - '' - ), +test_decode_data = [ ( b'Za\xbf\xf3\xb3\xe6 g\xea\xb6l\xb1 ja\xbc\xf1', 'Zażółć gęślą jaźń', @@ -37,49 +33,491 @@ '') ] +with open('./test_data/recipient.pem') as file_: + recipient_cert = file_.read() +with open('./test_data/recipient_key.pem') as file_: + recipient_key = file_.read() +with open('./test_data/recipient2.pem') as file_: + recipient2_cert = file_.read() +with open('./test_data/recipient2_key.pem') as file_: + recipient2_key = file_.read() +recipient = {'to@email.com': recipient_cert, 'to2@email.com': recipient2_cert} +cc = {'cc@email.com': 'instancePublicKey'} +bcc = {'bcc@email.com': recipient2_cert} +test_attachments = 'attachment1.txt,attachment2.txt' + +sign_and_encrypt_tests = [ + # (sign, encrypt, recipients, cc, bcc, create_file, attachments) + ('', '', '', '', '', '', ''), + ('True', 'False', recipient, cc, bcc, 'False', ''), + ('False', 'True', recipient, cc, bcc, 'False', ''), + ('False', 'False', recipient, cc, bcc, 'False', ''), + ('False', 'False', recipient, cc, bcc, 'False', test_attachments), + ('False', 'False', recipient, cc, bcc, 'True', ''), + ('True', 'False', recipient, cc, bcc, 'True', ''), + ('True', 'True', recipient, cc, bcc, 'True', ''), + ('True', 'True', recipient, cc, bcc, 'True', test_attachments), +] + +test_messages = [ + ('This is a plain-text test message', 'text'), + ('

This is an html test message, in bold.

', 'html'), +] +test_multi_recipient_params = [ + (recipient, '', '', [(recipient_key, recipient_cert), (recipient2_key, recipient2_cert)]), + (recipient, cc, '', [('instanceKey', 'instanceCert'), (recipient_key, recipient_cert), (recipient2_key, recipient2_cert)]), + ('', cc, bcc, [('instanceKey', 'instanceCert'), (recipient2_key, recipient2_cert)]), +] + + +def mockFileResult(filename, data, file_type=None): + if isinstance(data, str): + data = data.encode('utf-8') + if file_type is None: + file_type = entryTypes['file'] + with open(filename, 'wb') as f: + f.write(data) + return {'Contents': '', 'ContentsFormat': 'text', 'Type': file_type, 'File': filename, 'FileID': 0} + def test_sign(): + """ + Given: + - Client configured with valid key and certificate + + When: + - Using sign_email + + Then: + - A signed message is output + + """ message_body = 'text to check' - sign, _ = sign_email(client, {'message_body': message_body}) + sign = sign_email(client, {'message_body': message_body}).readable_output assert 'MIME-Version: 1.0\nContent-Type: multipart/signed; protocol="application/x-pkcs7-signature"; ' \ 'micalg="sha1";' in sign def test_verify(mocker): + """ + Given: + - File to verify in PEM format + + When: + - Using verify + - Some tag is provided + + Then: + - The message will be verified successfully + - Tag will be added to the war room output + + """ mocker.patch.object(demisto, 'getFilePath', return_value={'path': './test_data/signed.p7'}) - v, _ = verify(client, {}) - assert 'a sign of our times' in v + verify_out = verify(client, {'tag': 'test_tag'})[0].to_context() + assert 'a sign of our times' in verify_out['HumanReadable'] + assert 'test_tag' in verify_out['Tags'] + + +def test_verify_der(mocker): + """ + Given: + - File to verify in binary format (DER) + + When: + - Using verify + + Then: + - The message will be verified successfully + + """ + mocker.patch('SMIME_Messaging.fileResult', return_value={ + 'Contents': '', 'ContentsFormat': 'text', 'Type': '', 'File': '', 'FileID': '' + }) + mocker.patch.object(demisto, 'getFilePath', return_value={ + 'name': 'signed-binary-format.p7m', + 'path': './test_data/signed-binary-format.p7m' + }) + + v = verify(client, {})[0].to_context()['HumanReadable'] + assert 'This is a test email 1, only signed' in v def test_encrypt(mocker): + """ + Given: + - Client configured with valid key and certificate + + When: + - Using encrypt_email_body + + Then: + - An encrypted message is output + + """ mocker.patch.object(demisto, 'args', return_value={'message': 'testing message'}) - encrypt, _ = encrypt_email_body(client, {}) + encrypt = encrypt_email_body(client, {}).readable_output assert 'MIME-Version: 1.0\nContent-Disposition: attachment; filename="smime.p7m"\n' \ 'Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"\n' \ 'Content-Transfer-Encoding: base64' in encrypt def test_decrypt(mocker): - mocker.patch.object(demisto, 'getFilePath', return_value={'path': './test_data/encrypt.p7'}) + """ + Given: + - File to decrypt in PEM format + - Client configured with key and certificate matching the cert used for encryption - decrypted, _ = decrypt_email_body(client, {}) - assert 'Hello world' in decrypted + When: + - Using decrypt_email_body + - Some tag is provided + Then: + - The message will be decrypted correctly + - Tag will be added to the war room output -def test_sign_and_encrypt(mocker): + """ + mocker.patch.object(demisto, 'getFilePath', return_value={'name': 'encrypt.p7', 'path': './test_data/encrypt.p7'}) - mocker.patch.object(demisto, 'args', return_value={'message': 'testing message'}) - sign_encrypt, _ = sign_and_encrypt(client, {}) - assert 'MIME-Version: 1.0\nContent-Disposition: attachment; filename="smime.p7m"\n' \ - 'Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"\n' \ - 'Content-Transfer-Encoding: base64' in sign_encrypt + decrypted_out = decrypt_email_body(client, {'tag': 'test_tag'})[0].to_context() + assert 'Hello world' in decrypted_out['HumanReadable'] + assert 'test_tag' in decrypted_out['Tags'] + + +def test_decrypt_der(mocker): + """ + Given: + - File to decrypt in binary format (DER) + - Client configured with key and certificate matching the cert used for encryption + + When: + - Using decrypt_email_body + + Then: + - The message will be decrypted correctly + + """ + # Test decryption when file is in binary format + mocker.patch.object(demisto, 'getFilePath', return_value={ + 'name': 'encrypted-binary-format.p7m', + 'path': './test_data/encrypted-binary-format.p7m' + }) + decrypted_out = decrypt_email_body(client, {})[0].to_context() + assert 'This is a test email 2, only encrypted' in decrypted_out['HumanReadable'] + + +@pytest.mark.parametrize('sign, encrypt, recipients, cc, bcc, create_file, attachments', sign_and_encrypt_tests) +def test_sign_and_encrypt(mocker, sign, encrypt, recipients, cc, bcc, create_file, attachments): + """ + Given: + - Client configured with valid key and certificate + - Various command arguments for sign_and_encrypt + + When: + - Using sign_and_encrypt with the given arguments + + Then: + - The message will be signed/encrypted as requested + - Recipient addresses will be included in the mail header + - Attachments will be added to the email if included + - Output will be saved to file if requested -@pytest.mark.parametrize('decrypted_text_bytes, expected_output, error_msg, encoding', test_data) + """ + mocker.patch.object(demisto, 'getFilePath', + side_effect=lambda file_name: {'name': file_name, 'path': f'./test_data/{file_name}'}) + # patch file result to known name to use for clean up + mocker.patch.object(demisto, 'uniqueFile', return_value='outfile.txt') + out_file_name = f'{demisto.investigation()["id"]}_outfile.txt' + args = { + 'message': 'Sign and encrypt test message', + 'subject': 'Sign and encrypt test subject', + 'sender': 'sender@email.com', + 'encrypted': encrypt, + 'signed': sign, + 'attachment_entry_id': attachments, + 'create_file_p7': create_file, + } + if recipients: + args['recipients'] = json.dumps(recipients) + if cc: + args['cc'] = json.dumps(cc) + if bcc: + args['bcc'] = json.dumps(bcc) + args = {k: v for k, v in args.items() if v != ''} # clean up empty args + + sign_encrypt_out = sign_and_encrypt(client, args).to_context() + + readable = sign_encrypt_out['HumanReadable'] + context = sign_encrypt_out['EntryContext'] + + for recipient in [key for d in (recipients, cc, bcc) for key in d]: + assert recipient in readable + + if encrypt != 'False': + assert 'MIME-Version: 1.0\nContent-Disposition: attachment; filename="smime.p7m"\n' \ + 'Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"\n' in readable + elif sign != 'False': + assert 'smime-type=signed-data' in readable + else: + assert 'Sign and encrypt test message' in readable + assert 'Sign and encrypt test subject' in readable + for attach_name in attachments: + assert attach_name in readable + + if create_file == 'True': + try: + with open(out_file_name) as file: + # Ignore carriage return differences + assert file.read().replace('\r\n', '\n') == context['SMIME.SignedAndEncrypted']['Message'].replace('\r\n', '\n') + finally: + os.unlink(out_file_name) + + +@pytest.mark.parametrize('msg, msg_type', test_messages) +def test_encrypt_decrypt(mocker, msg, msg_type): + """ + Given: + - Client configured with valid key and certificate + - Message to sign, in plain-text or html format + + When: + - Using sign_and_encrypt to encrypt the message + - Then using decrypt_message_body to decrypt the message + + Then: + - The message will be decrypted successfully + - For html, an html output entry will be included + - attachments will be extracted + + """ + mocker.patch.object(demisto, 'getFilePath', + side_effect=lambda file_name: {'name': file_name, 'path': f'./test_data/{file_name}'}) + mocker.patch('SMIME_Messaging.fileResult', side_effect=mockFileResult) + args = { + 'message': msg, + 'subject': 'Encrypt-Decrypt test subject', + 'sender': 'sender@email.com', + 'encrypted': 'True', + 'signed': 'False', + 'attachment_entry_id': test_attachments, + } + + sign_encrypt_out = sign_and_encrypt(client, args).to_context() + encrypted_msg = sign_encrypt_out['EntryContext']['SMIME.SignedAndEncrypted']['Message'] + + with open('temp_encrypted.p7', 'wb') as f: + f.write(encrypted_msg.encode('utf-8')) + + try: + mocker.patch.object(demisto, 'getFilePath', return_value={'name': 'temp_encrypted.p7', 'path': './temp_encrypted.p7'}) + decrypted_out = decrypt_email_body(client, {}) + hr = decrypted_out[0].to_context()['HumanReadable'] + ctx = decrypted_out[0].to_context()['EntryContext']['SMIME.Decrypted'] + assert msg in ctx['Message'] + if msg_type == 'text': + assert msg in hr + + if msg_type == 'html': + html_out = decrypted_out[1].to_context() + assert 'decrypted' in hr + assert msg in html_out['Contents'] + assert html_out['ContentsFormat'] == EntryFormat.HTML + + for attach in test_attachments.split(','): + with open(f'./{attach}') as f, open(f'./test_data/{attach}') as orig: + assert f.read() == orig.read() + + finally: + os.unlink('./temp_encrypted.p7') + for attach in test_attachments.split(','): + os.unlink(f'./{attach}') + + +@pytest.mark.parametrize('msg, msg_type', test_messages) +def test_sign_verify(mocker, msg, msg_type): + """ + Given: + - Client configured with valid key and certificate + - Message to sign, in plain-text or html format + + When: + - Using sign_and_encrypt to sign the message + - Then using verify to check the signature and extract the message + + Then: + - The message will be verified successfully + - For html, an html output entry will be included + - attachments will be extracted + + """ + mocker.patch.object(demisto, 'getFilePath', + side_effect=lambda file_name: {'name': file_name, 'path': f'./test_data/{file_name}'}) + mocker.patch('SMIME_Messaging.fileResult', side_effect=mockFileResult) + args = { + 'message': msg, + 'subject': 'Sign-Verify test subject', + 'sender': 'sender@email.com', + 'encrypted': 'False', + 'signed': 'True', + 'attachment_entry_id': test_attachments, + } + + sign_encrypt_out = sign_and_encrypt(client, args).to_context() + signed_msg = sign_encrypt_out['EntryContext']['SMIME.SignedAndEncrypted']['Message'] + + with open('temp_signed.p7', 'wb') as f: + f.write(signed_msg.encode('utf-8')) + + try: + mocker.patch.object(demisto, 'getFilePath', return_value={'name': 'temp_signed.p7', 'path': './temp_signed.p7'}) + verified_out = verify(client, {}) + hr = verified_out[0].to_context()['HumanReadable'] + ctx = verified_out[0].to_context()['EntryContext']['SMIME.Verified'] + assert msg in ctx['Message'] + assert 'The signature verified' in hr + if msg_type == 'text': + assert msg in hr + + if msg_type == 'html': + html_out = verified_out[1].to_context() + assert msg in html_out['Contents'] + assert html_out['ContentsFormat'] == EntryFormat.HTML + + for attach in test_attachments.split(','): + with open(f'./{attach}') as f, open(f'./test_data/{attach}') as orig: + assert f.read() == orig.read() + + finally: + os.unlink('./temp_signed.p7') + for attach in test_attachments.split(','): + os.unlink(f'./{attach}') + + +def test_sign_encrypt_decrypt_verify(mocker): + """ + Given: + - Client configured with valid key and certificate + + When: + - Using sign_and_encrypt to encrypt and sign a message + - Then using decrypt_message_body followed by verify to reverse the action + + Then: + - The message will decrypt and verify correctly + - attachments will be extracted + + """ + mocker.patch.object(demisto, 'getFilePath', + side_effect=lambda file_name: {'name': file_name, 'path': f'./test_data/{file_name}'}) + mocker.patch('SMIME_Messaging.fileResult', side_effect=mockFileResult) + args = { + 'message': 'Sign-Encrypt-Decrypt-Verify test message', + 'subject': 'Sign-Encrypt-Decrypt-Verify test subject', + 'sender': 'sender@email.com', + 'encrypted': 'True', + 'signed': 'True', + 'attachment_entry_id': test_attachments, + } + + sign_encrypt_out = sign_and_encrypt(client, args).to_context() + encrypted_signed_msg = sign_encrypt_out['EntryContext']['SMIME.SignedAndEncrypted']['Message'] + + with open('temp_encrypted_signed.p7', 'wb') as f: + f.write(encrypted_signed_msg.encode('utf-8')) + + try: + mocker.patch.object(demisto, 'getFilePath', return_value={ + 'name': 'temp_encrypted_signed.p7', 'path': './temp_encrypted_signed.p7' + }) + decrypted_out = decrypt_email_body(client, {})[0].to_context() + assert 'The decrypted message is signed' in decrypted_out['HumanReadable'] + assert 'smime-type=signed-data' in decrypted_out['HumanReadable'] + + finally: + os.unlink('./temp_encrypted_signed.p7') + + decrypted_out_msg = decrypted_out['EntryContext']['SMIME.Decrypted']['Message'] + with open('temp_decrypted_signed.p7', 'wb') as f: + f.write(decrypted_out_msg.encode('utf-8')) + + try: + mocker.patch.object(demisto, 'getFilePath', return_value={ + 'name': 'temp_decrypted_signed.p7', 'path': './temp_decrypted_signed.p7' + }) + verified_out = verify(client, {})[0].to_context() + assert 'Sign-Encrypt-Decrypt-Verify test message' in verified_out['HumanReadable'] + assert 'The signature verified' in verified_out['HumanReadable'] + for attach in test_attachments.split(','): + with open(f'./{attach}') as f, open(f'./test_data/{attach}') as orig: + assert f.read() == orig.read() + + finally: + os.unlink('temp_decrypted_signed.p7') + for attach in test_attachments.split(','): + os.unlink(f'./{attach}') + + +@pytest.mark.parametrize('to, cc, bcc, credentials', test_multi_recipient_params) +def test_multi_encrypt_decrypt(mocker, to, cc, bcc, credentials): + """ + Given: + - Client configured with valid key and certificate + - Recipient lists (to, cc, bcc) and their credentials + + When: + - Using sign_and_encrypt to encrypt a message to these recipients + - Using decrypt_email_body to decrypt the encrypted message with each of the recipient keys + + Then: + - The message will decrypt correctly using any one of the recipients private keys + - The decryption will fail for a key not matching any recipient certificate + + """ + if to: + to = json.dumps(to) + if cc: + cc = json.dumps(cc) + if bcc: + bcc = json.dumps(bcc) + args = { + 'message': 'Multi decrypt test message', + 'sender': 'sender@email.com', + 'signed': 'False', + 'recipients': to, + 'cc': cc, + 'bcc': bcc, + } + + sign_encrypt_out = sign_and_encrypt(client, args).to_context() + encrypted_msg = sign_encrypt_out['EntryContext']['SMIME.SignedAndEncrypted']['Message'] + + with open('temp_encrypted.p7', 'wb') as f: + f.write(encrypted_msg.encode('utf-8')) + mocker.patch.object(demisto, 'getFilePath', return_value={'name': 'temp_encrypted.p7', 'path': './temp_encrypted.p7'}) + + try: + for key, cert in credentials: + decrypt_client = client + if key != 'instanceKey': + decrypt_client = Client(key, cert) + + decrypted_out = decrypt_email_body(decrypt_client, {}) + hr = decrypted_out[0].to_context()['HumanReadable'] + assert 'Multi decrypt test message' in hr + + if 'instanceKey' not in [key for key, _cert in credentials]: + with pytest.raises(Exception): + decrypt_email_body(client, {}) # should fail, wrong credentials + + finally: + os.unlink('temp_encrypted.p7') + + +@pytest.mark.parametrize('decrypted_text_bytes, expected_output, error_msg, encoding', test_decode_data) def test_decode_using_chardet(decrypted_text_bytes, expected_output, error_msg, encoding): """ Given: @@ -99,6 +537,36 @@ def test_decode_using_chardet(decrypted_text_bytes, expected_output, error_msg, def test_test_module(mocker): + """ + Given: + - Client was configured with a valid key and certificate pair + + When: + - Using test module + + Then: + - Test module will finish successfully + + """ from SMIME_Messaging import test_module mocker.patch.object(demisto, 'results') test_module(client) + + +def test_test_module_fail(mocker): + """ + Given: + - Client is configured using non-matching key and certificate + + When: + - Using test module + + Then: + - Test module will fail + + """ + from SMIME_Messaging import test_module + mocker.patch.object(demisto, 'results') + mocker.patch('SMIME_Messaging.return_error', side_effect=Exception()) + with pytest.raises(Exception): + test_module(Client(recipient_key, recipient2_cert)) diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment1.txt b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment1.txt new file mode 100644 index 000000000000..faaedcd7050f --- /dev/null +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment1.txt @@ -0,0 +1 @@ +This is test attachment #1 diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment2.txt b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment2.txt new file mode 100644 index 000000000000..72b31bf941cb --- /dev/null +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/attachment2.txt @@ -0,0 +1 @@ +This is test attachment #2 diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/encrypted-binary-format.p7m b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/encrypted-binary-format.p7m new file mode 100644 index 0000000000000000000000000000000000000000..dddd970f37c14db372c473ea65f2d789e97369e8 GIT binary patch literal 641 zcmV-{0)G84f&zU82`Yw2hW8Bt2Lqsj0&XyZ0%`&Q05O5$FoE9!0RS*aFgq~|FbM_& zRRjhT0!d6U4=@b|162eF3tfowKn0K$={oFbxI?Duzgg_YDC70R;dAfq=G%0fHzN4&@>WE%5rTk>&W-Mr>Wj}l|HFo!s~rx#`K^Zg^1>)xYuX@;wR1oWBC>(3 z(G%ezA;$wYc^X)O^WCayb!EW2(_+eYF1A40YAzu#UWCJxBQP|n)7-$i*a(7K(;K-}NIRzX=C~h5Ao2KPW2o_}uo90$2E&v>qykDexEa+wtyQItMgzhl4(!KX+Gz|w`Vv{i9FJvC?P zgtZRwP`q#Dg=6_Zs5t5tm~_~VMW7|RQDjdP(NUc(;;sAm?O literal 0 HcmV?d00001 diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2.pem b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2.pem new file mode 100644 index 000000000000..dbf23e68d701 --- /dev/null +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICtjCCAh+gAwIBAgIUHscTweh265+Ay0NHeWlwHxSDOsUwDQYJKoZIhvcNAQEL +BQAwbTELMAkGA1UEBhMCSUwxEzARBgNVBAgMClNvbWUtU3RhdGUxDTALBgNVBAoM +BFBhbG8xGDAWBgNVBAMMD1NNSU1FIFJlY2lwaWVudDEgMB4GCSqGSIb3DQEJARYR +cmVjaXBAZXhhbXBsZS5jb20wHhcNMjQwNzE0MTE1OTEwWhcNMjUwNzE0MTE1OTEw +WjBtMQswCQYDVQQGEwJJTDETMBEGA1UECAwKU29tZS1TdGF0ZTENMAsGA1UECgwE +UGFsbzEYMBYGA1UEAwwPU01JTUUgUmVjaXBpZW50MSAwHgYJKoZIhvcNAQkBFhFy +ZWNpcEBleGFtcGxlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxh/1 +0Ww5orZ/Ae8ueikpnOfGp4qgYeWe957EiHYX1sh73xKZQWz2Ur1jF+UjlplsOE65 +HMFHm9HG8SXTa+IeuB+091ru/UuGiXNtY0hE1L+G40/IjMo6at+JTAROiYb2Ix5b +l7v62DSzyQ2rCtO8B3j+ztSttvVX//488MRM1akCAwEAAaNTMFEwHQYDVR0OBBYE +FDmESr+IT6LjE6G1udQB6Szafxn1MB8GA1UdIwQYMBaAFDmESr+IT6LjE6G1udQB +6Szafxn1MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEAinwsFjJh +B7AVAh6mEO+Xc/Utz2EbZzfWnQSOZZPa7wkTbOfFc3IHl2Y4kJ0aB4CJddc4GwMf +tofWjzhzqYA+6wC1Z7VX4cZpQZPtT2mz6s8eAazWlpvGQPnOycwIWWuWLqbRNXWX +Jp8NgBKy1QCjLSqF0himRQbRtsBvIIUNlis= +-----END CERTIFICATE----- diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2_key.pem b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2_key.pem new file mode 100644 index 000000000000..d8fb037c5b41 --- /dev/null +++ b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/recipient2_key.pem @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMYf9dFsOaK2fwHv +LnopKZznxqeKoGHlnveexIh2F9bIe98SmUFs9lK9YxflI5aZbDhOuRzBR5vRxvEl +02viHrgftPda7v1LholzbWNIRNS/huNPyIzKOmrfiUwETomG9iMeW5e7+tg0s8kN +qwrTvAd4/s7Urbb1V//+PPDETNWpAgMBAAECgYEAwzB9h4MuDSXqXsd7bJLdEl4u +EqW6eHg2cxIR4bcmqU3+67hxEEn/K2i2FbaDpz0jpx23taKdn9++NZnkfubZByRY +3yLznoD8WxOGGI4VJsw0zhcat62rUSXvHXLhHjasKVjflMubkiMjQE/B9i1CtkVk +NUGPotJ5NF6cpU3NrmECQQDwL8FStR+nG+mRtt7DHXJlum4qw0L3G7yIHS17w64d +i24r6AE6l5SJ5M4va+Fl/aanENAZJfTX0hTquTnIKQUtAkEA0ytFxASqnHOVxYaK +qDqUM1MS6uxYiHbPc6C6fXpd1c8JFDKGTtNQfKzJ3ZBM7w1y5E0gi+JU66r8sG9H +o8wX7QJAMEvJ+dGFzdpk+vHklSNEr4PvRxYATyP6ovwK+0n7puE0hAugw6FbMucZ +NpvgtNtuOUW+MnBZbVRG9HPOVJs6+QJBAIQ/0Y2VrpQU/3OZczUwmqgaGvrt0fSF +FB9CRglXnXTOGM2BZwPu67VpMXOFb+k27wF0HDH/KVf+2gpVZvR6WXECQQDTwpFD +ziBvP/EXB7ioVeesZqwKQxCFOdeJGC9A13ZGl0PIvM3Pk5Xu+gB8nSCy20Eh2ubR +3ITrFs9DdRgl9n0+ +-----END PRIVATE KEY----- diff --git a/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/signed-binary-format.p7m b/Packs/SMIME_Messaging/Integrations/SMIME_Messaging/test_data/signed-binary-format.p7m new file mode 100644 index 0000000000000000000000000000000000000000..2ddd8aed35a21b10c7ce730cb7226237416f7349 GIT binary patch literal 1369 zcmXqLVhv^E)N1o+`_9YA&a|M3)y<%Z)rpCb(U9MOmyI)_&4V$OnT3gwmBFBiF#@5K zaX}NKCrcBft8;!{Norn+Zb)T8s+B@+X--LIL1Iyfer{$(YKpZ&QhsS(N@7u^t&%M& zFfcYXG_o`{H!w7}Fg7Kf^7Zs})eTE6D$dN$vr;hBGvMXo<GjLc#MAWBpyNi8l>NX<>m%uz7ZQOM8BsZ=P=OwUVA(F3U?*44VY zyj;M*{0I!+w?G`m#K|ys^M=0;vtpKlVgMR9jNHH&ur}m2;ACSCWnmL$^7H}65Rk*c z!{%9Bl$e@hC~Y7KlI7wN3P{Y!S8&WJ$ye}8Eh*10$}TpL6X!LwG&C@@>< z&k_mCek5rdoifc=b?#>t6o1mT&GbI2t(Sq)WxvJcU!GO_syA&3of4__aQ(aqbEmp> z)IMtRSr^E}%*eoq>^xvlG6UV^-FuVy)75il^Ge*EBYpq>m0BdwWzPAXztn3=wEYK{ zDLykDuY2SzReo!JO{b1Sv|THvtu6Fj`umVt$L~(X^EQ_X&y@Y7ROe&TJ1Lc={g;mG zoqr$BCNM7DW}36wqs3Xj)MuWxP+r>THHQ50FxBWclymSq8HJf=PtzY*rii_3xiEA*swSB1B|BwmV3t3E8t$CNlt;)-%)OBa~MJMH!w3N&_?T!*I q(>UM!-($@xDE5SLM_a1NzgZiWI9=MJmg-yThis is a test email, + \ in HTML, signed and encrypted.\nä, Ø, ß \n

\n\n\n" + recipients: + simple: '{"${inputs.recipient}":"instancePublicKey"}' + subject: + simple: Email TEST - HTML Signed and encrypted + separatecontext: false + continueonerrortype: "" + view: |- + { + "position": { + "x": 50, + "y": 380 + } + } + note: false + timertriggers: [] + ignoreworker: false + skipunavailable: false + quietmode: 0 + isoversize: false + isautoswitchedtoquietmode: false + "3": + id: "3" + taskid: f4a4bd33-bfb6-4352-82ae-01709564ef59 + type: title + task: + id: f4a4bd33-bfb6-4352-82ae-01709564ef59 + version: -1 + name: Done + type: title + iscommand: false + brand: "" + separatecontext: false + continueonerrortype: "" + view: |- + { + "position": { + "x": 50, + "y": 765 + } + } + note: false + timertriggers: [] + ignoreworker: false + skipunavailable: false + quietmode: 0 + isoversize: false + isautoswitchedtoquietmode: false + "4": + id: "4" + taskid: 172b41fe-c8b7-4955-8a09-d17a20b98b6b + type: regular + task: + id: 172b41fe-c8b7-4955-8a09-d17a20b98b6b + version: -1 + name: Create attachment + description: | + Creates a file (using the given data input or entry ID) and uploads it to the current investigation War Room. + scriptName: FileCreateAndUploadV2 + type: regular + iscommand: false + brand: "" + nexttasks: + '#none#': + - "1" + scriptarguments: + data: + simple: This is a test attachment + filename: + simple: attachment.txt + separatecontext: false + continueonerrortype: "" + view: |- + { + "position": { + "x": 50, + "y": 180 + } + } + note: false + timertriggers: [] + ignoreworker: false + skipunavailable: false + quietmode: 0 + isoversize: false + isautoswitchedtoquietmode: false + "5": + id: "5" + taskid: 4e40e920-c2ca-413b-84e1-0a9d33e866f2 + type: regular + task: + id: 4e40e920-c2ca-413b-84e1-0a9d33e866f2 + version: -1 + name: Send mail + description: Sends an email using EWS. + script: '|||send-mail' + type: regular + iscommand: true + brand: "" + nexttasks: + '#none#': + - "3" + scriptarguments: + raw_message: + simple: ${SMIME.SignedAndEncrypted.Message} + subject: + simple: SMIME Test subject + to: + simple: ${inputs.recipient} + separatecontext: false + continueonerrortype: "" + view: |- + { + "position": { + "x": 50, + "y": 570 + } + } + note: false + timertriggers: [] + ignoreworker: false + skipunavailable: false + quietmode: 0 + isoversize: false + isautoswitchedtoquietmode: false + "6": + id: "6" + taskid: 1c0dd1fe-1aa3-468c-8d32-ee37b48aaf29 + type: regular + task: + id: 1c0dd1fe-1aa3-468c-8d32-ee37b48aaf29 + version: -1 + name: Delete context + description: |- + Delete field from context. + + This automation runs using the default Limited User role, unless you explicitly change the permissions. + For more information, see the section about permissions here: + https://docs-cortex.paloaltonetworks.com/r/Cortex-XSOAR/6.10/Cortex-XSOAR-Administrator-Guide/Automations + scriptName: DeleteContext + type: regular + iscommand: false + brand: "" + nexttasks: + '#none#': + - "4" + scriptarguments: + all: + simple: "yes" + separatecontext: false + continueonerrortype: "" + view: |- + { + "position": { + "x": 50, + "y": -20 + } + } + note: false + timertriggers: [] + ignoreworker: false + skipunavailable: false + quietmode: 0 + isoversize: false + isautoswitchedtoquietmode: false +view: |- + { + "linkLabelsPosition": {}, + "paper": { + "dimensions": { + "height": 1040, + "width": 380, + "x": 50, + "y": -210 + } + } + } +inputs: +- key: recipient + value: + simple: buildtests@demisto.int + required: false + description: "" + playbookInputQuery: null +outputs: [] +fromversion: 5.0.0 diff --git a/Packs/SMIME_Messaging/pack_metadata.json b/Packs/SMIME_Messaging/pack_metadata.json index 58eeea304646..8790dcef8410 100644 --- a/Packs/SMIME_Messaging/pack_metadata.json +++ b/Packs/SMIME_Messaging/pack_metadata.json @@ -2,7 +2,7 @@ "name": "SMIME Messaging", "description": "Use the S/MIME (Secure Multipurpose Internet Mail Extensions) integration to send and receive secure MIME data.", "support": "xsoar", - "currentVersion": "1.0.24", + "currentVersion": "2.0.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Tests/conf.json b/Tests/conf.json index 7ccb50a3e8a9..4819c6ce7248 100644 --- a/Tests/conf.json +++ b/Tests/conf.json @@ -1828,6 +1828,17 @@ ], "playbookID": "EWS V2 Send Mail Test 3" }, + { + "integrations": [ + "SMIME Messaging", + "EWS v2" + ], + "instance_names": [ + "SMIME Messaging", + "ews_mail_sender_labdemisto" + ], + "playbookID": "SMIME_Messaging-Test" + }, { "playbookID": "decodemimeheader_-_test" },