Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .agents/skills/secfoo-fix-findings/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: secfoo-fix-findings
description: Triage and remediate open secfoo security findings in the repository. Shared by OpenAI Codex and Antigravity (`agy`).
---

# Fix secfoo Findings

1. Run `secfoo run --json` (or inspect `.secfoo/findings.json` if inside a network-restricted sandbox).
2. Group findings by severity (`critical`, `high`, `medium`, `low`).
3. Fix each finding with minimal, well-tested edits.
4. Re-run `secfoo run --json` and the project test suite to verify the findings are resolved.
19 changes: 19 additions & 0 deletions docs/GEMINI_AGY_AUTOMATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Gemini CLI and Antigravity (`agy`) Automations (#247)

secfoo supports both **Gemini CLI** and **Antigravity (`agy`)**.

## Gemini CLI

- **Config:** `.gemini/settings.json` (`hooks` object with `BeforeTool`, `AfterTool`, `AfterAgent`, `SessionStart`, `SessionEnd`). `timeout` is in **milliseconds** (default `60000`).
- **Extension:** Installable from GitHub via `gemini extensions install` using `extensions/gemini-secfoo/` (`gemini-extension.json`, `hooks/hooks.json`, `commands/secfoo/fix-findings.toml`, `skills/secfoo-fix-findings/SKILL.md`).
- **Headless (`gemini -p`):** secfoo's `SECFOO_HOOK_ACTIVE` recursion guard prevents nested hook loops when `gemini -p` is used as a delegate runner.
- **AfterTool:** Never denies (denying `AfterTool` hides tool output in Gemini CLI); instead surfaces `additionalContext`.
- **AfterAgent:** `decision: "deny"` forces a retry and is loop-guarded via `stop_hook_active` / `retry_active`.

## Antigravity (`agy`)

- **Config:** `.agents/hooks.json` (workspace) or `~/.gemini/config/hooks.json` (global). Hooks in `~/.gemini/antigravity-cli/settings.json` are **not** loaded. `timeout` is in **seconds** (default `30`).
- **Events:** `PreToolUse` (`run_command`), `PostToolUse`, `Stop` (`decision: "continue"`, guarded by `continuationActive`), and `SessionStart` (`injectSteps`).
- **Skills:** `.agents/skills/<name>/SKILL.md` is shared with OpenAI Codex without duplication. Workflows are deprecated in favor of skills.
- **Scheduling:** Session schedules in `agy` do not replace CI; use CI or a cloud scheduler for `scheduled-baseline`.
- **Migration note:** Users migrating from Gemini CLI to Antigravity should install hooks via `secfoo automations enable <recipe> --host antigravity` rather than relying on `.gemini/settings.json` hook blocks carrying over automatically.
28 changes: 28 additions & 0 deletions docs/automations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Secfoo Automations & `secfoo hook`

Secfoo provides a single tested hook entrypoint (`secfoo hook <recipe> --host <tool>`) and a recipe manager (`secfoo automations`) for AI coding tools.

## Recipes

Built-in recipes live in `src/secfoo/automations/recipes/*.toml` (and user overrides in `~/.secfoo/automations/*.toml` — never loaded from untrusted target repositories):

- `commit-guard`: Scans staged changes for secrets and high-risk issues before `git commit`, `git push`, or `gh pr create`.
- `secret-on-edit`: Scans edited files for credentials after file edits.
- `pr-security-review`: Runs quick SAST + reachability checks on changed files before PR creation.

## Host Support & Detection

Supported hosts: `claude` (reference adapter), `cursor`, `copilot`, `gemini`, `antigravity`, `kiro`, `droid`, `codex`, `opencode`.

`secfoo hook` detects the actual host from environment variables and stdin payload shape, warns on `--host` mismatches, enforces `SECFOO_HOOK_ACTIVE=1` recursion protection and `stop_hook_active` / `continuationActive` / `loop_count` loop guards, deduplicates concurrent hooks, and fails open on errors or expired budgets.

## CLI

```sh
secfoo automations list
secfoo automations enable commit-guard --host claude --dry-run
secfoo automations enable commit-guard --host claude
secfoo automations status
secfoo automations doctor
secfoo automations disable commit-guard --host claude
```
4 changes: 4 additions & 0 deletions extensions/gemini-secfoo/commands/secfoo/fix-findings.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
description = "Run secfoo security review and remediate open findings"
prompt = """
Run `secfoo run --json` to scan the workspace, group findings by severity, fix each finding cleanly, and re-run `secfoo run --json` to confirm zero open issues.
"""
6 changes: 6 additions & 0 deletions extensions/gemini-secfoo/gemini-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "secfoo",
"version": "0.1.0",
"description": "secfoo security hooks, commands, and skills for Gemini CLI",
"contextFileName": "GEMINI.md"
}
32 changes: 32 additions & 0 deletions extensions/gemini-secfoo/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"hooks": {
"BeforeTool": [
{
"matcher": "run_shell_command",
"sequential": true,
"hooks": [
{
"name": "secfoo-commit-guard",
"type": "command",
"command": "secfoo hook commit-guard --host gemini",
"timeout": 60000
}
]
}
],
"AfterTool": [
{
"matcher": "write_file|replace",
"sequential": false,
"hooks": [
{
"name": "secfoo-secret-on-edit",
"type": "command",
"command": "secfoo hook secret-on-edit --host gemini",
"timeout": 60000
}
]
}
]
}
}
10 changes: 10 additions & 0 deletions extensions/gemini-secfoo/skills/secfoo-fix-findings/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: secfoo-fix-findings
description: Triage and remediate open secfoo security findings in the repository.
---

# Fix secfoo Findings

1. Run `secfoo run --json` to inspect open findings.
2. Remediate critical and high findings first, then medium and low.
3. Re-run `secfoo run --json` and project tests to confirm the fix.
1 change: 1 addition & 0 deletions src/secfoo/automations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading