feat(plugins): a granted plugin's Java agent joins Java run configurations (API 1.10) (#3830)

Plugins that instrument the user's application had no way to get a Java agent into the JVM the IDE starts. A [[contributes.javaAgents]] entry (one per plugin, a jar inside the package, optional single-line args, API ^1.10) derives the high-risk java.agent capability; granting it records the jar's blake3 hash, and every launch re-hashes the jar and leaves out a changed or missing one until approved again. For Application, Spring Boot and JAR Application run and debug, the host adds one -javaagent argument after the VM options (java-debug vmArgs, Kotlin vmArguments), never twice, and a shortened command line keeps it as its own argument. Remote projects and run targets get no agent, with one console line. Settings › Plugins shows the agent next to the permission.

Closes #3566

Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
This commit is contained in:
Bert Verhelst
2026-11-17 03:20:18 +08:00
committed by GitHub
co-authored by bertyhell
parent 6c9556ef54
commit 2b69d64055
28 changed files with 1023 additions and 12 deletions
+51
View File
@@ -0,0 +1,51 @@
import { beforeEach, expect, it, vi } from "vitest";
import type { CapabilityInfo, PluginInfo } from "@/platform/ipc";
const state = vi.hoisted(() => ({ remote: false, plugins: [] as unknown[] }));
vi.mock("@/platform/remote", () => ({ isRemoteWindow: () => state.remote }));
vi.mock("@/platform/ipc", async (original) => {
const real = await original<typeof import("@/platform/ipc")>();
return {
...real,
commands: {
...real.commands,
pluginList: vi.fn(() => Promise.resolve({ status: "ok", data: { plugins: state.plugins } })),
},
};
});
const { remoteJavaAgentNote } = await import("./javaLaunch");
function plugin(name: string, enabled: boolean, granted: boolean | null): PluginInfo {
const capabilities: CapabilityInfo[] =
granted === null ? [] : [{ id: "java.agent", risk: "high", description: "", optional: true, granted }];
return { name, enabled, capabilities } as unknown as PluginInfo;
}
beforeEach(() => {
state.remote = true;
state.plugins = [
plugin("Spring Agent", true, true),
plugin("Refused", true, false),
plugin("Off", false, true),
plugin("Theme", true, null),
];
});
it("says once that a remote Java launch got no agent, naming the plugins with a granted one", async () => {
for (const kind of ["application", "spring-boot", "jar-application"]) {
expect(await remoteJavaAgentNote({ kind })).toBe(
"Java agents of Spring Agent were not added: they load only in local projects.\n",
);
}
});
it("says nothing for local projects, other kinds, or without a granted agent", async () => {
expect(await remoteJavaAgentNote({ kind: "maven" })).toBeNull();
expect(await remoteJavaAgentNote({ kind: "junit" })).toBeNull();
state.remote = false;
expect(await remoteJavaAgentNote({ kind: "application" })).toBeNull();
state.remote = true;
state.plugins = [plugin("Refused", true, false)];
expect(await remoteJavaAgentNote({ kind: "application" })).toBeNull();
});