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

Enable URL-encoded chars support in DB username #9588

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

Conversation

abezard-conduit
Copy link

@abezard-conduit abezard-conduit commented Mar 8, 2024

Closes #9589

@@ -56,9 +55,9 @@ defmodule Explorer.Repo.ConfigHelper do

# sobelow_skip ["DOS.StringToAtom"]
defp extract_parameters(database_url) do
~r/\w*:\/\/(?<username>[a-zA-Z0-9_-]*):(?<password>[a-zA-Z0-9-*#!%^&$_.]*)?@(?<hostname>(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])):(?<port>\d+)\/(?<database>[a-zA-Z0-9_-]*)/
~r/\w*:\/\/(?<username>[a-zA-Z0-9-*#!%^&$_.]*):(?<password>[a-zA-Z0-9-*#!%^&$_.]*)?@(?<hostname>(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])):(?<port>\d+)\/(?<database>[a-zA-Z0-9_-]*)/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abezard-conduit it looks, suggested change is too broad to the considered case. I'd suggest adding only "." to the regular expression. Will it be enough to cover IAM-based user creation?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the issue it seems that most needed character is @

With this I faced a following problem: since we decode URL before we extract parameters regular expression fails to extract parameters because the format becomes broken due to unexpected @, so the change that requires most attention is decoding after extracting parameters. Would it break anything, what do you think?

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.

Enable support for URL-encoded characters in database usernames.
3 participants