Skip to content

docs: add Azure Pipelines CI example and documentation - #201

Closed
Labu1 wants to merge 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-173
Closed

Labu1 wants to merge 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-173

Conversation

@Labu1

@Labu1 Labu1 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Closes #173

What does this change, and why?

docs/CI.md had copy-paste setups for GitHub Actions, GitLab, Jenkins and pre-commit, but Azure Pipelines users only got the generic "Anything else" snippet (part of #110).

  • examples/ci/azure-pipelines.yml (new), modelled on examples/ci/gitlab-ci.yml:
    • triggers on PRs and the default branch
    • installs secfoo with pip on Python 3.12
    • runs secfoo run --agent api ... --fail-on high --max-cost 2.00
    • exports secfoo.sarif and secfoo-findings.jsonl next to secfoo-result.json
    • publishes them with PublishPipelineArtifact@1 and condition: succeededOrFailed(), so the files are kept when a gate fails
    • saves secfoo run's exit code so both exports always run before the step fails
    • writes outputs to $(Build.ArtifactStagingDirectory), so they don't end up inside the scanned checkout
    • names the artifact CodeAnalysisLogs, which I understand is what the SARIF SAST Scans Tab extension reads (not checked)
  • docs/CI.md: new ## Azure Pipelines section after GitLab CI. It covers where to add the secret OPENAI_API_KEY pipeline variable, why it has to be mapped into the step's env: (Azure does not expose secret variables to scripts automatically), what exit codes 0–3 mean, and that the pr: trigger only works for GitHub/Bitbucket repos (Azure Repos needs a build-validation branch policy). Azure is removed from the "Anything else" heading.

Difference from the issue: the issue suggested a python:3.12-slim container. As far as I know, Azure container jobs don't run steps as root when the image has no sudo, so the apt-get install git / system pip install used in the GitLab job would likely fail. I haven't tested this. The example uses the hosted ubuntu-latest agent (git preinstalled) with UsePythonVersion@0 pinned to 3.12 instead. Happy to switch to a container job if you prefer.

Not done yet: I have not run this pipeline on an Azure DevOps organization, so I can't link a run or attach a screenshot of the uploaded secfoo.sarif. That still has to be done before this meets the issue's "Done when" condition.

Testing

Ran pytest in a clean Linux container: the 4 remaining failure(s) also occur on the base branch without this change; no new failures are introduced.

  • pytest tests passes
  • ruff check . passes
  • Added/updated tests for the behavior change

This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

Azure Pipelines users only had the generic "Anything else" snippet in
docs/CI.md. Add examples/ci/azure-pipelines.yml, modelled on the
GitLab job: it triggers on PRs and the default branch, installs secfoo
with pip on Python 3.12, runs the api agent with --fail-on high and
--max-cost 2.00, exports SARIF and JSONL, and publishes the files with
PublishPipelineArtifact even when a gate fails.

Add an "Azure Pipelines" section to docs/CI.md after GitLab CI that
explains where to set the secret OPENAI_API_KEY variable, why it must
be mapped into env: (Azure does not expose secrets to scripts), and
what the exit codes mean.

Fixes secfoo-com#173.
@Labu1
Labu1 requested a review from vsn411 as a code owner November 26, 2026 17:05
@vsn411

vsn411 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, and for the careful write-up. You independently reached the same conclusion we did about container jobs running as non-root. We're closing this PR only because #200 merged an Azure Pipelines example for #173 earlier today, so the two now conflict on both files.

Your version has two things the merged one doesn't, and we'd welcome a small follow-up PR on top of current main with them:

  1. Write the reports to $(Build.ArtifactStagingDirectory), so the output files don't land inside the checkout being scanned.
  2. Name the artifact CodeAnalysisLogs, if that is what the SARIF SAST Scans Tab extension reads. A link to the extension's docs that confirms it would be great, and a line in docs/CI.md that mentions the extension would help Azure users find their SARIF results.

Thanks again for your work this week on #198, #199 and #202.

@vsn411 vsn411 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI example: Azure Pipelines (examples/ci + docs/CI.md)

2 participants