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: Enabling username and passwords to be obfuscated #483

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 2 deletions rq_dashboard/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ def get_queue_registry_jobs_count(queue_name, registry_name, offset, per_page):

def escape_format_instance_list(url_list):
if isinstance(url_list, (list, tuple)):
url_list = [re.sub(r"://:[^@]*@", "://:***@", x) for x in url_list]
url_list = [re.sub(r":\/\/[^@]*@", "://***:***@", x) for x in url_list]
elif isinstance(url_list, string_types):
url_list = [re.sub(r"://:[^@]*@", "://:***@", url_list)]
url_list = [re.sub(r":\/\/[^@]*@", "://***:***@", url_list)]
return url_list


Expand Down
17 changes: 16 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rq import Queue, Worker, pop_connection, push_connection

from rq_dashboard.cli import make_flask_app
from rq_dashboard.web import escape_format_instance_list


HTTP_OK = 200
Expand Down Expand Up @@ -107,6 +108,20 @@ def test_worker_version_field(self):
w.register_death()


def test_instance_escaping(self):
expected_redis_instance = "redis://***:***@redis.example.com:6379"
self.assertEqual(
escape_format_instance_list(
[
"redis://myuser:[email protected]:6379",
"redis://:[email protected]:6379",
"redis://:@redis.example.com:6379",
]
),
[expected_redis_instance, expected_redis_instance, expected_redis_instance],
)


__all__ = [
'BasicTestCase',
]
]
Loading