Ignore check_run & check_suite events ASAP (#167)

* Ignore check_run & check_suite events ASAP
* Add a comment
This commit is contained in:
Gene Hazan 2019-04-18 12:53:06 -07:00 коммит произвёл GitHub
Родитель 0602563a59
Коммит 020c39d01e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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))) {