You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored and
Richard Taylor
committed
DownloadManager: document redact_url kwarg for auth-bearing URLs
Companion to MicroPythonOS#136 (adds the kwarg to DownloadManager.download_url).
Adds a new "Redacting Sensitive URLs" section explaining when callers
should opt in, what gets redacted (URL path/query, response-headers,
exception messages — host kept for failure triage), and why the default
is False (preserves useful debug output for public-URL callers).
Updates the parameters table with the new kwarg.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
**Note:** This method works in both async and sync contexts. When called from an async function, it returns a coroutine. When called from a sync function, it runs synchronously.
|`speed_callback`| async function | Callback for download speed (optional) |
104
+
|`redact_url`| bool | Opt-in: hide the URL in log output when it carries an auth secret in its path or query string. Default `False` keeps existing debug output for public URLs. See [Redacting Sensitive URLs](#redacting-sensitive-urls) below. |
`DownloadManager.download_url` prints the request URL three times per download (start, finished, exception path) plus the full response-headers dict — useful debug output for typical callers fetching public URLs (app icons, OS updates, weather data), but it silently leaks any auth secret embedded in the URL.
-**Wallet xpubs** in indexer URLs: `https://btc1.trezor.io/api/v2/xpub/zpub6q…`
157
+
-**LNBits readkey** in URL path on some endpoints
158
+
159
+
A leaked secret-bearing URL ends up in serial / REPL output, screenshots of debug logs, and anywhere those logs are shared. Pass `redact_url=True` to scrub it:
160
+
161
+
```python
162
+
await DownloadManager.download_url(
163
+
"https://btc1.trezor.io/api/v2/xpub/zpub6q…",
164
+
redact_url=True,
165
+
)
166
+
```
167
+
168
+
When `redact_url=True`:
169
+
170
+
- The URL is logged as `scheme://host[:port]/...REDACTED...` (path + query stripped). The host is intentionally kept so failure triage (DNS, connectivity, wrong endpoint) is still possible.
171
+
- The response-headers dump is suppressed entirely (`<redacted>`). Response headers often contain `set-cookie`, `cf-ray`, and other tokens that correlate to the secret-bearing request.
172
+
- Exception messages have any embedded URL substring scrubbed (aiohttp's `ClientConnectorError` typically embeds the URL).
173
+
174
+
Default `False` is deliberate — most callers fetch public URLs and want the full log line for diagnostics. Opt-in is per call.
0 commit comments