Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'Options' field is not properly escaped, fails when " some_key_without_value: " is present #8

Open
sirkubax opened this issue Apr 14, 2017 · 2 comments

Comments

@sirkubax
Copy link

sirkubax commented Apr 14, 2017

It seems, that when in the templates/slack-message.ftl the value ${executionData.argstring} is a
{ 'key': value, 'key2': value, "some_key_without_value": }

Options: app: promo system_version_file: stg_default version_in_system_version_file: version_unknown diff: --diff dont_enable_after_deploy: false dry_run: disable_nagios_probe: True version_override: 0.9.926 verbose: -v

a dry_run: is not empty, it contains ' ' whitespace :) yet it should be escaped...

The slack reject the output.
Is this a Slack issue, or a rundeck-slack plugin escaping issue?


2017-04-13 09:02:11,316 [quartzScheduler_Worker-7] ERROR grails.app.services.rundeck.services.NotificationService - Error sending notification: Notification{eventTrigger='onstart', type='SlackNotification', content='{"username":"Rundeck","external_template":"slack-message.ftl","room":"#rundeck","teamDomain":"x","apiAuthToken":"y","icon_url":""}'}: class com.bitplaces.rundeck.plugins.slack.SlackNotificationPluginException: Unknown status returned from Slack API: [invalid_payload].
com.bitplaces.rundeck.plugins.slack.SlackNotificationPluginException: Unknown status returned from Slack API: [invalid_payload].
        at com.bitplaces.rundeck.plugins.slack.SlackNotificationPlugin.postNotification(SlackNotificationPlugin.java:179)
        at rundeck.services.NotificationService.triggerPlugin(NotificationService.groovy:490)
        at rundeck.services.NotificationService$_triggerJobNotification_closure5.doCall(NotificationService.groovy:352)
        at rundeck.services.NotificationService.triggerJobNotification(NotificationService.groovy:147)
        at rundeck.services.NotificationService$_triggerJobNotification_closure1.doCall(NotificationService.groovy:89)
        at rundeck.services.NotificationService.triggerJobNotification(NotificationService.groovy:86)
        at rundeck.services.ExecutionService.executeAsyncBegin(ExecutionService.groovy:959)
        at rundeck.quartzjobs.ExecutionJob.executeCommand(ExecutionJob.groovy:325)
        at rundeck.quartzjobs.ExecutionJob.execute_internal(ExecutionJob.groovy:143)
        at rundeck.quartzjobs.ExecutionJob$_execute_closure1.doCall(ExecutionJob.groovy:91)
        at com.codahale.metrics.Timer.time(Timer.java:99)
        at rundeck.quartzjobs.ExecutionJob.execute(ExecutionJob.groovy:90)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

@sirkubax
Copy link
Author

sirkubax commented Apr 14, 2017

This fixes the problem on the 'template level' :)

<#if (executionData.argstring)?has_content>
    ,{
      "title": "Options",
-      "value": "${executionData.argstring}",
+      "value": "${executionData.argstring?js_string?replace(":", "A")}",
      "short": false
    }
</#if>

Result:

Options: app: promo system_version_file: stg_default version_in_system_version_file: version_unknown diff: --diff dont_enable_after_deploy: false dry_run: disable_nagios_probe: True version_override: 0.9.926 verbose: -v

(do not ask me, why the replacment does not contain "A")

At Slack channel:

Options

-app promo -diff --diff -disable_nagios_probe True -dont_enable_after_deploy false -dry_run " " -system_version_file stg_default -verbose -v -version_in_system_version_file version_unknown -version_override 0.9.926

@sirkubax
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant