only allow for valid urls in slack button (#5312)

pull/5317/head
Daan Meijer 3 weeks ago committed by GitHub
parent a7407a1b65
commit 13ea190298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,7 +1,7 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { setSettings, setting } = require("../util-server");
const { getMonitorRelativeURL, UP } = require("../../src/util");
const { getMonitorRelativeURL, UP, log } = require("../../src/util");
class Slack extends NotificationProvider {
name = "slack";
@ -50,6 +50,7 @@ class Slack extends NotificationProvider {
const address = this.extractAddress(monitorJSON);
if (address) {
try {
actions.push({
"type": "button",
"text": {
@ -57,8 +58,12 @@ class Slack extends NotificationProvider {
"text": "Visit site",
},
"value": "Site",
"url": address,
"url": new URL(address),
});
} catch (e) {
log.debug("slack", `Failed to parse address ${address} as URL`);
}
}
return actions;

Loading…
Cancel
Save