fix: add URL validation to webhook endpoints (#26593)
Validates webhook URLs on create and update: - HTTPS required (HTTP allowed for self-hosted and E2E) - Blocks private IP ranges and localhost - Blocks cloud metadata endpoints Existing webhooks are preserved: validation only applies when URL is created or changed. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c57b517555
commit
cb36fc201f
17 files changed
+386
-75
No files matched your search
+5
@@ -1,6 +1,7 @@
|
||||
import { OrganizationsWebhooksRepository } from "@/modules/organizations/webhooks/organizations-webhooks.repository";
|
||||
import { UpdateWebhookInputDto } from "@/modules/webhooks/inputs/webhook.input";
|
||||
import { PipedInputWebhookType } from "@/modules/webhooks/pipes/WebhookInputPipe";
|
||||
import { validateWebhookUrl, validateWebhookUrlIfChanged } from "@/modules/webhooks/utils/validate-webhook-url";
|
||||
import { WebhooksRepository } from "@/modules/webhooks/webhooks.repository";
|
||||
import { ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
||||
|
||||
@@ -12,6 +13,8 @@ export class OrganizationsWebhooksService {
|
||||
) {}
|
||||
|
||||
async createWebhook(orgId: number, body: PipedInputWebhookType) {
|
||||
validateWebhookUrl(body.subscriberUrl);
|
||||
|
||||
const existingWebhook = await this.organizationsWebhooksRepository.findWebhookByUrl(
|
||||
orgId,
|
||||
body.subscriberUrl
|
||||
@@ -40,6 +43,8 @@ export class OrganizationsWebhooksService {
|
||||
}
|
||||
|
||||
async updateWebhook(webhookId: string, body: UpdateWebhookInputDto) {
|
||||
const existingSubscriberUrl = await this.webhooksRepository.getWebhookSubscriberUrl(webhookId);
|
||||
validateWebhookUrlIfChanged(body.subscriberUrl, existingSubscriberUrl);
|
||||
return this.webhooksRepository.updateWebhook(webhookId, body);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user