Skip to content

fix: keep the signing key and the fleet keys from leaving through actions and phone transfer - #111

Merged
GeiserX merged 5 commits into
mainfrom
fix/release-pins-and-backup-rules
Nov 12, 2026
Merged

GeiserX merged 5 commits into
mainfrom
fix/release-pins-and-backup-rules

Conversation

@GeiserX

@GeiserX GeiserX commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Problem

The release job holds the APK signing key. It decodes the keystore and passes its passwords to Gradle. The same job runs gradle/actions/setup-gradle@v6 and android-actions/setup-android@v4 by major tag. Whoever controls those repos can move the tag. setup-gradle then injects init scripts into our signed Gradle run, and the signing key leaks.

Also, the app sets allowBackup="false", but Android 12 and later ignore that for device-to-device transfer. The settings DataStore holds the fleet key and the phone's worker key, and it moved to a new phone during setup.

Fix

  • Pin setup-gradle, setup-android, action-gh-release and codecov-action to full commit SHAs in release.yml and ci.yml. Each pin carries its version in a comment (# v6.4.1). The existing Dependabot github-actions updates keep these pins current. Each pinned SHA equals the current major tag, so behaviour does not change.
  • Add res/xml/data_extraction_rules.xml. It excludes files/datastore/ and the heartbeat state (heartbeat_state.xml: last server URL and earnings snapshot) from cloud backup and from device transfer. The manifest points at it. allowBackup="false" stays, so Android 11 and earlier are unchanged.
  • Fix the SDK levels in CLAUDE.md: compileSdk 37 and targetSdk 36, as in app/build.gradle.kts.

Testing

  • New DataBackupRulesTest (Robolectric). It checks that the merged manifest points at the rules. It gets the DataStore path from preferencesDataStoreFile, the function the preferencesDataStore delegate uses, and checks that both sections exclude it and the heartbeat state. It writes nothing: the delegate is one store per process, so a write from a test can land in another test's folder. An earlier version of this test did that and failed when BackgroundPolicyTest ran first.
  • The tests go red without the fix. Without the manifest attribute: expected:<[@xml/data_extraction_rules]> but was:<[]>. With device-transfer pointing at a wrong path: device-transfer does not exclude file:datastore/cashpilot_settings.preferences_pb. Without the heartbeat exclude, the heartbeat test fails. BackgroundPolicyTest and DataBackupRulesTest pass together in the order that failed before.
  • lintDebug passes. Lint now shows one new warning: it suggests fullBackupContent for API 26 to 30. That is not needed, because allowBackup="false" already turns off all backup on those versions.
  • These runs were in the build container, not CI. CI runs the full suite and the signed release build.

Left out

  • First-party actions/* steps are still on tags. They are not third-party code.
  • Turning on the repo's "require SHA pinning" setting is a separate repo-setting change.
  • Nodle Cash and Wipter still have no referral link. We have no referral code for either yet.

Summary by CodeRabbit

  • Data & Backups
    • App settings and heartbeat state are excluded from cloud backups and device-to-device transfers. Settings won’t be restored from a backup or transferred to a new device, so you may need to configure them again.

…h the signing key

The release job decodes the keystore and passes its passwords to Gradle in
the same job that runs setup-gradle and setup-android by major tag. Pin
those, action-gh-release and codecov-action to full SHAs with the version
in a comment; Dependabot's github-actions updates keep the pins current.
…d 12+

allowBackup=false does not stop device-to-device transfer on Android 12
and later, so the settings DataStore moved to a new phone. Add
dataExtractionRules that exclude it from cloud backup and device transfer.
DataBackupRulesTest checks the manifest points at the rules and that every
file SettingsStore writes is excluded.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CI and release workflows now pin actions to commit SHAs. The Android manifest references rules that exclude datastore and heartbeat state files from cloud backup and device transfer. Robolectric tests check the manifest reference and exclusions. Android SDK versions in the documentation are updated.

Changes: Workflow Action Pinning

Layer / File(s) Summary
Pin workflow actions
.github/workflows/ci.yml, .github/workflows/release.yml
The CI and release workflows use commit-SHA references for setup, coverage, and release actions. Version comments identify the corresponding action versions.

Android Backup Rules

Layer / File(s) Summary
Configure backup exclusions
app/src/main/AndroidManifest.xml, app/src/main/java/com/cashpilot/android/util/SettingsStore.kt, app/src/main/java/com/cashpilot/android/service/Heartbeat.kt, app/src/main/res/xml/data_extraction_rules.xml, CLAUDE.md
The manifest references rules that exclude datastore and heartbeat state files from cloud backup and device transfer. SettingsStore defines the datastore filename, and Heartbeat exposes the preferences name. The documentation updates compileSdk to 37 and targetSdk to 36; minSdk remains 26.
Verify backup exclusions
app/src/test/java/com/cashpilot/android/DataBackupRulesTest.kt
Robolectric tests check the manifest reference and verify that the settings datastore and heartbeat preferences file are excluded from both backup sections.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 50ddb

This change pins CI and release actions to commit SHAs and keeps app-held settings and heartbeat state out of cloud backup and device transfer. No actionable merge-blocking risk remains based on the supplied review evidence.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names two changes that the changeset makes: keeping the signing key and fleet keys from leaving through GitHub Actions tags and phone transfer. The changeset pins actions to commit SHAs in r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names two changes that the changeset makes: keeping the signing key and fleet keys from leaving through GitHub Actions tags and phone transfer. The changeset pins actions to commit SHAs in release.yml and ci.yml, and it excludes the datastore and heartbeat_state files from cloud backup and device transfer. The title covers the main intent, but it leads with the 'keep keys' goal and does not name the mechanisms. It also says 'signing key and fleet keys', which the changeset does not state directly. The title is long at 92 characters, but it is still specific and on topic.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f2cc2d2 and 50ddb22.

Files selected for processing: 4

  • app/src/main/java/com/cashpilot/android/service/Heartbeat.kt
  • app/src/main/java/com/cashpilot/android/util/SettingsStore.kt
  • app/src/main/res/xml/data_extraction_rules.xml
  • app/src/test/java/com/cashpilot/android/DataBackupRulesTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@GeiserX

GeiserX commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Review plan

The required test check is red because of this PR's new test, not because of main. Main's last CI run is green.

Why it fails. SettingsStore keeps its DataStore in a preferencesDataStore delegate (

private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "cashpilot_settings")
). The delegate makes one store per process. That store binds to the files folder of the first Robolectric test that touches it. BackgroundPolicyTest runs the heartbeat worker, which reads the settings, so when it runs first the store lives in its temp folder. The new test then writes through that store, finds nothing in its own folder, and fails at
assertTrue("SettingsStore wrote no file under filesDir", written.isNotEmpty())
. Run alone, the class passes. Run after BackgroundPolicyTest, it fails the same way as CI.

What we change

  • The test stops writing settings. SettingsStore exposes its store name as FILE_NAME. The test gets the file path from preferencesDataStoreFile, the same function the delegate uses, and checks that both sections exclude it. Nothing is shared between tests, so the run order no longer matters.
  • The rules also exclude the heartbeat SharedPreferences file (heartbeat_state.xml). It holds the last server URL and the last earnings snapshot. No key is in it, but allowBackup="false" says nothing should leave the phone, and a phone set up again should start clean. The test checks this exclude too.

What we keep

  • The four SHA pins. Each SHA is the commit of its named tag upstream, and each tag is the latest release. Dependabot's github-actions updates already bump SHA pins and their version comments in this repo.
  • The rules file and the manifest wiring. preferencesDataStore writes to files/datastore/, which domain="file" path="datastore" covers.
  • The CLAUDE.md SDK levels. They match app/build.gradle.kts.

What we leave out

  • Pinning the first-party actions/* steps and a pin checker script. They are outside this PR, and the repo setting that enforces SHA pins is a separate decision.
  • The lint warning that suggests fullBackupContent for API 26 to 30. allowBackup="false" already turns off all backup there, so it is only a warning.

…ared store

The preferencesDataStore delegate is one store per process, bound to the
files folder of the first Robolectric test that touches it. When
BackgroundPolicyTest ran first, the old test wrote into that test's folder,
found nothing in its own and failed. Get the path from
preferencesDataStoreFile, as the delegate does, and check the rules
exclude it.
heartbeat_state holds the last server URL and earnings snapshot. It holds
no key, but allowBackup="false" means nothing should leave the phone, and
a phone set up again should start clean. Exclude it from cloud backup and
device transfer, next to the DataStore.
@GeiserX
GeiserX merged commit 630e0ec into main Nov 12, 2026
5 checks passed
@GeiserX
GeiserX deleted the fix/release-pins-and-backup-rules branch November 12, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant