Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTS test app <intent-filter> priorities #307

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions SeedVaultSimulator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,45 @@
android:parentActivityName=".ui.seeds.SeedsActivity"
android:theme="@style/Theme.SeedVaultImpl.NoActionBar" />

<!-- NOTE: intent-filter order set below that of the privileged alias in case an app holds
both permissions. Apps normally should hold only one of the two permissions, but the
<!-- NOTE: Priority set to 100 (which only functions if this app is installed as a
privileged app) to ensure that non-privileged apps cannot handle Seed Vault implicit
intents. Order set below that of the privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. -->
<activity-alias
android:name=".seedDetailsGenericAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT"
android:targetActivity=".ui.seeddetail.SeedDetailActivity">
<intent-filter android:order="-100">
<intent-filter android:priority="100" android:order="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:order="-100">
<intent-filter android:priority="100" android:order="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>

<!-- NOTE: Priority set to 100 (which only functions if this app is installed as a
privileged app) to ensure that non-privileged apps cannot handle Seed Vault implicit
intents. Order set above that of the non-privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. -->
<activity-alias
android:name=".seedDetailsPrivilegedAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED"
android:targetActivity=".ui.seeddetail.SeedDetailActivity">
<intent-filter>
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="100">
<intent-filter android:priority="100" android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SEED_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Expand All @@ -97,6 +104,10 @@
android:noHistory="true"
android:theme="@style/Theme.SeedVaultImpl.Transparent" />

<!-- NOTE: Order set below that of the privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. These
intents are always explicit, so no elevated priority is required. -->
<activity-alias
android:name=".authActivityGenericAlias"
android:exported="true"
Expand All @@ -120,24 +131,28 @@
</intent-filter>
</activity-alias>

<!-- NOTE: Order set above that of the non-privileged alias in case an app holds both
permissions. Apps normally should hold only one of the two permissions, but the
Seed Vault should gracefully handle the case where an app is granted both. These
intents are always explicit, so no elevated priority is required. -->
<activity-alias
android:name=".authActivityPrivilegedAlias"
android:exported="true"
android:permission="com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED"
android:targetActivity=".ui.AuthorizeActivity">
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_AUTHORIZE_SEED_ACCESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_TRANSACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter android:order="0">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_GET_PUBLIC_KEY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Expand Down
37 changes: 36 additions & 1 deletion cts/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
android:theme="@style/Theme.WalletAPISDK">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -36,6 +35,42 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>

<!-- This activity exists to catch unhandled Intents and ensure that they return immediately
with RESULT_CANCELED. Any proper implementation of Seed Vault will have higher priority
handling of these, and so these should never be used. -->
<activity
android:name=".UnhandledIntentActivity"
android:exported="true">
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_AUTHORIZE_SEED_ACCESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_TRANSACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SIGN_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_GET_PUBLIC_KEY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_CREATE_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_IMPORT_SEED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter android:priority="-100">
<action android:name="com.solanamobile.seedvault.wallet.v1.ACTION_SEED_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Solana Mobile Inc.
*/

package com.solanamobile.seedvault.cts

import android.os.Bundle
import androidx.activity.ComponentActivity

class UnhandledIntentActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setResult(RESULT_CANCELED)
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal object TestCorpusProvider {
signatureRequestsExceedLimitTestCase,
denySignTransactionTestCase,
incorrectPinSignTransactionFailureTestCase,
cannotShowSeedSettingsTestCase.takeIf { isGenericBuild },
cannotShowSeedSettingsTestCase.takeIf { isGenericBuild && !isSaga },
showSeedSettingsTestCase.takeIf { !isGenericBuild },
deauthorizeSeed12TestCase.takeIf { isGenericBuild },
hasUnauthorizedSeedsContentProviderTestCase.takeIf { isGenericBuild },
Expand Down