Fix crash when receiving a webhook POST for unknown repo
This commit is contained in:
parent
317247e31a
commit
e6def5b3f8
|
@ -13,7 +13,8 @@
|
||||||
[compojure.core :refer [defroutes POST]]
|
[compojure.core :refer [defroutes POST]]
|
||||||
[crypto.equality :as crypto]
|
[crypto.equality :as crypto]
|
||||||
[ring.util.http-response :refer [ok forbidden]]
|
[ring.util.http-response :refer [ok forbidden]]
|
||||||
[commiteth.db.bounties :as bounties-db])
|
[commiteth.db.bounties :as bounties-db]
|
||||||
|
[clojure.string :as string])
|
||||||
(:import java.lang.Integer))
|
(:import java.lang.Integer))
|
||||||
|
|
||||||
(defn find-issue-event
|
(defn find-issue-event
|
||||||
|
@ -187,9 +188,10 @@
|
||||||
(defn validate-secret [webhook-payload raw-payload github-signature]
|
(defn validate-secret [webhook-payload raw-payload github-signature]
|
||||||
(let [full-name (get-in webhook-payload [:repository :full_name])
|
(let [full-name (get-in webhook-payload [:repository :full_name])
|
||||||
repo (repos/get-repo full-name)
|
repo (repos/get-repo full-name)
|
||||||
secret (:hook_secret repo)
|
secret (:hook_secret repo)]
|
||||||
signature (str "sha1=" (hex-hmac-sha1 secret raw-payload))]
|
(and (not (string/blank? secret))
|
||||||
(crypto/eq? signature github-signature)))
|
(crypto/eq? github-signature
|
||||||
|
(str "sha1=" (hex-hmac-sha1 secret raw-payload))))))
|
||||||
|
|
||||||
|
|
||||||
(defroutes webhook-routes
|
(defroutes webhook-routes
|
||||||
|
|
Loading…
Reference in New Issue