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 (`$secfoo-fix-findings` / `/skills`) and Antigravity.
---

# 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.
36 changes: 36 additions & 0 deletions docs/CODEX_AUTOMATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# OpenAI Codex Automations (#246)

secfoo integrates with OpenAI Codex CLI, Codex desktop app, and Codex web automations.

## Hook Configuration

`secfoo automations enable <recipe> --host codex` writes `.codex/hooks.json` (project scope) or `$CODEX_HOME/hooks.json` (user scope). `hooks.json` is preferred over `[hooks]` in `config.toml` so only one format is active per layer.

### Trust Requirement

Non-managed project hooks in `.codex/hooks.json` must be **reviewed and trusted** in Codex before they execute. Never pass `--dangerously-bypass-hook-trust`.

Run diagnostics with:

```bash
secfoo automations doctor --tool codex
```

## Supported Events & Recipes

| Recipe | Codex Hook Event | Notes |
|---|---|---|
| `commit-guard` | `PreToolUse` (`^Bash$`) | Returns `permissionDecision: "deny"` with reason |
| `turn-review` | `Stop` | Returns `decision: "block"` when findings remain (loop-guarded via `stop_hook_active`) |
| `dependency-watch` | `PostToolUse` (`async: true`) | Runs asynchronously and surfaces findings on `Stop` |
| `session-brief` | `SessionStart` | Injects `additionalContext` |
| `session-flush` | `SessionEnd` | Synchronous flush capped at 3 s maximum |

## Sandbox & Outbox

Under Codex `workspace-write` sandboxes, outbound network calls from hooks may be blocked. secfoo automatically buffers reports to the local outbox so they are flushed when network access is available. `codex exec` recursion is prevented by secfoo's hook recursion guard.

## Shared Skills & Scheduled Tasks

- **Shared skills:** `.agents/skills/secfoo-fix-findings/SKILL.md` is read by both OpenAI Codex (`$secfoo-fix-findings` / `/skills`) and Antigravity without duplication.
- **Scheduled tasks:** See `examples/automations/codex-scheduled-baseline.md` for the ChatGPT/Codex scheduled-task prompt template.
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
```
10 changes: 10 additions & 0 deletions examples/automations/codex-scheduled-baseline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Codex Scheduled Task: secfoo Baseline Review

Use this prompt template in the ChatGPT/Codex app or web UI for a scheduled `scheduled-baseline` automation (Codex scheduled tasks are configured in the app/web UI rather than the CLI):

```text
Run the `$secfoo-fix-findings` skill against the repository:
1. Execute `secfoo run --json` (delegate mode) or review current findings with secfoo.
2. Summarize any new critical or high findings introduced since the last baseline.
3. If the task runs in a network-restricted sandbox (`workspace-write`), leave the outbox artifacts in `.secfoo/outbox/` so `secfoo` flushes them on the next connected run.
```
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