Skip to content

fix: Redact Authorization bearer token in debug logs#1284

Merged
takanabe merged 1 commit intov1from
reduct-logs
Apr 21, 2026
Merged

fix: Redact Authorization bearer token in debug logs#1284
takanabe merged 1 commit intov1from
reduct-logs

Conversation

@takanabe
Copy link
Copy Markdown
Contributor

dded _sanitize_headers() function to redact sensitive Authorization bearer tokens when logging HTTP requests in debug mode. The token value is replaced with [REDACTED] while preserving the "Bearer " prefix.

We can use HTTP library for this but this needs library version upgrade. This is the most simplest way to work with small number of code.

I will merge v1 change to v2 after merging this PR>

@takanabe
Copy link
Copy Markdown
Contributor Author

@Konboi there is one failure for Python package build.

Warning: Your Pipfile requires "python_version" 3.6, but you are using 3.10.20 
from //home/runner/.local/share/v/s/bin/python.
$ pipenv --rm and rebuilding the virtual environment may resolve the issue.
$ pipenv check will surely fail.
tests/utils/test_http_client.py:5: error: Cannot find implementation or library stub for module named "smart_tests.app"  [import-not-found]
tests/utils/test_http_client.py:6: error: Cannot find implementation or library stub for module named "smart_tests.utils.http_client"  [import-not-found]
tests/utils/test_http_client.py:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tests/utils/test_http_client.py:7: error: Cannot find implementation or library stub for module named "smart_tests.version"  [import-not-found]
Found 3 errors in 1 file (checked 159 source files)
Error: Process completed with exit code 1.

Is this OK?

Comment thread tests/utils/test_http_client.py Outdated
from launchable.utils.http_client import _HttpClient
from launchable.version import __version__

from smart_tests.app import Application
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to fix the package names

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

v1 is launchable, v2 is smart_tets

Added _sanitize_headers() function to redact sensitive Authorization
bearer tokens when logging HTTP requests in debug mode. The token value
is replaced with [REDACTED] while preserving the "Bearer " prefix.

We can use HTTP library for this but this needs library version upgrade.
This is the most simplest way to work with small number of code.
Copy link
Copy Markdown
Contributor

@Konboi Konboi left a comment

Choose a reason for hiding this comment

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

LGTM - nice

@takanabe takanabe merged commit 2290883 into v1 Apr 21, 2026
13 checks passed
@takanabe takanabe deleted the reduct-logs branch April 21, 2026 00:32
This was referenced Apr 21, 2026
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.

2 participants