Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redact sensitive struct fields on inspect #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

grzuy
Copy link

@grzuy grzuy commented Jul 25, 2024

Hi,

Thanks for this great library.

Noticed these fields end up on our app's logs and/or error tracking reports in cases like e.g. MatchError: no match of right hand side value: %OAuth2.Client{..., client_secret: "<secret>", ...} when having match errors when doing stuff like

%{
  ...
} = oauth2_client

We temporarily fixed this on our app's end by writing

defimpl Inspect, for: OAuth2.Client do
  def inspect(%OAuth2.Client{} = client, opts) do
    client
    |> Map.replace(:client_secret, "[REDACTED]")
    |> Inspect.Any.inspect(opts)
  end
end

defimpl Inspect, for: OAuth2.AccessToken do
  def inspect(%OAuth2.AccessToken{} = client, opts) do
    client
    |> Map.replace(:access_token, "[REDACTED]")
    |> Map.replace(:refresh_token, "[REDACTED]")
    |> Inspect.Any.inspect(opts)
  end
end

But maybe you wanted to consider adding it to the package?

Thanks.

@grzuy grzuy changed the title Redact sensitive fields on inspect Redact sensitive struct fields on inspect Jul 25, 2024
Copy link

This pull request has been automatically marked as "stale:discard". If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated!.

@grzuy
Copy link
Author

grzuy commented Sep 24, 2024

Bump

Copy link

This pull request has been automatically marked as "stale:discard". If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated!.

@grzuy
Copy link
Author

grzuy commented Nov 24, 2024

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant