Skip to content

fix(opencode): anchor checkGaGraph path check to /src/ so antigravity checkout dirs build - #47

Closed
mv2sa wants to merge 4 commits into
cortexkit:mainfrom
mv2sa:fix/ga-graph-checkout-path
Closed

mv2sa wants to merge 4 commits into
cortexkit:mainfrom
mv2sa:fix/ga-graph-checkout-path

Conversation

@mv2sa

@mv2sa mv2sa commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #46

Summary

checkGaGraph in packages/opencode/scripts/build-tui.ts tests each audited file path against GA_FORBIDDEN_SOURCE (/\/(?:rpc|plugin|antigravity|hooks)\/|.../). Because graph.files contains absolute paths, cloning the repository into a directory named antigravity causes every file in the package to match /antigravity/ on the checkout folder name and fail bun run build.

Changes

  • Slice audited paths from the last /src/ segment before testing GA_FORBIDDEN_SOURCE, so directory names above src/ do not collide with package-internal forbidden directories.
  • Add regression coverage in packages/opencode/scripts/build-tui.test.ts (graph.ga_policy_refusals).

Verification

  • bun run build inside a checkout directory named antigravity/ (0 errors)
  • bun test --isolate packages/opencode/scripts/build-tui.test.ts -t "graph.ga_policy_refusals"
  • bun x @biomejs/biome check packages/opencode/scripts/build-tui.ts packages/opencode/scripts/build-tui.test.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

@agauth-alfonso

Copy link
Copy Markdown

Thanks for this. Confirmed: with the change, a full bun run build from a directory named antigravity succeeds, the new test fails without the fix, and the existing build-script tests still pass.

This check enforces that the OpenCode 2 TUI never imports credential-handling code, so it needs to fail closed. Slicing from the last /src/ segment lets one path shape through: a src directory nested inside a forbidden directory. For example, …/src/plugin/src/storage.ts and …/src/antigravity/src/client.ts are both accepted. No such directory exists today, but we'd rather not depend on that. Could you:

  1. Anchor on the package root instead, by testing the path relative to the package root ('/' + relative(packageRoot, path) with separators normalized) and refusing any path that resolves outside the package. buildTui already has packageRoot; checkGaGraph could take it as a parameter.
  2. Add refusal cases to graph.ga_policy_refusals for a forbidden file under an antigravity checkout (for example /work/antigravity/packages/opencode/src/rpc/port-file.ts) and for a nested src under a forbidden directory.

Separately, the TUI-wide check in auditGraph (the regex that includes /tools/) has the same problem with a parent directory named tools. You're welcome to fix it here with the same anchoring, or we can handle it in a follow-up.

@mv2sa

mv2sa commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in aee6616:

  1. Anchored checkGaGraph (and auditGraph) on packageRoot via '/' + portable(relative(packageRoot, path)), failing closed when a path resolves outside packageRoot.
  2. Added refusal cases to graph.ga_policy_refusals for a forbidden file under an antigravity checkout (/work/antigravity/packages/opencode/src/rpc/port-file.ts), nested src directories inside forbidden directories (src/plugin/src/storage.ts and src/antigravity/src/client.ts), and paths outside packageRoot.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread packages/opencode/scripts/build-tui.ts
Comment thread packages/opencode/scripts/build-tui.ts Outdated
@agauth-alfonso

Copy link
Copy Markdown

Thanks — verified on a trial merge onto our current release: the full
build-tui.test.ts suite passes (25 pass, 1 skip), the scripts typecheck is
clean, and the policy test fails with the fix reverted, which is what we
want. All three points are addressed: both checks are anchored on the
package root and fail closed outside it, the refusal cases (forbidden file
under an antigravity checkout, nested src, outside the package) are
covered, and the TUI-wide check got the same anchoring. Approving; we will
run the formatter over the test file on merge (one long files: array it
wants wrapped — CI's format:check would flag it), with no content changes.

ualtinok added a commit that referenced this pull request Oct 27, 2026
checkGaGraph and auditGraph now compare paths relative to the package root
and refuse a path outside it, so a checkout under a directory named
antigravity, plugin, hooks or rpc builds, and a nested src directory inside a
forbidden folder can no longer slip past the credential-isolation check.
Every caller passes the root it checks: the build passes its admitted package
root, and the pack smoke passes the extracted package's own root.

Co-authored-by: Marcos Santanna <2573094+mv2sa@users.noreply.github.com>
@agauth-alfonso

Copy link
Copy Markdown

Thank you for this fix and for working through the review. It shipped in 3.0.14 (https://github.com/cortexkit/antigravity-auth/releases/tag/v3.0.14), squashed into our release branch with you credited as co-author (Co-authored-by), which is why this PR shows as closed rather than merged. We also passed the package root to the pack check that calls the same functions.

@agauth-alfonso agauth-alfonso Bot closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bun run build fails in checkGaGraph when repository is cloned into a directory named antigravity

1 participant