You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2b4e39b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-api): address review findings on KeystoreSecretStore
All ten findings from the review at 8f739ca. Both IMPORTANT ones were in the
published contract of a class three plugins are about to adopt, so they are
fixed rather than documented.
encrypt's @throws(GeneralSecurityException) did not cover every way it can
fail: KeyStore.load(null) declares IOException and AndroidKeyStore keygen
raises the unchecked ProviderException, so a plugin catching exactly what the
KDoc documents still took an uncaught throwable - in the host's process, so it
surfaced as an IDE crash. Anything that is not already a
GeneralSecurityException is now wrapped in one, cause preserved; a
KeyStoreException still passes through unwrapped.
The invalidated-key recovery was a delete-then-create-then-encrypt compound
with no serialization, so two concurrent callers could leave one holding a
ciphertext nothing could ever decrypt. readAndMigrate was a read-modify-write
against SharedPreferences with the same gap, so a write committing mid-upgrade
was silently reverted. Both now run under one alias-scoped, process-wide
monitor shared with write - the same scope AndroidKeystoreSource already uses
for its own read-then-generate race, and for the same reason.
Also from the review:
- Stored.Value overrides toString, so a Stored reaching a log line or a crash
breadcrumb can no longer print the decrypted secret.
- decrypt no longer collapses "the key is lost" into "the Keystore would not
answer". A new Stored.Unavailable reports the transient case, so a keystore
that is not ready yet does not tell the user to retype an intact credential.
Free to add now: Stored is sealed and unreleased with no consumers, which is
exactly why the changelog entry now says a later case needs a breaking row.
- AndroidKeystoreSource logs the alias and the unexpected entry class before
replacing a non-SecretKeyEntry, instead of silently overwriting whatever a
colliding plugin left there.
Test harness:
- The two raw NUL bytes are now unicode escapes. Identical bytes once compiled,
but the file is text to git again, so the suite has a reviewable diff on
GitHub (568 added lines vs origin/stage, previously Bin 0 -> 14025 bytes).
- FakeKeySource.delete() mints a fresh key instead of only counting, and
invalidation is modelled on the key rather than the next call - a
next-call-only flag models a failure that cannot happen and is what made the
recovery race untestable.
- Three new regression tests, each confirmed to fail against the unfixed code
for the reason it is named for: concurrent recovery (deleted=2, was 1), a
write racing a legacy upgrade (reverted to legacy-secret), and the
non-GeneralSecurityException wrap (raw IOException escaped). The Unavailable
split and the toString redaction were verified the same way.
36 tests, 0 failures, the two concurrency cases repeated 6x. Whole module: 76
tests, 0 failures. plugin-api.api regenerated: 43 additions, 0 deletions vs
origin/stage, apiCheck green.
Docs: the 26.36 entry claimed later additions to KeystoreSecretStore are
additive. That holds for the class, which plugins instantiate, but not for the
sealed Stored the same entry introduces - a new case breaks every plugin's
exhaustive when at compile time and throws NoWhenBranchMatchedException in an
already-built .cgp. The entry now says a new Stored case needs a breaking row,
including the enc:v2: state its own future-proofing note leaves room for, and
plugin-api.md lists Stored among the sealed types plugins reference.
CI, the last finding: debug.yml ran only :plugin-api:apiCheck, so the suite
never ran on a PR at all (analyze.yml is schedule/dispatch only). Adds a step
beside apiCheck, running testDebugUnitTest rather than testV8DebugUnitTest
because this module declares no product flavors.
jacocoAggregateReport had the matching gap: it collected only
testV8DebugUnitTest and its class and exec paths were v8Debug-only, so
mapNotNull returned nothing for a flavorless module and dropped it from the
report entirely. It now carries a (variant, task) pair list, v8 first, and
collects both shapes. Verified by diffing the generated report against the old
wiring: 286 -> 292 packages (the six com.itsaky.androidide.plugins.* packages
were absent altogether), line 1957/79722 -> 2147/80459, branch 312/44837 ->
361/44961, with KeystoreSecretStore itself at 99% line / 93% branch. The task
graph gains :plugin-api:testDebugUnitTest, which the old wiring did not contain
(0 occurrences in --dry-run before, present after).
sourceDirectories is deliberately left naming src/main/java only, though nine
modules keep sources under src/main/kotlin: it is inert for this task.
Emptying it outright still renders full Kotlin source in the HTML and leaves
the XML byte-identical, so adding the Kotlin roots buys nothing. Measured
rather than assumed, and commented in place so the next reader does not "fix"
it.
Copy file name to clipboardExpand all lines: docs/plugin-api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The surface a plugin binds to is broader than one module. All of the following a
15
15
- Cross-plugin service interfaces, where **one plugin implements what another calls** (via `SharedServices`): `LlmInferenceService` — implemented by ai-core, called by every AI plugin — together with the types nested in it that a *backend* plugin implements (`LlmBackend`, `HistoryCapableBackend`, `ToolCallingBackend`, `CancellableBackend`, `ConfigurableBackend`) and the value types either side constructs (`ChatMessage`, `LlmConfig`, `LlmResponse`, `SystemPromptRequest`, `ToolDefinition`, `ToolCallRequest`). Also `ToolSourceRegistry` — implemented by ai-core, called by any plugin contributing tools to the agent — with `ToolSource` and `ToolSpec`, which a *contributing* plugin implements, `ToolInvocation`, which ai-core constructs and passes to `ToolSource.invoke`, and `ToolOutcome`, which the source returns.
16
16
- Utility classes plugins **instantiate**: `KeystoreSecretStore` (AES/GCM over the Android Keystore, alias supplied by the caller). Host-side implementation rather than an interface, so plugins share one copy in the process instead of compiling their own.
- Enums / sealed types plugins **reference**: `PluginPermission`, `ShowAsAction`, `ArchiveFormat`, `BuildActionCategory`, `ToolbarActionIds`, `CommandSpec`, `CommandResult`, `ExtractResult`, `KeystoreSecretStore.Stored`. Sealed, so a plugin `when`s over the cases exhaustively — adding one is a **breaking** change, not an additive one.
Copy file name to clipboardExpand all lines: plugin-api/api/plugin-api.api
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1231,6 +1231,13 @@ public final class com/itsaky/androidide/plugins/security/KeystoreSecretStore$St
1231
1231
public fun toString ()Ljava/lang/String;
1232
1232
}
1233
1233
1234
+
public final class com/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored$Unavailable : com/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored {
1235
+
public static final field INSTANCE Lcom/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored$Unavailable;
1236
+
public fun equals (Ljava/lang/Object;)Z
1237
+
public fun hashCode ()I
1238
+
public fun toString ()Ljava/lang/String;
1239
+
}
1240
+
1234
1241
public final class com/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored$Unreadable : com/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored {
1235
1242
public static final field INSTANCE Lcom/itsaky/androidide/plugins/security/KeystoreSecretStore$Stored$Unreadable;
0 commit comments