зеркало из https://github.com/microsoft/ghcrawler.git
Ignore check_run & check_suite events ASAP (#167)
* Ignore check_run & check_suite events ASAP * Add a comment
This commit is contained in:
Родитель
0602563a59
Коммит
020c39d01e
|
@ -16,7 +16,7 @@ router.post('/', wrap(function* (request, response, next) {
|
|||
return warn(request, response, 'Webhooks not enabled');
|
||||
}
|
||||
const deliveryId = request.headers['x-github-delivery'];
|
||||
getLogger().verbose('Received', `Webhook event`, { delivery: deliveryId });
|
||||
getLogger().verbose('Received', 'Webhook event', { delivery: deliveryId });
|
||||
const signature = request.headers['x-hub-signature'];
|
||||
const eventType = request.headers['x-github-event'];
|
||||
|
||||
|
@ -24,6 +24,12 @@ router.post('/', wrap(function* (request, response, next) {
|
|||
return fatal(request, response, 'Missing signature or event type on GitHub webhook');
|
||||
}
|
||||
|
||||
// Ignoring since check events aren't useful for now and constitute over 99% of the events traffic.
|
||||
if (['check_run', 'check_suite'].includes(eventType)) {
|
||||
getLogger().info('Ignored', 'Webhook event', { delivery: deliveryId, eventType, signature });
|
||||
return response.status(200);
|
||||
}
|
||||
|
||||
const data = request.body;
|
||||
const computedSignature = 'sha1=' + crypto.createHmac('sha1', webhookSecret).update(data).digest('hex');
|
||||
if (!crypto.timingSafeEqual(new Buffer(signature), new Buffer(computedSignature))) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче