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
19 changes: 19 additions & 0 deletions docs/COPILOT_AUTOMATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# GitHub Copilot Automations (CLI, VS Code, Cloud Agent)

One hook system works across Copilot CLI, VS Code agent mode, and the Copilot cloud agent:

| Recipe | Copilot Event | Behavior |
|---|---|---|
| `commit-guard` | `preToolUse` | Returns `permissionDecision: "deny"` when findings exceed threshold (`timeoutSec` set above recipe budget because 30s default fails open). |
| `secret-on-edit` | `postToolUse` | Non-blocking secret scan; returns `additionalContext` when findings are ready. |
| `pr-security-review` | `agentStop` | Returns `decision: "block"` with findings, loop-guarded. |

## Setup

```bash
secfoo automations enable commit-guard --host copilot
```

- Writes `.github/hooks/secfoo.json` (project) or `~/.copilot/hooks/secfoo.json` (user) using `exec` + `args` (no shell).
- **Claude config dedup:** Copilot also reads `.claude/settings.json`; if a recipe is already enabled there at project scope, `secfoo automations enable --host copilot` skips writing a duplicate.
- **Cloud agent:** Copy [examples/ci/copilot-setup-steps.yml](../examples/ci/copilot-setup-steps.yml) to `.github/workflows/copilot-setup-steps.yml`. Because the Copilot cloud agent firewall only allows GitHub/Copilot hosts by default, allowlist your portal host or rely on the [secfoo GitHub Action](../action.yml) on the resulting PR.
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
```
17 changes: 17 additions & 0 deletions examples/ci/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copy to .github/workflows/copilot-setup-steps.yml to pre-install secfoo
# for GitHub Copilot cloud agent runs (#245).
name: Copilot Setup Steps

on:
workflow_dispatch:

jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install secfoo
run: pip install --quiet secfoo
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