TheHive-Project / TheHive

TheHive: a Scalable, Open Source and Free Security Incident Response Platform
https://thehive-project.org
GNU Affero General Public License v3.0
3.28k stars 604 forks source link

[Bug] Unable to send Slack blocks template with `{{object.description}}` because of newlines #2458

Open octocolby opened 1 year ago

octocolby commented 1 year ago

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu
OS version (client) Ubuntu
Virtualized Env. False
Dedicated RAM 16 GB
vCPU 4
TheHive version / git hash 5.0.17-1
Package Type Binary
Database Cassandra
Index type Elasticsearch
Attachments storage Local
Browser type & version If applicable

Problem Description

When sending the {{object.description}} to a Slack webhook that has newlines it breaks the slack payload and no messages arrive in Slack.

Any help would be really appreciated. Thanks.

Steps to Reproduce

  1. Create a slack webhook to send an object description. eg.

    [
    {
        "type": "section",
        "text": {
            "text": "*Description*: {{object.description}}",
            "type": "mrkdwn"
        }
    }
    ]
  2. Create a case with a newline in the description.

  3. Triggering the webhook will fail

Possible Solutions

I have tried to see if there is a way to strip newlines in the templating engine but I haven't seen anything to show that is possible.

Complementary information

I tested and confirmed that my Slack webhook works by setting the description to only a single line and it works.

image

Here is a full screenshot of my test webhook configuration.

image