Repository navigation
fix: keep the signing key and the fleet keys from leaving through actions and phone transfer - #111
Conversation
…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.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Review planThe required Why it fails. 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
. Run alone, the class passes. Run after BackgroundPolicyTest, it fails the same way as CI.
What we change
What we keep
What we leave out
|
…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.
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@v6andandroid-actions/setup-android@v4by major tag. Whoever controls those repos can move the tag.setup-gradlethen 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
setup-gradle,setup-android,action-gh-releaseandcodecov-actionto full commit SHAs inrelease.ymlandci.yml. Each pin carries its version in a comment (# v6.4.1). The existing Dependabotgithub-actionsupdates keep these pins current. Each pinned SHA equals the current major tag, so behaviour does not change.res/xml/data_extraction_rules.xml. It excludesfiles/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.CLAUDE.md: compileSdk 37 and targetSdk 36, as inapp/build.gradle.kts.Testing
DataBackupRulesTest(Robolectric). It checks that the merged manifest points at the rules. It gets the DataStore path frompreferencesDataStoreFile, the function thepreferencesDataStoredelegate 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 whenBackgroundPolicyTestran first.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.BackgroundPolicyTestandDataBackupRulesTestpass together in the order that failed before.lintDebugpasses. Lint now shows one new warning: it suggestsfullBackupContentfor API 26 to 30. That is not needed, becauseallowBackup="false"already turns off all backup on those versions.Left out
actions/*steps are still on tags. They are not third-party code.Summary by CodeRabbit