Skip to content

Added URL secrets redaction fix #1006 - #1007

Open
ndaprela wants to merge 3 commits into
nats-io:mainfrom
ndaprela:main
Open

Added URL secrets redaction fix #1006#1007
ndaprela wants to merge 3 commits into
nats-io:mainfrom
ndaprela:main

Conversation

@ndaprela

Copy link
Copy Markdown

Added a function to redact secrets in URLs so that they do not get leaked in logs.

Added a function to redact secrets in URLs so that they do not get leaked in logs.
Applied code formatting.

@fallenmi fallenmi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The token-only URL form still leaks the credential on reconnect.

connect() explicitly treats username-only URL userinfo as an authentication token, and the existing test_connect_uses_token_from_url covers that supported form. At exact head cfe39caff85b88c0c8669cfdcc9c5b8e05a72168, this regression oracle fails:

safe = _redact_url("nats://token-secret@example.com:4222")
assert "token-secret" not in safe

Because u.password is None, _redact_url returns the original URL unchanged. Validation showed the password-form oracle moving from RED on the exact base to GREEN on this head, while the token-form oracle remains RED on both; the exact-head nats-core/tests/test_client.py suite is otherwise green (175 passed), so it currently does not exercise token redaction.

Please redact username-only userinfo as well and add a regression for the supported token URL form.

Reviewed with OpenAI Codex assistance.

This commit improves _redact_url to handle token-form and URLs with implicit protocol.

It also introduces tests for this function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants