Oma deepsec

From gracefullight/stock-checker · View interactive version

Oma deepsec is an AI agent skill from the GitHub repository gracefullight/stock-checker. Set up and run Deepsec vulnerability scans, triage, and CI gates. Use for Deepsec work or an explicitly requested agent-powered vulnerability scan.

How to use this skill

Skill file

Deepsec: Agent-Powered Vulnerability Scanner Driver

Scheduling

Goal

Operate Vercel's deepsec security scanner inside a target repository safely and cost-consciously: bootstrap the .deepsec/ workspace, write a tight INFO.md, run the right scan/process/triage/revalidate/export sequence, gate PRs in CI via process --diff, and grow project-specific matchers, surfacing real, revalidated findings without runaway spend.

Intent signature

When to use

When NOT to use

Expected inputs

Expected outputs

Dependencies

Control-flow features

Structural Flow

Entry

  1. Confirm whether .deepsec/ already exists; if yes, treat the run as incremental, never re-init.
  2. Resolve intent from the user prompt; if ambiguous (e.g. "scan this repo"), default to setup then scan (calibration mode).
  3. Estimate scale: count source files (rough rg --files | wc -l excluding node_modules, .git, dist) to forecast cost before any AI pass.
  4. Resolve the selected credential mode and backend. Check its required environment configuration or an existing claude / codex subscription login, without echoing secrets. A valid subscription session does not require an API-key environment variable. Resolve only missing configuration before AI calls.
  5. Resolve backend, scope, and spend from existing instructions and configuration under ../_shared/core/execution-policy.md. Before paid or custom-scope work, record the actual approved, limited, or declined action using resources/decision-records.md. A configured backend does not authorize additional spend; ask only for a material missing choice or new authorization.

Transitions

Failure and recovery

| Failure | Recovery |

|---------|----------|

| Missing AI credentials for --agent claude / codex | Check the selected mode per resources/config.md: environment configuration for key/OIDC/direct modes, or CLI login for subscription mode. Do not require .env.local credentials for a valid subscription session. |

| 401 Unauthorized from gateway | OIDC: re-run vercel env pull (12 h expiry). API key: regenerate. Confirm .env.local is in the cwd deepsec runs from. |

| Stopped: AI Gateway credits exhausted | Top up via the printed URL; re-run the same command, files already done are skipped. |

| Stopped: Claude Pro/Max subscription exhausted | Switch to AI Gateway; subscriptions don't carry full scans. |

| Persistent refusal on a single file (>5% of batches) | Add the path to data/<id>/config.json:ignorePaths, or run that file alone with --batch-size 1. |

| FP rate too high on HIGH+ | Run revalidate --min-severity HIGH; tighten INFO.md's threat model and FP notes; bias matchers to precise. |

| noisy matcher wedges scanner on a 100k-file repo | Tighten filePatterns to language- or directory-anchored globs. |

| Sandbox auth fails | OIDC: re-run vercel env pull. Access-token mode: verify VERCEL_TOKEN + VERCEL_TEAM_ID + VERCEL_PROJECT_ID. |

| Full pass exceeds existing scope or spend authorization | Report the calibrated estimate and preserve completed free/limited work. Resolve only the missing authorization; record the actual approved, limited, or declined pass before executing it. |

Exit

Logical Operations

Tools and instruments

Canonical workflow path

  1. Bootstrap (one time per repo):

```bash

cd <target-repo>

bunx deepsec init

cd .deepsec

bun install

# Edit .env.local: set AI_GATEWAY_API_KEY=vck_… (or VERCEL_OIDC_TOKEN via vercel env pull)

```

Then prompt the coding agent (this skill) to read

.deepsec/node_modules/deepsec/SKILL.md and .deepsec/data/<id>/SETUP.md,

skim README / AGENTS.md / CLAUDE.md and a handful of representative

files, and replace each section of data/<id>/INFO.md (50-100 lines,

3-5 examples per section, no line numbers, no generic CWE rehash).

  1. Calibrate before any full pass. First record the selected authorized calibration scope using resources/decision-records.md; --limit bounds files, not dollar spend. The deepsec docs (getting-started.md, vercel-setup.md, faq.md) recommend --limit 50 --concurrency 5 as the calibration starting point.

```bash

bunx deepsec scan

bunx deepsec status

bunx deepsec process --limit 50 --concurrency 5

```

Read the run cost and extrapolate to the full repo using resources/scanning.md. Reuse existing authorization covering the backend, scope, and estimated spend. Record the actual scope decision before calibration and again before an expanded pass; resolve only missing authorization. If the user names different --limit / --concurrency values, use theirs.

  1. Full investigation, triage, revalidate, export:

