Repository navigation
feat: add Java framework support - #948
Conversation
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
700cbba to
6cad9a7
Compare
ffc03e7 to
de69e22
Compare
Adds Java (server) as a supported framework, stacked on the Rust framework PR: - Integration.java enum entry ordered after kmp/swift/android — those claim gradle projects first — and before the language fallbacks - JAVA_AGENT_CONFIG in src/frameworks/java/ — claims pom.xml unconditionally (Maven is unambiguously JVM backend) and root gradle files only when they carry no Android/KMP plugin markers and no AndroidManifest.xml subtree exists; gathers buildTool (maven | gradle) as agent context; installs by editing the build file with com.posthog:posthog-server then resolving with mvn install / gradle build - detectJavaPackageManagers detector (Maven via pom.xml, Gradle fallback reusing gradlePackageManager) + FRAMEWORK_REGISTRY entry - No bash-fence changes needed: mvn/mvnw and gradle/gradlew grammars already exist from Android/KMP - Pins framework: java on a new integration-java entry in the variant-resolution contract test, matching context-mill PR #270 which must release before this merges - Marks pom.xml as a real framework target in the agentic manifest comment, leaving .NET as the only manifest without a target Generated-By: PostHog Code Task-Id: 9c949855-7611-48f2-b8b5-7aa4112543e5
de69e22 to
c8c2d59
Compare
Additive conflicts against the Flutter work: both kept; drops the pre-rename duplicate of the Flutter detection test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| projectTypeDetection: | ||
| 'This is a Java server project. Look for pom.xml (Maven) or build.gradle/build.gradle.kts (Gradle), src/main/java/, and the framework in use (Spring Boot, Quarkus, Micronaut, plain servlets) to confirm.', | ||
| packageInstallation: | ||
| 'Neither Maven nor Gradle has a single add command. Add the com.posthog:posthog-server dependency (pinned to the latest release on Maven Central) to pom.xml or build.gradle(.kts), matching the existing dependency format, then run `mvn install` or `gradle build` to resolve it.', |
There was a problem hiding this comment.
High: Repository-defined code execution
An attacker can execute arbitrary commands on a developer's machine by placing an execution plugin in pom.xml or code in a Gradle build script: this prompt directs the agent to run mvn install or gradle build, and both commands are permitted by the Bash fence without user approval. Add the dependency by editing the manifest, but do not automatically execute a project lifecycle; the mvn install value returned by detectJavaPackageManagers must also be removed or made non-executable so the generic package-manager instructions cannot trigger the same path.
| function readRootGradleFiles(installDir: string): string[] { | ||
| return GRADLE_FILES.map((name) => path.join(installDir, name)) | ||
| .filter((p) => fs.existsSync(p)) | ||
| .map((p) => fs.readFileSync(p, 'utf-8')); |
There was a problem hiding this comment.
Low: Unbounded project scanning
An attacker can exhaust memory or stall the wizard by supplying oversized root Gradle files or a large or symlinked tree of AndroidManifest.xml files. Use readProjectFile for the build files and boundedGlob with limit: 1 for the manifest check; these helpers enforce file-size, traversal, match-count, and deadline bounds.
PR overviewThis pull request adds Java framework support to the wizard agent, including detection of Maven, Gradle, and Android projects and instructions for adding dependencies. Three security issues remain open, with none addressed so far. A malicious repository could cause arbitrary commands to run through Maven or Gradle lifecycle execution, while symlinked manifests could expose local secret files to the agent. Unbounded file and directory scanning also creates a denial-of-service risk. Open issues (3)
Fixed/addressed: 0 · PR risk: 8/10 |
|
Full e2e run of this PR pair (wizard #948 + context-mill #270, both with main merged in) against spring-projects/spring-petclinic. Set up, one honest conflict — the runner has no JRE so the agent could not self-verify. Idiomatic Spring: Dashboard and notebook created through prod MCP. Compiles clean, but petclinic's own Note: the context-mill branch as filed fails at the dashboard step — its agent prompts predate the |
The result JSON parsed package.json and pubspec.yaml only, so Go, Rust, Java, and Elixir runs reported hasPosthogDep false; a *.env file like gotify's also failed the .env prefix check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…sitive Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Go framework support landed on main in parallel, so most conflicts were two frameworks claiming the same list. Kept both sides, with java staying after kmp/swift/android so those keep first claim on gradle projects. Also restores the "a Flutter project resolves to flutter" detection test, which this branch overwrote with its Maven test. Main still has it, so the merge is the right place to bring it back. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
||
| if (fs.existsSync(path.join(installDir, 'pom.xml'))) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
High: Symlinked manifests bypass secret-file fencing
An attacker can commit pom.xml as a symlink to .env. When the victim has that file, this check classifies the repository as Java, and the integration instructions subsequently make the agent read pom.xml before editing it; the tool gate sees the benign basename rather than .env, so the secret contents enter the model context. Reject symlinks and require each Java manifest's resolved path to remain inside installDir before using it for detection; apply the same check to the Gradle files.
Elixir support (#946) landed on main, so the conflicts were java and elixir claiming the same lists. Kept both sides throughout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rust support (#947) landed on main, so the conflicts were java and rust claiming the same lists. Kept both sides, with java staying after kmp/swift/android so those keep first claim on gradle projects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

























Related PRs:
mainand can merge on its own, in any order relative to the sibling Go/Elixir/Rust/Java framework PRs.Adds Java (server) as a supported framework. Java is the one language here whose manifest collides with existing frameworks — Android and KMP both claim gradle projects — so detection is deliberately conservative:
Integration.javaenum entry ordered afterkmp/swift/android(they claim gradle projects first, enforced by a new enum-order test) and before the language fallbacksJAVA_AGENT_CONFIGinsrc/frameworks/java/— claimspom.xmlunconditionally (Maven is unambiguously a JVM backend); claims root gradle files only when they carry no Android/KMP plugin markers and noAndroidManifest.xmlexists anywhere in the tree (mirroring the Android detector's own strategies, so a directdetect()call can never claim their projects); Flutter'spubspec.yamlguard includedgatherContextrecords the build tool (maven|gradle) for analytics tags and the agent promptdetectJavaPackageManagers— a real detector (Maven viapom.xml, otherwise the existinggradlePackageManager); install guidance is manual-edit-then-resolve since neither tool has a single add verb, pinningcom.posthog:posthog-serverfrom Maven Centralposthog-androidis a different library, and covers the client lifecycle (close()on shutdown,flush()in serverless)mvn/mvnwandgradle/gradlewgrammars already exist from Android/KMPframework: javaon a newintegration-javaentry in the variant-resolution contract test, matching the context-mill PR aboveWhy: the wizard docs page lists Java as "Coming soon"; instead of removing the label (posthog.com#18797), we're making the wizard actually support it.
Verification:
pnpm build✅,pnpm test✅ (1560 tests, incl. 7 new java detect cases + enum-order + package-manager detection tests),pnpm fix✅Created with PostHog Code