[PM.24380] fix: Correct and redact flight recorder hostname on logs#6633
[PM.24380] fix: Correct and redact flight recorder hostname on logs#6633
Conversation
Replacing api url with selfhosted one on toFailure at NetworkResultCall
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6633 +/- ##
==========================================
+ Coverage 85.91% 86.41% +0.49%
==========================================
Files 801 789 -12
Lines 57098 56791 -307
Branches 8305 8310 +5
==========================================
+ Hits 49056 49074 +18
+ Misses 5160 4834 -326
- Partials 2882 2883 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Great job! No new security vulnerabilities introduced in this pull request |
| val url = if (actualHost != null) { | ||
| "${originalUrl.protocol}://$actualHost${originalUrl.path}" | ||
| } else { | ||
| "${originalUrl.protocol}://${originalUrl.authority}${originalUrl.path}" |
There was a problem hiding this comment.
Do we need to rebuild here, can't we return originalUrl?
SaintPatrck
left a comment
There was a problem hiding this comment.
❓ I recently added logging of hostname to CookieIntercepter. Do those need to be checked/redacted also?
| throwable?.let { | ||
| bw.append(" – ") | ||
| bw.append(it.getStackTraceString()) | ||
| bw.append(it.getStackTraceString().redactUrls()) // Also redact stack traces |
|
|
||
| // Check if this is a hardcoded default URL that will be replaced by BaseUrlInterceptor | ||
| // Match against the defaults from RetrofitsImpl.kt line 111 and EnvironmentUrlDataJson | ||
| val actualHost = if (baseUrlsProvider != null) { |
| // Match against the defaults from RetrofitsImpl.kt line 111 and EnvironmentUrlDataJson | ||
| val actualHost = if (baseUrlsProvider != null) { | ||
| when (originalUrl.host) { | ||
| "api.bitwarden.com" -> baseUrlsProvider.getBaseApiUrl().toHttpUrlOrNull()?.host |
There was a problem hiding this comment.
We can avoid all this complexity with an Interceptor that handles the error logging.
class NetworkErrorLogInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
return chain
.proceed(chain.request())
.also {
if (!it.isSuccessful) {
val url = it.request.url.toUrl().run { "$protocol://$authority$path" }
Timber.e("Network Error: $url")
}
}
}
}
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-24380
📔 Objective
This aims two address different scenarios.
BaseUrlInterceptorhaving updated the url. So now we are checking on theNetworkResultCallif we should update the BaseUrl using the existingBaseUrlsProvider