Repository navigation
fix(hooks): enforce path policies on Antigravity's current file tools #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,75 @@ describe("E2E: Antigravity integration — hook protocol", () => { | |
| }); | ||
| }); | ||
|
|
||
| // Payload shapes captured live from agy 1.4.9 and 1.4.12 with a recorder hook | ||
| // (#961). Every case here was a silent allow before the maps learned this tool set. | ||
| describe("E2E: Antigravity integration — native file tools", () => { | ||
| const deniedCases: Array<[string, string[], string, (cwd: string) => Record<string, unknown>]> = [ | ||
| ["read_file .env", ["block-env-files"], "read_file", (cwd) => ({ Path: `${cwd}/.env` })], | ||
| ["read_file outside the project", ["block-read-outside-cwd"], "read_file", () => ({ Path: "/etc/passwd" })], | ||
| ["view_file with Path", ["block-env-files"], "view_file", (cwd) => ({ Path: `${cwd}/.env` })], | ||
| ["write_file .env", ["block-env-files"], "write_file", (cwd) => ({ Path: `${cwd}/.env`, Content: "X=1" })], | ||
| ["write_file a private key", ["block-secrets-write"], "write_file", (cwd) => ({ Path: `${cwd}/id_rsa`, Content: "k" })], | ||
| ["edit_file .env", ["block-env-files"], "edit_file", (cwd) => ({ Path: `${cwd}/.env`, Target: "a", Replacement: "b" })], | ||
| // No policy enabled at all: this one is the always-on guard, and writing this | ||
| // file is how an agent would switch every other policy off. | ||
| ["write_file over failproofai's own config", [], "write_file", (cwd) => ({ Path: `${cwd}/.failproofai/policies-config.json`, Content: "{}" })], | ||
| ["edit_file on failproofai's own config", [], "edit_file", (cwd) => ({ Path: `${cwd}/.failproofai/policies-config.json`, Target: "a", Replacement: "b" })], | ||
| ]; | ||
|
|
||
| it.each(deniedCases)("denies %s", (_label, policies, tool, args) => { | ||
| const env = createAntigravityEnv(); | ||
| try { | ||
| writeConfig(env.cwd, policies); | ||
| const result = runHook( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning These cases exercise in-process evaluation without configuring failproofaid. The installed daemon passed the manual checks, but that route remains uncovered by these regression tests. Please add a daemon-enabled read_file denial and ordinary-file allow case, asserting the denial names the actual policy rather than an unavailable daemon. |
||
| "PreToolUse", | ||
| AntigravityPayloads.preToolUse.tool(tool, args(env.cwd), env.cwd), | ||
| { homeDir: env.home, cli: "antigravity" }, | ||
| ); | ||
| assertAntigravityDeny(result); | ||
| } finally { | ||
| env.cleanup(); | ||
| } | ||
| }); | ||
|
|
||
| // agy reads its own skills and artifacts with read_file. Those reads only became | ||
| // visible to block-read-outside-cwd once Path mapped, so the ~/.gemini allowlist | ||
| // now carries them. | ||
| it("still allows agy reading its own files under the user's ~/.gemini", () => { | ||
| const env = createAntigravityEnv(); | ||
| try { | ||
| writeConfig(env.cwd, ["block-read-outside-cwd"]); | ||
| const result = runHook( | ||
| "PreToolUse", | ||
| AntigravityPayloads.preToolUse.tool( | ||
| "read_file", | ||
| { Path: `${env.home}/.gemini/antigravity-cli/builtin/skills/agy-customizations/docs/hooks.md` }, | ||
| env.cwd, | ||
| ), | ||
| { homeDir: env.home, cli: "antigravity" }, | ||
| ); | ||
| assertAllow(result); | ||
| } finally { | ||
| env.cleanup(); | ||
| } | ||
| }); | ||
|
|
||
| it("still allows an ordinary read inside the project", () => { | ||
| const env = createAntigravityEnv(); | ||
| try { | ||
| writeConfig(env.cwd, ["block-env-files", "block-read-outside-cwd"]); | ||
| const result = runHook( | ||
| "PreToolUse", | ||
| AntigravityPayloads.preToolUse.tool("read_file", { Path: `${env.cwd}/notes.txt` }, env.cwd), | ||
| { homeDir: env.home, cli: "antigravity" }, | ||
| ); | ||
| assertAllow(result); | ||
| } finally { | ||
| env.cleanup(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("E2E: Antigravity integration — install/uninstall", () => { | ||
| it("policies --install --cli antigravity --scope project writes .agents/hooks.json with named-hook schema", () => { | ||
| const env = createAntigravityEnv(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the PR number in the changelog entry.
This entry ends with
(#961), the linked issue number. Change it to(#964)so the release note identifies this PR. As per coding guidelines, “Each entry should be a single line: a short description followed by the PR number.”Source: Coding guidelines