Repository navigation
Detect native apps via zerogapp.json manifests - #6
SPhillips1337 wants to merge 1 commit into
Conversation
Projects without Electron build.fileAssociations can ship a zerogapp.json (name, version, extensions, launch) to appear in Settings > File apps. Relative commands resolve against the project dir; missing executables are skipped; package.json associations keep priority. Enables ZeroG Edit and ZeroG Play detection. 8 new tests (225 total). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Review Summary
This PR adds zerogapp.json manifest detection for native (Rust) apps alongside the existing Electron build.fileAssociations path. The overall structure — validation in the shared zerogAppManifest() function, resolution and existence-check in app-detect.ts, priority of package.json over the manifest — is sound, and the test coverage is good.
Two blocking issues need to be addressed:
-
Logic error in
app-detect.ts: Thecatchblock wrapping thepackage.jsonpath also covers thelaunchForProjectasync call. Any I/O error insidelaunchForProjectwill be silently swallowed and the project treated as if it had nopackage.json, leading to incorrect manifest-path fallback for valid Electron projects. The error boundary should be tightened to only guard thereadFile/JSON.parse. -
Path traversal in
file-apps.tszerogAppManifest(): Thecwdfield from the manifest is accepted verbatim with no path validation, whilecommandis properly resolved and existence-checked. A craftedzerogapp.jsonwith a relativecwd(e.g.,../../../etc) can direct the spawned process into an arbitrary directory.cwdmust be validated as an absolute path (or resolved againstprojectDirand constrained to it).
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| } catch { | ||
| /* no package.json — try a native manifest below */ | ||
| } |
There was a problem hiding this comment.
🛑 Logic Error: The catch block at line 91 swallows all exceptions from the entire try block, including errors thrown by launchForProject (which performs async file I/O). If launchForProject throws — for example, due to a filesystem permission error — the exception is treated as "no package.json", detected stays false, and the code then tries to read zerogapp.json for a project that actually has a valid package.json. This silently drops legitimate Electron projects from detection results. The catch block should only guard the readFile/JSON.parse for package.json, not the launch resolution logic.
| .filter((arg): arg is string => typeof arg === 'string' && arg.length <= 2048 && !/[\0\r\n]/.test(arg)) | ||
| .slice(0, 32) | ||
| : []; | ||
| const cwd = typeof launchSource.cwd === 'string' && launchSource.cwd.trim() ? launchSource.cwd.trim() : undefined; |
There was a problem hiding this comment.
🛑 Security Vulnerability: The cwd value from the manifest is accepted and stored without validation. Unlike command, which is resolved against projectDir and checked for existence with existsSync, cwd is passed through verbatim (after a trim()). A malicious zerogapp.json could supply a cwd like ../../../sensitive/dir, causing the spawned process to run in an arbitrary directory outside the project. At minimum, cwd should be validated as an absolute path; if it must support relative paths, it should be resolved against projectDir and kept within it.
Teaches app detection to read
zerogapp.jsonfor native (Rust) projects alongside Electronbuild.fileAssociations.zerogAppManifest()validates name/version/extensions/launch; args default to{file}; unsafe args filteredlaunch.commandresolves against the project dir; missing exe → skippedpackage.jsonassociations keep priority when both existVerification:
npm run cigreen — 225 tests (8 new), typecheck + build pass.Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>