From 5e4fda295f673380c3310476558766e1e02b2732 Mon Sep 17 00:00:00 2001 From: regeloapp-coder Date: Mon, 26 Oct 2026 10:29:10 +0100 Subject: [PATCH 1/3] Fix plaintext database encryption migration Use sqlcipher_export with the stored binary key to migrate legacy SQLite data, preserve the Room schema version, and validate the encrypted result before replacing the original file. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../regelo/app/data/EncryptedLocalDatabase.kt | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/hu/regelo/app/data/EncryptedLocalDatabase.kt b/app/src/main/java/hu/regelo/app/data/EncryptedLocalDatabase.kt index 22b133a..3673d19 100644 --- a/app/src/main/java/hu/regelo/app/data/EncryptedLocalDatabase.kt +++ b/app/src/main/java/hu/regelo/app/data/EncryptedLocalDatabase.kt @@ -95,6 +95,9 @@ internal object EncryptedLocalDatabase { } finally { plainDb.close() } + check(temporary.createNewFile()) { + "A titkosított adatbázis ideiglenes fájlja nem hozható létre." + } listOf("-wal", "-shm").forEach { suffix -> val sidecar = File(database.absolutePath + suffix) check(!sidecar.exists() || sidecar.delete()) { @@ -103,22 +106,38 @@ internal object EncryptedLocalDatabase { } try { - database.copyTo(temporary, overwrite = true) val migrationDb = SQLiteDatabase.openDatabase( - temporary.absolutePath, + database.absolutePath, null, SQLiteDatabase.OPEN_READWRITE, ) try { verifyReadable(migrationDb) - migrationDb.changePassword(passphrase) - verifyReadable(migrationDb) + val schemaVersion = migrationDb.version + migrationDb.execSQL( + "ATTACH DATABASE ? AS encrypted KEY ?", + arrayOf(temporary.absolutePath, passphrase), + ) + try { + migrationDb.rawQuery("SELECT sqlcipher_export('encrypted')", null).use { cursor -> + check(cursor.moveToFirst() && cursor.getInt(0) == 0) { + "Az SQLite-adatbázis titkosított exportja sikertelen." + } + } + migrationDb.execSQL("PRAGMA encrypted.user_version = $schemaVersion") + migrationDb.rawQuery("PRAGMA encrypted.user_version", null).use { cursor -> + check(cursor.moveToFirst() && cursor.getInt(0) == schemaVersion) { + "Az adatbázis sémaverziójának exportja sikertelen." + } + } + } finally { + migrationDb.execSQL("DETACH DATABASE encrypted") + } } finally { migrationDb.close() } verifyEncryptedDatabase(temporary, passphrase) Os.rename(temporary.absolutePath, database.absolutePath) - verifyEncryptedDatabase(database, passphrase) } catch (e: Exception) { temporary.delete() throw IllegalStateException( From e5b208837de80435b37c8fc60fa575484d5b9b20 Mon Sep 17 00:00:00 2001 From: regeloapp-coder Date: Mon, 26 Oct 2026 10:37:18 +0100 Subject: [PATCH 2/3] Run the Android unit tests in CI Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/android.yml | 30 +++++++++++++++++++++++++ .github/workflows/deno.yml | 42 ----------------------------------- 2 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/android.yml delete mode 100644 .github/workflows/deno.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..c99ba9c --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,30 @@ +name: Android + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run unit tests + run: ./gradlew test diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml deleted file mode 100644 index 782af35..0000000 --- a/.github/workflows/deno.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow will install Deno then run `deno lint` and `deno test`. -# For more information see: https://github.com/denoland/setup-deno - -name: Deno - -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -permissions: - contents: read - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Setup repo - uses: actions/checkout@v4 - - - name: Setup Deno - # uses: denoland/setup-deno@v1 - uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2 - with: - deno-version: v1.x - - # Uncomment this step to verify the use of 'deno fmt' on each commit. - # - name: Verify formatting - # run: deno fmt --check - - - name: Run linter - run: deno lint - - - name: Run tests - run: deno test -A From 3d8bbf2fe4eba47933054ccfc349651dc5bf7453 Mon Sep 17 00:00:00 2001 From: regeloapp-coder Date: Mon, 26 Oct 2026 10:37:57 +0100 Subject: [PATCH 3/3] Invoke Gradle wrapper through Bash in CI Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c99ba9c..6ea8d73 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -27,4 +27,4 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: Run unit tests - run: ./gradlew test + run: bash ./gradlew test