Skip to content

Commit

Permalink
Workaround for elixir-sentry default_body_scrubber bug
Browse files Browse the repository at this point in the history
  • Loading branch information
begedin committed Dec 8, 2016
1 parent f9c60b7 commit 9be728e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion web/router.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
defmodule CodeCorps.Router do
use CodeCorps.Web, :router
use Plug.ErrorHandler
use Sentry.Plug
use Sentry.Plug, body_scrubber: &scrub_params/1

# elixir-sentry 2.0.1 has a bug in the default_body_scrubber
# this deals with the bug and should be removed once the bug is fixex
def scrub_params(conn) do
conn.params
|> Enum.map(fn({key, value}) ->
value = cond do
Enum.member?(["password"], key) -> "*********"
String.valid?(value) && Regex.match?(~r/^(?:\d[ -]*?){13,16}$/, value) -> "*********"
true -> value
end

{key, value}
end)
|> Enum.into(%{})
end

pipeline :browser do
plug :accepts, ["html"]
Expand Down

0 comments on commit 9be728e

Please sign in to comment.