From 269822ccb27aa57fbc80190367629312b8e78d7a Mon Sep 17 00:00:00 2001 From: Debjit Sarkar <225563802+deba310984@users.noreply.github.com> Date: Fri, 27 Nov 2026 11:47:12 +0530 Subject: [PATCH 1/2] docs: add CircleCI CI example and documentation --- docs/CI.md | 59 ++++++++++++++++++++++++++++++++- examples/ci/circleci-config.yml | 48 +++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 examples/ci/circleci-config.yml diff --git a/docs/CI.md b/docs/CI.md index dd894b7..f65f2cb 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -211,6 +211,63 @@ dependency files), so they stay in the SARIF and JSON Lines exports. Full job, including merge-request rules and a container-image variant: [examples/ci/gitlab-ci.yml](../examples/ci/gitlab-ci.yml). +## CircleCI + +```yaml +# .circleci/config.yml +version: 2.1 + +jobs: + secfoo: + docker: + - image: cimg/python:3.12 + steps: + - checkout + - run: pip install --quiet secfoo + - run: + name: secfoo security review + command: | + code=0 + secfoo run --agent api --target . --depth quick --json --rescan \ + --project-name "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" \ + --skill sast --skill secret-scanning \ + --fail-on high --max-cost 2.00 > secfoo-result.json || code=$? + secfoo findings export --format sarif -o secfoo.sarif + secfoo findings export -o secfoo-findings.jsonl + exit $code + - store_artifacts: + path: secfoo-result.json + when: always + - store_artifacts: + path: secfoo.sarif + when: always + - store_artifacts: + path: secfoo-findings.jsonl + when: always + +workflows: + secfoo: + jobs: + - secfoo: + context: secfoo +``` + +Add `OPENAI_API_KEY` (or `ANTHROPIC_API_KEY` / `GEMINI_API_KEY`) either as a +project environment variable (**Project Settings → Environment Variables**) or +in a context (**Organization Settings → Contexts**) named `secfoo`, which the +workflow above references; drop the `context:` line if you use a project +variable. CircleCI masks the value in job output. The `cimg/python` image runs +as a non-root user and already has git, so no `apt-get` is needed. + +The script records `secfoo run`'s exit code so both exports always run before +the step fails: `0` is clean, `1` means a skill run failed or timed out, `2` +means `--fail-on` tripped, and `3` means `--max-cost` tripped. A failed step +skips the steps after it, so each `store_artifacts` carries `when: always`; +the files appear on the job's **Artifacts** tab even when a gate fails. +CircleCI has no SARIF viewer, so treat `secfoo.sarif` as the hand-off file for +other tools. Full file: +[examples/ci/circleci-config.yml](../examples/ci/circleci-config.yml). + ## Bitbucket Pipelines ```yaml @@ -396,7 +453,7 @@ choice; build `FROM ghcr.io/secfoo-com/secfoo` and `npm install -g `/root/.secfoo`; mount it to keep findings between jobs. See the [Distribution](REFERENCE.md#distribution) notes. -## Anything else (Buildkite, CircleCI, ...) +## Anything else (Buildkite, ...) ```bash pip install secfoo # or: uvx secfoo run ... diff --git a/examples/ci/circleci-config.yml b/examples/ci/circleci-config.yml new file mode 100644 index 0000000..3dd1bc4 --- /dev/null +++ b/examples/ci/circleci-config.yml @@ -0,0 +1,48 @@ +# Add to your repository as .circleci/config.yml (or merge the job into an +# existing config). +# +# AI security review as a CircleCI job, on every push. Set OPENAI_API_KEY (or +# ANTHROPIC_API_KEY / GEMINI_API_KEY) as an environment variable under +# Project Settings -> Environment Variables, or in a context (Organization +# Settings -> Contexts) that the workflow references, as below. +# +# The SARIF and JSON Lines files are kept as artifacts for other tools. +version: 2.1 + +jobs: + secfoo: + docker: + - image: cimg/python:3.12 # non-root, git preinstalled + steps: + - checkout + - run: + name: Install secfoo + command: pip install --quiet secfoo + - run: + name: secfoo security review + # Exit codes: 0 clean, 1 a run failed, 2 the --fail-on gate tripped, 3 the --max-cost gate tripped. + command: | + code=0 + secfoo run --agent api --target . --depth quick --json --rescan \ + --project-name "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" \ + --skill sast --skill secret-scanning \ + --fail-on high --max-cost 2.00 > secfoo-result.json || code=$? + secfoo findings export --format sarif -o secfoo.sarif + secfoo findings export -o secfoo-findings.jsonl + exit $code + # A failed step skips later steps unless they say `when: always`. + - store_artifacts: + path: secfoo-result.json + when: always + - store_artifacts: + path: secfoo.sarif + when: always + - store_artifacts: + path: secfoo-findings.jsonl + when: always + +workflows: + secfoo: + jobs: + - secfoo: + context: secfoo # remove if the key is a project environment variable From a84b8efc5a89cf3849dd9e08b7484343ac55683e Mon Sep 17 00:00:00 2001 From: aitechnology <40792067+vsn411@users.noreply.github.com> Date: Fri, 27 Nov 2026 14:25:30 +0000 Subject: [PATCH 2/2] docs(ci): drop when: always from CircleCI store_artifacts store_artifacts documents only path and destination, and it already runs after a failed step. Co-Authored-By: Claude Opus 5.5 --- docs/CI.md | 9 +++------ examples/ci/circleci-config.yml | 5 +---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index f65f2cb..528fef0 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -237,13 +237,10 @@ jobs: exit $code - store_artifacts: path: secfoo-result.json - when: always - store_artifacts: path: secfoo.sarif - when: always - store_artifacts: path: secfoo-findings.jsonl - when: always workflows: secfoo: @@ -261,9 +258,9 @@ as a non-root user and already has git, so no `apt-get` is needed. The script records `secfoo run`'s exit code so both exports always run before the step fails: `0` is clean, `1` means a skill run failed or timed out, `2` -means `--fail-on` tripped, and `3` means `--max-cost` tripped. A failed step -skips the steps after it, so each `store_artifacts` carries `when: always`; -the files appear on the job's **Artifacts** tab even when a gate fails. +means `--fail-on` tripped, and `3` means `--max-cost` tripped. +`store_artifacts` runs even when an earlier step failed, so the files appear +on the job's **Artifacts** tab when a gate trips too. CircleCI has no SARIF viewer, so treat `secfoo.sarif` as the hand-off file for other tools. Full file: [examples/ci/circleci-config.yml](../examples/ci/circleci-config.yml). diff --git a/examples/ci/circleci-config.yml b/examples/ci/circleci-config.yml index 3dd1bc4..ad7c37b 100644 --- a/examples/ci/circleci-config.yml +++ b/examples/ci/circleci-config.yml @@ -30,16 +30,13 @@ jobs: secfoo findings export --format sarif -o secfoo.sarif secfoo findings export -o secfoo-findings.jsonl exit $code - # A failed step skips later steps unless they say `when: always`. + # store_artifacts runs even when the review step failed. - store_artifacts: path: secfoo-result.json - when: always - store_artifacts: path: secfoo.sarif - when: always - store_artifacts: path: secfoo-findings.jsonl - when: always workflows: secfoo: