Browse Source

Check.schedule contains user input and needs to be escaped.

pull/114/merge
Pēteris Caune 8 years ago
parent
commit
94cdfe1e64
2 changed files with 13 additions and 1 deletions
  1. +12
    -0
      hc/api/tests/test_notify.py
  2. +1
    -1
      templates/integrations/slack_message.json

+ 12
- 0
hc/api/tests/test_notify.py View File

@ -205,6 +205,18 @@ class NotifyTestCase(BaseTestCase):
n = Notification.objects.get() n = Notification.objects.get()
self.assertEqual(n.error, "Connection timed out") self.assertEqual(n.error, "Connection timed out")
@patch("hc.api.transports.requests.request")
def test_slack_with_tabs_in_schedule(self, mock_post):
self._setup_data("slack", "123")
self.check.kind = "cron"
self.check.schedule = "*\t* * * *"
self.check.save()
mock_post.return_value.status_code = 200
self.channel.notify(self.check)
self.assertEqual(Notification.objects.count(), 1)
self.assertTrue(mock_post.called)
@patch("hc.api.transports.requests.request") @patch("hc.api.transports.requests.request")
def test_hipchat(self, mock_post): def test_hipchat(self, mock_post):
self._setup_data("hipchat", "123") self._setup_data("hipchat", "123")


+ 1
- 1
templates/integrations/slack_message.json View File

@ -20,7 +20,7 @@
}, },
{% elif check.kind == "cron" %} {% elif check.kind == "cron" %}
{"title": "Schedule", {"title": "Schedule",
"value": "{{ check.schedule }}",
"value": "{{ check.schedule|escapejs }}",
"short": true "short": true
}, },
{% endif %} {% endif %}


Loading…
Cancel
Save