Skip to content

Commit 6849fa3

Browse files
authored
Merge pull request #6 from cockroachlabs/cla-fix
add try/catch to prevent app from crashing
2 parents d79634a + 505ba80 commit 6849fa3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/server/src/app.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,17 @@ app.all('/api/:obj/:fun', async (req, res) => {
265265

266266
app.all('/github/webhooks', async (req, res) => {
267267
const signature = req.get('X-Hub-Signature')
268-
if (!(await verifyWebhookSignature(
269-
config.server.github.app.webhookSecret,
270-
JSON.stringify(req.body),
271-
signature
272-
))) {
273-
return res.status(401).send('Cannot verify webhook signature')
268+
try {
269+
if (!(await verifyWebhookSignature(
270+
config.server.github.app.webhookSecret,
271+
JSON.stringify(req.body),
272+
signature
273+
))) {
274+
return res.status(401).send('Cannot verify webhook signature')
275+
}
276+
} catch (error) {
277+
log.error('Webhook signature verification failed:', error)
278+
return res.status(401).send('Webhook signature verification failed')
274279
}
275280
const event = req.get('X-GitHub-Event')
276281
const hook = webhooks[event]

0 commit comments

Comments
 (0)