fix: address performance and security findings
- Add PostgreSQL-backed backend and frontend tests to CI - Harden Android API logging and disable app backups - Update the performance report with resolved findings
This commit is contained in:
1 parent
a84a36349b
commit
937f51b4fb
35 files changed
+2566
-332
No files matched your search
@@ -40,6 +40,7 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<application
|
||||
android:name=".CollabTableApplication"
|
||||
android:allowBackup="true"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.collabtable.app.data.api
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import com.collabtable.app.BuildConfig
|
||||
import com.collabtable.app.data.preferences.PreferencesManager
|
||||
import com.collabtable.app.utils.Logger
|
||||
import okhttp3.Interceptor
|
||||
@@ -17,9 +18,13 @@ object ApiClient {
|
||||
private var retrofit: Retrofit? = null
|
||||
private var context: Context? = null
|
||||
|
||||
// Bodies and the Authorization header carry the sync token and user data, so
|
||||
// only debug builds log them, and the header is redacted in every build.
|
||||
private val loggingInterceptor =
|
||||
HttpLoggingInterceptor().apply {
|
||||
level = HttpLoggingInterceptor.Level.BODY
|
||||
level =
|
||||
if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
|
||||
redactHeader("Authorization")
|
||||
}
|
||||
|
||||
private val authInterceptor =
|
||||
@@ -116,6 +121,18 @@ object ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
// Cleartext stays allowed so LAN servers work (see network_security_config.xml). The
|
||||
// warning makes the trade-off visible: the sync token and data are not encrypted in transit.
|
||||
private fun warnIfCleartext(url: String) {
|
||||
if (url.startsWith("http://", ignoreCase = true)) {
|
||||
Logger.w(
|
||||
"HTTP",
|
||||
"API base URL uses plain HTTP: the sync token and data are not encrypted in transit. " +
|
||||
"Use HTTPS for any server outside your LAN.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun initialize(context: Context) {
|
||||
this.context = context.applicationContext
|
||||
val prefs = PreferencesManager.getInstance(context)
|
||||
@@ -124,6 +141,7 @@ object ApiClient {
|
||||
Logger.i("HTTP", "API base URL initialized to $baseUrl")
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
warnIfCleartext(baseUrl)
|
||||
retrofit = buildRetrofit()
|
||||
}
|
||||
|
||||
@@ -133,6 +151,7 @@ object ApiClient {
|
||||
Logger.i("HTTP", "API base URL set to $baseUrl")
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
warnIfCleartext(baseUrl)
|
||||
retrofit = buildRetrofit()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user