Security hardening + code-review fixes
Outcome of a full multi-agent code review. Touches TLS, credential storage, API versioning, networking correctness, concurrency/lifecycle, and the release build. See CHANGELOG.md for the full list and the items to port to the iOS app. Security - Remove untrusted-TLS support: delete ServerTrustPolicy.AllowSelfSignedForHost and its trust-all X509TrustManager; drop the self-signed Settings toggle. - Enforce HTTPS in normalizedBaseUrl (reject http + embedded credentials); add network_security_config (no cleartext, system CAs only) + allowBackup=false. - Never persist passwords at rest: remember-me stores email only; no password pre-fill; clear creds on sign-out / when remember-me is off. - Match CSRF host lookup to OkHttp's host parsing; stop leaking raw exception text. Correctness - Fix API versioning: hardcode v1/v3 per endpoint (docs Sec.4) instead of one broken global apiVersion; remove the version plumbing + Settings field. - Treat "warning" status as success (committed write); fail-fast on a missing pagination cursor; close Response on cancellation; tolerant JSON parse; User-Agent. - Firmware isCompatible fails closed + extra acknowledgment for a non-compatible image. Concurrency / lifecycle - Run network I/O on Dispatchers.IO; stale-result generation guards + rethrow CancellationException in all loads; host AppState in a ViewModel (survive config change); thread-safe cookie jar; reset/upgrade re-entry guard; wire list Retry. Build - Enable R8 minify+shrink with kotlinx.serialization keep rules; drop unused navigation-compose; add the missing .gitignore. NOTE: built/verified by static review only (no Android SDK on the dev machine) — run :app:assembleDebug and a release build before shipping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ca3d7d05e0
commit
41098831ae
20 changed files with 505 additions and 191 deletions
33
app/proguard-rules.pro
vendored
33
app/proguard-rules.pro
vendored
|
|
@ -1,4 +1,35 @@
|
|||
# Keep kotlinx.serialization metadata.
|
||||
# ─── kotlinx.serialization ───────────────────────────────────────────────────
|
||||
# R8 must not strip the generated $$serializer classes / serializer() methods or
|
||||
# the @Serializable config (ApiConfiguration, ServerTrustPolicy) fails to (de)serialize.
|
||||
-keepattributes *Annotation*, InnerClasses
|
||||
-dontnote kotlinx.serialization.**
|
||||
-keepclassmembers class kotlinx.serialization.json.** { *; }
|
||||
|
||||
# Keep `serializer()` and the synthetic Companion for every @Serializable type.
|
||||
-if @kotlinx.serialization.Serializable class **
|
||||
-keepclassmembers class <1> {
|
||||
static <1>$Companion Companion;
|
||||
}
|
||||
-if @kotlinx.serialization.Serializable class ** {
|
||||
static **$* *;
|
||||
}
|
||||
-keepclassmembers class <2>$<3> {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# Keep this app's serializable models and their generated serializers explicitly.
|
||||
-keep,includedescriptorclasses class no.svorka.mcms.**$$serializer { *; }
|
||||
-keepclassmembers class no.svorka.mcms.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class no.svorka.mcms.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# ─── OkHttp / Okio ───────────────────────────────────────────────────────────
|
||||
# OkHttp ships its own consumer rules; silence the optional-dependency warnings.
|
||||
-dontwarn okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.conscrypt.**
|
||||
-dontwarn org.bouncycastle.**
|
||||
-dontwarn org.openjsse.**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue