slack-orb icon indicating copy to clipboard operation
slack-orb copied to clipboard

Environment variables with double quotes as content are not handled properly by the orb

Open williamfalconeruk opened this issue 3 years ago • 0 comments

Orb version: 4.4.0

What happened:

  • We created a commit which has a revert message with double quotes e.g "some message"
  • This adds this string to the $COMMIT_MESSAGE environment variable.
  • Use a slack dynamic template or in custom option the following json:
{
    "blocks": [],
    "attachments":
    [
        {
            "color": "#508c18",
            "blocks":
            [
                {
                    "type": "header",
                    "text":
                    {
                        "type": "plain_text",
                        "text": "Production Release Successful",
                        "emoji": false
                    }
                },
                {
                    "type": "section",
                    "text":
                    {
                        "type": "mrkdwn",
                        "text": "public facing url: <https://${PUBLIC_FACING_DOMAIN}/home>"
                    }
                },
                {
                    "type": "section",
                    "text":
                    {
                        "type": "mrkdwn",
                        "text": "admin url: <https://${ADMIN_DOMAIN}>"
                    }
                },
                {
                    "type": "context",
                    "elements":
                    [
                        {
                            "type": "plain_text",
                            "text": "by user: ${CIRCLE_USERNAME} - branch: ${CIRCLE_BRANCH} - Commit Message: ${COMMIT_MESSAGE}"
                        }
                    ]
                }
            ]
        }
    ]
}

this generated the following:

{
    "blocks": [],
    "attachments":
    [
        {
            "color": "#508c18",
            "blocks":
            [
                {
                    "type": "header",
                    "text":
                    {
                        "type": "plain_text",
                        "text": "Production Release Successful",
                        "emoji": false
                    }
                },
                {
                    "type": "section",
                    "text":
                    {
                        "type": "mrkdwn",
                        "text": "public facing url: <https://www.redacted.service.gov.uk/home>"
                    }
                },
                {
                    "type": "section",
                    "text":
                    {
                        "type": "mrkdwn",
                        "text": "admin url: <https://admin.redacted.gov.uk>"
                    }
                },
                {
                    "type": "context",
                    "elements":
                    [
                        {
                            "type": "plain_text",
                            "text": "by user: some user - branch: master - Commit Message: revert "some message"
                        }
                    ]
                }
            ]
        }
    ]
}

this is not handled by the orb and returns the following message:

parse error: Invalid literal at line 1, column 785

Expected behaviour:

the orb should sanitise the quotes by escaping properly any strings inside of env var substitutions

Additional Information:

N/A

williamfalconeruk avatar Apr 23 '21 08:04 williamfalconeruk