```bash

bunx deepsec process --concurrency 5

bunx deepsec triage --severity HIGH

bunx deepsec revalidate --min-severity HIGH

```

Record and verify every triaged finding's actual verdict using resources/decision-records.md before filtering or suppression, including findings that will not be surfaced. Then export:

```bash

bunx deepsec export --format md-dir --out ./findings

bunx deepsec metrics

```

  1. PR mode (CI gate, scoped to changed files, exit code = 0/1):

```bash

bunx deepsec process \

--diff origin/${BASE_REF} \

--comment-out comment.md

```

Wire the two-job CI pattern from resources/pr-review.md. Never grant pull-requests: write to the job that runs PR-controlled code.

  1. Custom matchers (close entry-point gaps surfaced in step 3):
  1. Resume after any quota stop, network blip, or Ctrl-C: re-run the same command. State is on disk under .deepsec/data/<id>/.

Resource scope

| Scope | Resource target |

|-------|-----------------|

| CODEBASE | Target repo source files, framework configs, route directories, README / AGENTS.md / CLAUDE.md. |

| LOCAL_FS | .deepsec/deepsec.config.ts, .deepsec/.env.local, .deepsec/matchers/, .deepsec/data/<id>/{project.json,INFO.md,config.json,files/,runs/,reports/}, generated findings/, comment.md, CI workflow files. |

| PROCESS | bunx deepsec scan|process|triage|revalidate|export|metrics|status|sandbox, bun install, optional vercel link / vercel env pull. |

| NETWORK | Anthropic / OpenAI via Vercel AI Gateway (default) or direct provider endpoints; optional Vercel Sandbox microVM control plane. |

| CREDENTIALS | AI_GATEWAY_API_KEY, VERCEL_OIDC_TOKEN, ANTHROPIC_AUTH_TOKEN, OPENAI_API_KEY, VERCEL_TOKEN / VERCEL_TEAM_ID / VERCEL_PROJECT_ID, claude / codex subscription tokens. Consume read-only; never echo secrets back to the user or commit them. |

| MEMORY | User-stated budget cap, severity floor, and stop conditions for the current session. |

Preconditions

Effects and side effects

<!-- oma-docs:ignore-start -->

<!-- oma-docs:ignore-end -->

<!-- oma-docs:ignore-start -->

<!-- oma-docs:ignore-end -->

Guardrails

  1. Never launch an unbounded process on a repo whose size you have not measured. Always run a calibration pass first when file count is unknown or > 500 (deepsec docs recommend --limit 50 --concurrency 5; defer to a user-named value if given).
  2. State cost and stopping condition before any AI pass. Use the published bands (100 files ≈ $25-60, 500 ≈ $130-300, 2,000 ≈ $500-1,200; ×2-3 swing).
  3. Resume, do not reset. After any network / quota / Ctrl-C interruption, re-run the same command. Never delete data/<id>/ to "start clean" without explicit user instruction.
  4. INFO.md stays short and project-specific. 50-100 lines, 3-5 examples per section. Name primitives but no line numbers. Skip generic CWE categories; built-in matchers cover those.
  5. For PR/CI gates, keep PR-controlled code in a no-write job. Never grant pull-requests: write to a job that executes PR-controlled pnpm install / config-loading. Use the two-job pattern in resources/pr-review.md.
  6. Pin actions to full SHAs in production CI; major-version tags are for examples only.
  7. Never silently drop refusals. If the agent reports refused: true, log it, retry with the other backend, or add the file to ignorePaths only when reproducible.
  8. Bias matchers toward precise when the bug shape is exact. Reserve noisy for entry-point coverage and tight globs.
  9. Never echo or commit credentials (vck_…, sk-ant-…, sk-…, OIDC tokens). Treat .env.local as secret. Treat data/ as gitignored by default.
  10. Treat deepsec like an agent with shell access. Recommend sandbox for prompt-injection-prone repos (vendored code, untrusted deps).
  11. Findings need verdicts. For any HIGH+ surfaced to the user, prefer revalidate-tagged verdicts (true-positive / false-positive / fixed / uncertain) over raw process output.
  12. Do not invent CLI flags, and trust the CLI over these notes. Anything beyond resources/scanning.md's flag list must be checked against --help first. Likewise, when the CLI's printed model names, defaults, or per-batch costs disagree with the values written in this skill, the CLI is right — upstream moves faster than these resources.
  13. Reuse existing backend, scope, and spend decisions. Record consequential execution choices and per-finding verdicts through resources/decision-records.md; do not add another confirmation when existing authorization covers the action.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.