security: SHA256强制+dlUrl域名校验+缓存大小限制(500KB)

- saveCache: >500KB拒绝写入
- index.html: SHA256缺失时拒绝(不再静默跳过)
- index.html: dlUrl域名校验(dlUrl.indexOf(BASE)===0)
- 审查建议全部修复
This commit is contained in:
LukeMackin
2026-07-21 20:39:47 +08:00
parent 67adde25a4
commit f9d5d32785
3 changed files with 4 additions and 0 deletions

View File

@@ -40,6 +40,10 @@ class MainActivity : AppCompatActivity() {
inner class Bridge(private val ctx: MainActivity) { inner class Bridge(private val ctx: MainActivity) {
@android.webkit.JavascriptInterface @android.webkit.JavascriptInterface
fun saveCache(html: String) { fun saveCache(html: String) {
if (html.length > 500_000) {
Log.w(TAG, "Cache rejected: too large (${html.length}B)")
return
}
ctx.cacheFile.writeText(html) ctx.cacheFile.writeText(html)
Log.i(TAG, "Hot-update HTML saved (${html.length}B)") Log.i(TAG, "Hot-update HTML saved (${html.length}B)")
} }