Skip to content

Commit

Permalink
Fix: Enabling username and passwords to be obfuscated
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryAnkers committed Mar 5, 2024
1 parent 14a3090 commit cff7dff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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',
]
]

0 comments on commit cff7dff

Please sign in to comment.