Skip to content

Commit c695fe4

Browse files
committed
fix: guard slack
Signed-off-by: Innei <tukon479@gmail.com>
1 parent acf2a56 commit c695fe4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

apps/api/src/controllers/webhook.controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ export async function slackWebhook(
186186
return reply.status(400).send({ error: 'Invalid params' });
187187
}
188188
const slackInstaller = createSlackInstaller();
189+
if (!slackInstaller) {
190+
request.log.error('Slack installer not found');
191+
return reply.status(500).send({ error: 'Slack installer not found' });
192+
}
189193

190194
const veryfiedState = await slackInstaller.stateStore?.verifyStateParam(
191195
new Date(),

packages/integrations/src/slack.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export const createSlackInstaller = () => {
88
const SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID;
99
const SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET;
1010
const SLACK_STATE_SECRET = process.env.SLACK_STATE_SECRET;
11+
if (!SLACK_CLIENT_ID || !SLACK_CLIENT_SECRET || !SLACK_STATE_SECRET) {
12+
return null
13+
}
1114
const slackInstaller = new InstallProvider({
1215
clientId: SLACK_CLIENT_ID!,
1316
clientSecret: SLACK_CLIENT_SECRET!,
@@ -24,6 +27,9 @@ export const getSlackInstallUrl = ({
2427
}: { integrationId: string; organizationId: string; projectId: string }) => {
2528

2629
const slackInstaller = createSlackInstaller();
30+
if (!slackInstaller) {
31+
return null;
32+
}
2733
return slackInstaller.generateInstallUrl({
2834
scopes: [
2935
'incoming-webhook',

0 commit comments

Comments
 (0)