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
17 changes: 17 additions & 0 deletions docs/DEVIN_AUTOMATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Devin Local & Devin Automations (#248)

secfoo supports **Devin Local** (CLI and Desktop) hooks and **Devin Automations** (cloud).

## Devin Local Hooks

- **Project config:** `.devin/hooks.v1.json` (root object maps event names directly to hook lists, with explicit `timeout` set on every hook).
- **User config:** `~/.config/devin/config.json` (`%APPDATA%\devin\config.json` on Windows).
- **Claude deduplication:** Devin Local also reads `.claude/settings.json` and `.claude/settings.local.json`. `secfoo automations enable --host devin` skips writing `.devin/hooks.v1.json` (`covered_by_claude`) when Claude hooks already cover the recipe to prevent double-firing.
- **Restricted Mode:** Hooks do **not** run when Devin is in Restricted Mode.
- **Legacy Windsurf Cascade:** Older event names (`pre_run_command`, `post_write_code`, etc.) are supported in `hosts/devin.py` for backwards compatibility with older desktop builds; new installations should use `.devin/hooks.v1.json`.
- **Recursion guard:** `devin -p … --permission-mode auto` nested reviews are guarded via `SECFOO_HOOK_ACTIVE`.

## Devin Cloud Automations

- See `examples/automations/devin-scheduled-baseline.md` and `examples/automations/devin-pr-review.md`.
- Note that `POST .../schedules` is legacy (returns 403 for migrated orgs); configure Automations via the Devin UI, "Schedule Devin", or Terraform (`devin_automation`).
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
```
16 changes: 16 additions & 0 deletions examples/automations/devin-pr-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Devin Automation Template: GitHub PR Security Review

Trigger: **GitHub** (`pull_request` opened / synchronized).

## Preflight Script

```bash
pip install secfoo
secfoo cloud login --token "$SECFOO_API_KEY"
```

## Session Prompt

```text
Run diff-scoped `secfoo run --sast --secret-scanning --json` on the PR diff (`trigger.event = "pull_request"`), post findings as a concise PR review comment, and exit cleanly.
```
20 changes: 20 additions & 0 deletions examples/automations/devin-scheduled-baseline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Devin Automation Template: Scheduled Baseline

Trigger: **Schedule** (recurring, e.g. daily at 06:00 UTC).

## Preflight Script

Select `SECFOO_API_KEY` as a secret for the preflight environment:

```bash
pip install secfoo
secfoo cloud login --token "$SECFOO_API_KEY"
```

> Note: Selected secrets are injected into the preflight script environment, so `secfoo cloud login` persists the token to `~/.secfoo/cloud.toml` on the session VM.

## Session Prompt

```text
Run `secfoo run --json` to generate the repository security baseline, summarize any new critical/high findings, and remediate issues cleanly.
```
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