Skip to content

Commit

Permalink
Fix broken webhook verifier (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Jul 5, 2024
1 parent a7e2a4a commit b986de9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions charts/controller/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ rules:
resources:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- deployments.plural.sh
Expand Down
2 changes: 1 addition & 1 deletion lib/console_web/controllers/webhook_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule ConsoleWeb.WebhookController do

defp verify(conn, %ScmWebhook{type: :github, hmac: hmac}) do
with [signature] <- get_req_header(conn, "x-hub-signature-256"),
computed = :crypto.mac(:hmac, :sha256, hmac, conn.assigns.raw_body),
computed = :crypto.mac(:hmac, :sha256, hmac, Enum.reverse(conn.assigns.raw_body)),
true <- Plug.Crypto.secure_compare(signature, "sha256=#{Base.encode16(computed, case: :lower)}") do
:ok
else
Expand Down
2 changes: 1 addition & 1 deletion lib/console_web/plugs/cached_body_reader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ defmodule ConsoleWeb.CacheBodyReader do
end
end

defp append_body(conn, body), do: update_in(conn.assigns[:raw_body], &[body | (&1 || [])])
defp append_body(conn, body), do: update_in(conn.assigns[:raw_body], & [body | (&1 || [])])
end

0 comments on commit b986de9

Please sign in to comment.