From 9143639357d5c47cb3be49560f8058be48244d49 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 16 Mar 2023 19:42:17 +0100 Subject: [PATCH] :bug: Fix incorrect webhook url validation --- backend/src/app/rpc/commands/webhooks.clj | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/backend/src/app/rpc/commands/webhooks.clj b/backend/src/app/rpc/commands/webhooks.clj index d07d9ca33..1c6b812c5 100644 --- a/backend/src/app/rpc/commands/webhooks.clj +++ b/backend/src/app/rpc/commands/webhooks.clj @@ -48,25 +48,24 @@ (defn- validate-webhook! [cfg whook params] (when (not= (:uri whook) (:uri params)) - (try - (let [response (http/req! cfg - {:method :head - :uri (str (:uri params)) - :timeout (dt/duration "3s")} - {:sync? true})] - (when-let [hint (webhooks/interpret-response response)] - (ex/raise :type :validation - :code :webhook-validation - :hint hint))) - - (catch Throwable cause - (if-let [hint (webhooks/interpret-exception cause)] + (let [response (ex/try! + (http/req! cfg + {:method :head + :uri (str (:uri params)) + :timeout (dt/duration "3s")} + {:sync? true}))] + (if (ex/exception? response) + (if-let [hint (webhooks/interpret-exception response)] (ex/raise :type :validation :code :webhook-validation :hint hint) (ex/raise :type :internal :code :webhook-validation - :cause cause)))))) + :cause response)) + (when-let [hint (webhooks/interpret-response response)] + (ex/raise :type :validation + :code :webhook-validation + :hint hint)))))) (defn- validate-quotes! [{:keys [::db/pool]} {:keys [team-id]}]