Improve webhook URI validation

This commit is contained in:
Andrey Antukh 2022-12-14 16:21:23 +01:00
parent 6a7a25121e
commit 6ea0279c9e
9 changed files with 34 additions and 14 deletions

View file

@ -199,10 +199,12 @@
}
}
&.uri,
&.uri {
flex-grow: 1;
}
&.active {
width: 48%;
min-width: 300px;
min-width: 100px;
}
&.last-delivery {

View file

@ -620,7 +620,9 @@
ptk/WatchEvent
(watch [_ state _]
(let [team-id (:current-team-id state)
params (assoc params :team-id team-id)
params (-> params
(assoc :team-id team-id)
(update :uri str))
{:keys [on-success on-error]
:or {on-success identity
on-error rx/throw}} (meta params)]

View file

@ -620,7 +620,7 @@
;; WEBHOOKS SECTION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(s/def ::uri ::us/not-empty-string)
(s/def ::uri ::us/uri)
(s/def ::mtype ::us/not-empty-string)
(s/def ::webhook-form
(s/keys :req-un [::uri ::mtype]))
@ -657,6 +657,8 @@
(let [message (cond
(= hint "unknown")
(tr "errors.webhooks.unexpected")
(= hint "invalid-uri")
(tr "errors.webhooks.invalid-uri")
(= hint "ssl-validation-error")
(tr "errors.webhooks.ssl-validation")
(= hint "timeout")

View file

@ -696,6 +696,9 @@ msgstr "Webhook updated successfully."
msgid "dashboard.webhooks.create.success"
msgstr "Webhook created successfully."
msgid "webhooks.last-delivery.success"
msgstr "Last delivery was successfull."
msgid "errors.webhooks.unexpected"
msgstr "Unexpected error on validating"
@ -705,15 +708,15 @@ msgstr "Timeout"
msgid "errors.webhooks.connection"
msgstr "Connection error, url not reacheable"
msgid "webhooks.last-delivery.success"
msgstr "Last delivery was successfull."
msgid "errors.webhooks.last-delivery"
msgstr "Last delivery was not successfull."
msgid "errors.webhooks.ssl-validation"
msgstr "Error on SSL validation."
msgid "errors.webhooks.invalid-uri"
msgstr "URL does not passes validation."
msgid "errors.webhooks.unexpected-status"
msgstr "Unexpected status %s"

View file

@ -761,6 +761,9 @@ msgstr "Error en la validación SSL."
msgid "errors.webhooks.unexpected-status"
msgstr "Estado inesperado %s"
msgid "errors.webhooks.invalid-uri"
msgstr "La URL no pasa la validacion."
#: src/app/main/ui/alert.cljs
msgid "ds.alert-ok"
msgstr "Ok"