Skip to content

Commit afd5e53

Browse files
niharika3715harsha vardhanvsn411claude
authored
docs: added azure pipeline configuration and documentation (#200)
* added azure pipeline configuration * remove duplicate line * 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 <noreply@anthropic.com> --------- Co-authored-by: harsha vardhan <harshavardhan@harshas-MacBook-Air.local> Co-authored-by: aitechnology <40792067+vsn411@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8c8930e commit afd5e53

2 files changed

Lines changed: 123 additions & 1 deletion

File tree

‎docs/CI.md‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,65 @@ Lines and `--json` files are kept as step artifacts, downloadable from the
251251
`secfoo.sarif` as the hand-off file for other tools. Full file:
252252
[examples/ci/bitbucket-pipelines.yml](../examples/ci/bitbucket-pipelines.yml).
253253

254+
## Azure Pipelines
255+
256+
```yaml
257+
# azure-pipelines.yml
258+
trigger:
259+
branches: { include: [main] }
260+
pr:
261+
branches: { include: [main] }
262+
263+
jobs:
264+
- job: secfoo
265+
pool:
266+
vmImage: ubuntu-latest
267+
steps:
268+
- checkout: self
269+
fetchDepth: 50
270+
- task: UsePythonVersion@0
271+
inputs:
272+
versionSpec: "3.12"
273+
- bash: pip install --quiet secfoo
274+
- bash: |
275+
code=0
276+
mkdir -p secfoo-reports
277+
secfoo run --agent api --target . --depth quick --json --rescan \
278+
--project-name "$(Build.Repository.Name)" \
279+
--skill sast --skill secret-scanning \
280+
--fail-on high --max-cost 2.00 > secfoo-reports/secfoo-result.json || code=$?
281+
secfoo findings export --format sarif -o secfoo-reports/secfoo.sarif
282+
secfoo findings export -o secfoo-reports/secfoo-findings.jsonl
283+
exit $code
284+
env:
285+
OPENAI_API_KEY: $(OPENAI_API_KEY)
286+
- task: PublishPipelineArtifact@1
287+
condition: always()
288+
inputs:
289+
targetPath: secfoo-reports
290+
artifact: secfoo-reports
291+
```
292+
293+
Add `OPENAI_API_KEY` (or `ANTHROPIC_API_KEY` / `GEMINI_API_KEY`) as a secret
294+
pipeline variable under **Pipelines → your pipeline → Edit → Variables → New
295+
variable**, with **Keep this value secret** ticked. Azure Pipelines does not
296+
pass secret variables to scripts on its own, so the step maps it under `env:`.
297+
The job uses a Microsoft-hosted `ubuntu-latest` agent: git is preinstalled,
298+
and `pip install` works without root (a container job runs steps as a
299+
non-root user, so `apt-get` and a system-wide `pip install` fail there).
300+
301+
The `pr:` trigger works for GitHub and Bitbucket Cloud repositories. For Azure
302+
Repos Git, pull-request runs come from a branch policy instead: **Repos →
303+
Branches → main → Branch policies → Build validation**.
304+
305+
The script records `secfoo run`'s exit code so both exports always run before
306+
the step fails: `0` is clean, `1` means a skill run failed or timed out, `2`
307+
means `--fail-on` tripped, and `3` means `--max-cost` tripped. The reports are
308+
published as the `secfoo-reports` pipeline artifact even when the step fails.
309+
Azure has no built-in SARIF viewer, so treat `secfoo.sarif` as the hand-off
310+
file for other tools. Full file:
311+
[examples/ci/azure-pipelines.yml](../examples/ci/azure-pipelines.yml).
312+
254313
## Jenkins
255314

256315
A declarative pipeline that runs in the published image. It needs the
@@ -325,7 +384,7 @@ choice; build `FROM ghcr.io/secfoo-com/secfoo` and `npm install -g
325384
`/root/.secfoo`; mount it to keep findings between jobs. See the
326385
[Distribution](REFERENCE.md#distribution) notes.
327386

328-
## Anything else (Buildkite, CircleCI, Azure Pipelines, ...)
387+
## Anything else (Buildkite, CircleCI, ...)
329388

330389
```bash
331390
pip install secfoo # or: uvx secfoo run ...

‎examples/ci/azure-pipelines.yml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Add to your repository as azure-pipelines.yml (or merge the job into an
2+
# existing pipeline).
3+
#
4+
# AI security review as an Azure Pipelines job, on pull requests and on pushes
5+
# to main. Add OPENAI_API_KEY (or ANTHROPIC_API_KEY / GEMINI_API_KEY) as a
6+
# secret pipeline variable: Pipelines -> your pipeline -> Edit -> Variables ->
7+
# New variable, with "Keep this value secret" ticked. Azure does not pass
8+
# secret variables to scripts on its own, so the step maps it under env:.
9+
#
10+
# The pr: trigger below works for GitHub and Bitbucket Cloud repositories.
11+
# For Azure Repos Git, PR runs come from a branch policy instead (Repos ->
12+
# Branches -> main -> Branch policies -> Build validation).
13+
trigger:
14+
branches:
15+
include:
16+
- main
17+
18+
pr:
19+
branches:
20+
include:
21+
- main
22+
23+
jobs:
24+
- job: secfoo
25+
displayName: secfoo security review
26+
# A Microsoft-hosted agent: git is preinstalled, and pip can install
27+
# without root (a container job runs steps as a non-root user).
28+
pool:
29+
vmImage: ubuntu-latest
30+
31+
steps:
32+
- checkout: self
33+
fetchDepth: 50
34+
35+
- task: UsePythonVersion@0
36+
inputs:
37+
versionSpec: "3.12"
38+
displayName: Use Python 3.12
39+
40+
- bash: pip install --quiet secfoo
41+
displayName: Install secfoo
42+
43+
- bash: |
44+
# Exit codes: 0 clean, 1 a run failed, 2 the --fail-on gate tripped, 3 the --max-cost gate tripped.
45+
code=0
46+
mkdir -p secfoo-reports
47+
secfoo run --agent api --target . --depth quick --json --rescan \
48+
--project-name "$(Build.Repository.Name)" \
49+
--skill sast --skill secret-scanning \
50+
--fail-on high --max-cost 2.00 > secfoo-reports/secfoo-result.json || code=$?
51+
secfoo findings export --format sarif -o secfoo-reports/secfoo.sarif
52+
secfoo findings export -o secfoo-reports/secfoo-findings.jsonl
53+
exit $code
54+
displayName: Run secfoo
55+
env:
56+
OPENAI_API_KEY: $(OPENAI_API_KEY)
57+
58+
- task: PublishPipelineArtifact@1
59+
displayName: Publish secfoo reports
60+
condition: always()
61+
inputs:
62+
targetPath: secfoo-reports
63+
artifact: secfoo-reports

0 commit comments

Comments
 (0)