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

fix: only regex a string #16

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/logger_json/plug/metadata_formatters/datadog_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
- The expected outcome would be something like "stord_sk_publickeyasdfasdf_*******", assuming "*******" is the scrub value.
- You can use DataDog's regex to extract the public key part and turn it into a standard attribute.
"""
def extract_public_key(value, scrub_value) do
def extract_public_key(value, scrub_value) when is_binary(value) do
case Regex.named_captures(
~r/Bearer stord_(?<type>sk|ak)_(?<public_key>[A-Za-z0-9+\/]+)_(?<secret_key>.+)/,
value
Expand All @@ -121,6 +121,8 @@
end
end

def extract_public_key(value, scrub_value), do: scrub_value

Check warning on line 124 in lib/logger_json/plug/metadata_formatters/datadog_logger.ex

View workflow job for this annotation

GitHub Actions / Docs

variable "value" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 124 in lib/logger_json/plug/metadata_formatters/datadog_logger.ex

View workflow job for this annotation

GitHub Actions / Dialyzer

variable "value" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 124 in lib/logger_json/plug/metadata_formatters/datadog_logger.ex

View workflow job for this annotation

GitHub Actions / Test

variable "value" is unused (if the variable is not meant to be used, prefix it with an underscore)
vasspilka marked this conversation as resolved.
Show resolved Hide resolved

defp scrubbed_value(key, actual_value, scrub_map) do
case Map.get(scrub_map, key) do
{mod, func, args} when is_atom(mod) and is_atom(func) and is_list(args) ->
Expand Down
Loading