From 3dbe8d9d6a7c2b2a91f2708c5c101bd6b06c7173 Mon Sep 17 00:00:00 2001 From: harsha vardhan Date: Thu, 26 Nov 2026 20:36:10 +0530 Subject: [PATCH 1/3] added azure pipeline configuration --- docs/CI.md | 28 +++++++++++++++ examples/ci/azure-pipelines.yml | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 examples/ci/azure-pipelines.yml diff --git a/docs/CI.md b/docs/CI.md index aeee468..9ce62de 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -199,6 +199,34 @@ not SARIF, so treat this as the hand-off file for other tools. Full job, including merge-request rules and a container-image variant: [examples/ci/gitlab-ci.yml](../examples/ci/gitlab-ci.yml). +## Azure Pipelines + +## Azure Pipelines + +Add `OPENAI_API_KEY` as a secret pipeline variable under +Pipelines → your pipeline → Edit → Variables → New variable. +Enable "Keep this value secret". + +Azure Pipelines does not automatically expose secret variables to +scripts. Map the variable into the environment explicitly: + +```yaml +- bash: | + secfoo run --agent api --target . --depth quick --json --rescan \ + --skill sast --skill secret-scanning \ + --fail-on high --max-cost 2.00 + env: + OPENAI_API_KEY: $(OPENAI_API_KEY) +``` + +Exit codes: `0` means the scan completed cleanly, `1` means the run +failed, `2` means the `--fail-on` severity gate was tripped, and +`3` means the `--max-cost` budget gate was tripped. + +The SARIF and JSONL reports are published as pipeline artifacts. +Full pipeline configuration: [examples/ci/azure-pipelines.yml](../examples/ci/azure-pipelines.yml). + + ## Jenkins A declarative pipeline that runs in the published image. It needs the diff --git a/examples/ci/azure-pipelines.yml b/examples/ci/azure-pipelines.yml new file mode 100644 index 0000000..25ca687 --- /dev/null +++ b/examples/ci/azure-pipelines.yml @@ -0,0 +1,64 @@ + +# Azure Pipelines: Secfoo AI security review + +trigger: + branches: + include: + - main + +pr: + branches: + include: + - main + +jobs: + - job: Secfoo + displayName: Secfoo Security Scan + container: python:3.12-slim + + steps: + - checkout: self + fetchDepth: 50 + + - bash: | + mkdir -p secfoo-artifacts + displayName: Prepare artifacts directory + + - bash: | + apt-get update -qq + apt-get install -y -qq --no-install-recommends git + pip install --quiet secfoo + displayName: Install Secfoo + + - bash: | + # Exit codes: + # 0 = clean + # 1 = run failed + # 2 = --fail-on gate tripped + # 3 = --max-cost gate tripped + + code=0 + + secfoo run --agent api --target . --depth quick --json --rescan \ + --project-name "$(Build.Repository.Name)" \ + --skill sast --skill secret-scanning \ + --fail-on high --max-cost 2.00 \ + > secfoo-result.json || code=$? + + secfoo findings export --format sarif -o secfoo.sarif || code=$? + secfoo findings export -o secfoo-findings.jsonl || code=$? + + cp secfoo-result.json secfoo.sarif secfoo-findings.jsonl secfoo-artifacts/ || code=$? + + exit "$code" + displayName: Run Secfoo Security Scan + env: + OPENAI_API_KEY: $(OPENAI_API_KEY) + + - task: PublishPipelineArtifact@1 + displayName: Publish Secfoo Reports + condition: always() + inputs: + targetPath: $(System.DefaultWorkingDirectory)/secfoo-artifacts + artifact: secfoo-reports + publishLocation: pipeline From 8480d5533d75e4c72d991956a7157dc6f38573b5 Mon Sep 17 00:00:00 2001 From: harsha vardhan Date: Thu, 26 Nov 2026 20:47:35 +0530 Subject: [PATCH 2/3] remove duplicate line --- docs/CI.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index 9ce62de..298f4d0 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -201,8 +201,6 @@ including merge-request rules and a container-image variant: ## Azure Pipelines -## Azure Pipelines - Add `OPENAI_API_KEY` as a secret pipeline variable under Pipelines → your pipeline → Edit → Variables → New variable. Enable "Keep this value secret". From 69b64a0f4f40a0e43cf29eebfc4e9193eed21d0a Mon Sep 17 00:00:00 2001 From: aitechnology <40792067+vsn411@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:43:20 +0000 Subject: [PATCH 3/3] docs(ci): run the Azure example on a hosted agent; note Azure Repos PR policy - A container job runs steps as a non-root user, so apt-get and a system-wide pip install in python:3.12-slim would fail. Use the ubuntu-latest hosted agent with UsePythonVersion@0 (git is preinstalled). - Keep secfoo run's exit code: the exports no longer overwrite it. - Write the reports straight into the published folder. - The pr: trigger only applies to GitHub and Bitbucket Cloud repos; Azure Repos Git needs a build-validation branch policy. - docs/CI.md: show the job, then setup, exit codes and artifacts, in the same shape as the Bitbucket and GitLab sections. Co-Authored-By: Claude Opus 5.5 --- docs/CI.md | 73 ++++++++++++++++++++++++--------- examples/ci/azure-pipelines.yml | 67 +++++++++++++++--------------- 2 files changed, 86 insertions(+), 54 deletions(-) diff --git a/docs/CI.md b/docs/CI.md index 298f4d0..6957f75 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -201,29 +201,62 @@ including merge-request rules and a container-image variant: ## Azure Pipelines -Add `OPENAI_API_KEY` as a secret pipeline variable under -Pipelines → your pipeline → Edit → Variables → New variable. -Enable "Keep this value secret". - -Azure Pipelines does not automatically expose secret variables to -scripts. Map the variable into the environment explicitly: - ```yaml -- bash: | - secfoo run --agent api --target . --depth quick --json --rescan \ - --skill sast --skill secret-scanning \ - --fail-on high --max-cost 2.00 - env: - OPENAI_API_KEY: $(OPENAI_API_KEY) -``` - -Exit codes: `0` means the scan completed cleanly, `1` means the run -failed, `2` means the `--fail-on` severity gate was tripped, and -`3` means the `--max-cost` budget gate was tripped. +# azure-pipelines.yml +trigger: + branches: { include: [main] } +pr: + branches: { include: [main] } -The SARIF and JSONL reports are published as pipeline artifacts. -Full pipeline configuration: [examples/ci/azure-pipelines.yml](../examples/ci/azure-pipelines.yml). +jobs: + - job: secfoo + pool: + vmImage: ubuntu-latest + steps: + - checkout: self + fetchDepth: 50 + - task: UsePythonVersion@0 + inputs: + versionSpec: "3.12" + - bash: pip install --quiet secfoo + - bash: | + code=0 + mkdir -p secfoo-reports + secfoo run --agent api --target . --depth quick --json --rescan \ + --project-name "$(Build.Repository.Name)" \ + --skill sast --skill secret-scanning \ + --fail-on high --max-cost 2.00 > secfoo-reports/secfoo-result.json || code=$? + secfoo findings export --format sarif -o secfoo-reports/secfoo.sarif + secfoo findings export -o secfoo-reports/secfoo-findings.jsonl + exit $code + env: + OPENAI_API_KEY: $(OPENAI_API_KEY) + - task: PublishPipelineArtifact@1 + condition: always() + inputs: + targetPath: secfoo-reports + artifact: secfoo-reports +``` +Add `OPENAI_API_KEY` (or `ANTHROPIC_API_KEY` / `GEMINI_API_KEY`) as a secret +pipeline variable under **Pipelines → your pipeline → Edit → Variables → New +variable**, with **Keep this value secret** ticked. Azure Pipelines does not +pass secret variables to scripts on its own, so the step maps it under `env:`. +The job uses a Microsoft-hosted `ubuntu-latest` agent: git is preinstalled, +and `pip install` works without root (a container job runs steps as a +non-root user, so `apt-get` and a system-wide `pip install` fail there). + +The `pr:` trigger works for GitHub and Bitbucket Cloud repositories. For Azure +Repos Git, pull-request runs come from a branch policy instead: **Repos → +Branches → main → Branch policies → Build validation**. + +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. The reports are +published as the `secfoo-reports` pipeline artifact even when the step fails. +Azure has no built-in SARIF viewer, so treat `secfoo.sarif` as the hand-off +file for other tools. Full file: +[examples/ci/azure-pipelines.yml](../examples/ci/azure-pipelines.yml). ## Jenkins diff --git a/examples/ci/azure-pipelines.yml b/examples/ci/azure-pipelines.yml index 25ca687..348650c 100644 --- a/examples/ci/azure-pipelines.yml +++ b/examples/ci/azure-pipelines.yml @@ -1,6 +1,15 @@ - -# Azure Pipelines: Secfoo AI security review - +# Add to your repository as azure-pipelines.yml (or merge the job into an +# existing pipeline). +# +# AI security review as an Azure Pipelines job, on pull requests and on pushes +# to main. Add OPENAI_API_KEY (or ANTHROPIC_API_KEY / GEMINI_API_KEY) as a +# secret pipeline variable: Pipelines -> your pipeline -> Edit -> Variables -> +# New variable, with "Keep this value secret" ticked. Azure does not pass +# secret variables to scripts on its own, so the step maps it under env:. +# +# The pr: trigger below works for GitHub and Bitbucket Cloud repositories. +# For Azure Repos Git, PR runs come from a branch policy instead (Repos -> +# Branches -> main -> Branch policies -> Build validation). trigger: branches: include: @@ -12,53 +21,43 @@ pr: - main jobs: - - job: Secfoo - displayName: Secfoo Security Scan - container: python:3.12-slim + - job: secfoo + displayName: secfoo security review + # A Microsoft-hosted agent: git is preinstalled, and pip can install + # without root (a container job runs steps as a non-root user). + pool: + vmImage: ubuntu-latest steps: - checkout: self fetchDepth: 50 - - bash: | - mkdir -p secfoo-artifacts - displayName: Prepare artifacts directory + - task: UsePythonVersion@0 + inputs: + versionSpec: "3.12" + displayName: Use Python 3.12 - - bash: | - apt-get update -qq - apt-get install -y -qq --no-install-recommends git - pip install --quiet secfoo - displayName: Install Secfoo + - bash: pip install --quiet secfoo + displayName: Install secfoo - bash: | - # Exit codes: - # 0 = clean - # 1 = run failed - # 2 = --fail-on gate tripped - # 3 = --max-cost gate tripped - + # Exit codes: 0 clean, 1 a run failed, 2 the --fail-on gate tripped, 3 the --max-cost gate tripped. code=0 - + mkdir -p secfoo-reports secfoo run --agent api --target . --depth quick --json --rescan \ --project-name "$(Build.Repository.Name)" \ --skill sast --skill secret-scanning \ - --fail-on high --max-cost 2.00 \ - > secfoo-result.json || code=$? - - secfoo findings export --format sarif -o secfoo.sarif || code=$? - secfoo findings export -o secfoo-findings.jsonl || code=$? - - cp secfoo-result.json secfoo.sarif secfoo-findings.jsonl secfoo-artifacts/ || code=$? - - exit "$code" - displayName: Run Secfoo Security Scan + --fail-on high --max-cost 2.00 > secfoo-reports/secfoo-result.json || code=$? + secfoo findings export --format sarif -o secfoo-reports/secfoo.sarif + secfoo findings export -o secfoo-reports/secfoo-findings.jsonl + exit $code + displayName: Run secfoo env: OPENAI_API_KEY: $(OPENAI_API_KEY) - task: PublishPipelineArtifact@1 - displayName: Publish Secfoo Reports + displayName: Publish secfoo reports condition: always() inputs: - targetPath: $(System.DefaultWorkingDirectory)/secfoo-artifacts + targetPath: secfoo-reports artifact: secfoo-reports - publishLocation: pipeline