You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** Maximum file size for Slack uploads (free plan: 1GB, but we limit to 100MB for safety) */
47
48
privatestaticfinallongMAX_FILE_SIZE=100*1024*1024
@@ -291,6 +292,60 @@ class BotSlackSender implements SlackSender {
291
292
}
292
293
}
293
294
295
+
/**
296
+
* Validate the Slack connection by calling auth.test.
297
+
* Verifies the endpoint is reachable, the token is valid, and authentication succeeds.
298
+
*
299
+
* @return true if validation passes, false otherwise
300
+
*/
301
+
@Override
302
+
booleanvalidate() {
303
+
// Check token format before making network call
304
+
if (!botToken?.startsWith('xoxb-') &&!botToken?.startsWith('xoxp-')) {
305
+
log.warn "Slack plugin: Bot token must start with 'xoxb-' or 'xoxp-'"
306
+
returnfalse
307
+
}
308
+
if (botToken.startsWith('xoxp-')) {
309
+
log.warn "Slack plugin: You are using a User Token (xoxp-). It is recommended to use a Bot Token (xoxb-) for better security and granular permissions."
if (validateOnStartup !=null) config.validateOnStartup = validateOnStartup
141
+
132
142
// Get webhook URL from nested structure
133
143
def webhook = getWebhookUrl(session)
134
144
@@ -145,22 +155,10 @@ class SlackConfig {
145
155
// Set values in config map for constructor
146
156
if (webhook) config.webhook = webhook
147
157
if (botToken) {
148
-
// Validate token format
149
-
if (!botToken.startsWith('xoxb-') &&!botToken.startsWith('xoxp-')) {
150
-
thrownewIllegalArgumentException("Slack plugin: Bot token must start with 'xoxb-' or 'xoxp-'")
151
-
}
152
-
if (botToken.startsWith('xoxp-')) {
153
-
log.warn "Slack plugin: You are using a User Token (xoxp-). It is recommended to use a Bot Token (xoxb-) for better security and granular permissions."
154
-
}
155
-
156
-
// Validate channel format (basic check)
158
+
// Validate channel is present
157
159
if (!botChannel) {
158
-
thrownewIllegalArgumentException("Slack plugin: Bot channel is required when using bot token")
159
-
}
160
-
// Basic alphanumeric check for channel ID (allow hyphens/underscores for names)
161
-
// Also allow # for channel names
162
-
if (!botChannel.matches(/^[#a-zA-Z0-9\-_]+$/)) {
163
-
thrownewIllegalArgumentException("Slack plugin: Invalid channel ID format: ${botChannel}")
160
+
log.warn "Slack plugin: Bot channel is required when using bot token — plugin will be disabled"
0 commit comments