OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
Azure Pipelines with Amazon Bedrock
Keep the pipeline definition in a trusted tooling repository. It installs the CLI, checks out a separate Azure Repos Git repository, and assumes an AWS role through OIDC to scan that checkout. On Azure DevOps Services, queue either a full scan or a diff between commits on a Microsoft-hosted Linux agent. The pipeline retains reports and can publish SARIF to the target repository's Advanced Security view.
Setup
- Copy
azure-pipelines.ymlinto the tooling repository. Setresources.repositories.target.nameto the approvedProject/Repositoryand adjust the defaulttargetRef. Keep the repository name fixed in reviewed YAML instead of accepting arbitrary scan targets at queue time. - Install the AWS Toolkit for Azure DevOps
extension in your organization. Create an AWS service connection named
codex-security-bedrockwith Use OIDC and an AWS role ARN; leave access keys unset. Follow the AWS OIDC setup guide. Restrict the role trust to the service connection's actual issuer, audience, and subject. Authorize only this pipeline to use the connection. - Set
awsRegionandbedrockModelIdto an available, approved Bedrock model or inference profile. Grant the role only the required Bedrock invocation permissions for those resources. The requested AWS session is one hour, matching the job timeout; configure the role to allow that duration. - Create a pipeline pointing at the copied YAML. Grant its project build service identity read access to the target repository and authorize the repository resource. Cross-project checkout needs explicit access in the target project; do not disable project-scoped job authorization to work around a missing grant. See multi-repository checkout permissions.
- Keep
publishToAdvancedSecurity: falsefor artifact-only runs. To enable the native findings view, enable the required GitHub Code Security / Advanced Security entitlement on the target repository and grant the pipeline identity permission to publish its results. Then opt in when queuing a run. See third-party SARIF publishing.
The template pins the CLI, Node, and Python. Azure Pipelines resolves task
updates within the selected major versions. To update codexSecurityVersion,
choose a reviewed CLI release with native Bedrock authentication, committed-diff
scans, and SARIF export. On the selected hosted agent, check
Bubblewrap startup
before checkout and AWS authentication. Then run a baseline and a diff against
a known commit. Verify both artifacts and the target commit for any published
SARIF before adopting the new pin.
Run a scan
Choose Run pipeline from the trusted tooling branch, then set:
| Parameter | Meaning |
|---|---|
targetRef |
Target branch or tag, defaulting to refs/heads/main. |
scanMode |
full for a baseline, or diff for changes relative to a base revision. |
baseRevision |
Used only for diff; defaults to HEAD^ (the preceding commit). Prefer an exact base commit SHA for reproducibility. |
failOnSeverity |
none is report-only; select a severity to fail on findings at or above it. |
publishToAdvancedSecurity |
Opt in to native SARIF publishing after completing its setup. |
Start with a full scan. For a later committed-diff scan, select the target branch and a base revision present in that repository's history. The checkout fetches full history; Codex Security resolves the diff against the checked-out commit. For PR validation, see trust and rollout boundaries.
The optional publisher uses the target repository resource metadata, not the
tooling repository's build metadata. Keep its alias and
advancedsecurity.publish.repository in sync when adapting the YAML. This is
Microsoft's explicit multi-repository publishing mechanism.
Full and diff results use separate categories so a diff does not replace
the full-scan baseline. A diff result is still a snapshot of that diff, not a
complete repository inventory; use full scans to track the baseline over time.
Results and failures
The codex-security pipeline artifact contains result.json, available
report.md, scan-manifest.json, and findings.json, plus results.sarif after a
successful export. Check the JSON/report for findings, scope, runtime, and
usage. Scope exclusions and deferred investigations do not fail the scan or
bypass the findings policy; exit 2 indicates an execution error.
| Scan exit | Pipeline behavior |
|---|---|
0 |
Completed scan; export SARIF and retain reports. |
1 |
Severity policy failed; still export SARIF and retain reports, but keep the job failed. |
| Other nonzero | Execution failed or was interrupted; retain available reports without exporting or publishing SARIF. |
An export or publishing failure also fails the job. Cancellation skips the post-scan steps, so artifacts are not guaranteed for canceled runs. Native publishing waits for processing; verify the target repository and commit in the first live run. Local validation cannot prove your organization's OIDC trust, permissions, model access, or SARIF ingestion.
Trust and rollout boundaries
- Restrict who can edit or queue this privileged pipeline and use its AWS service connection. Treat scanned code and model output as untrusted. OIDC avoids long-lived keys; it does not make running untrusted code with credentials safe.
- The CLI is installed before target checkout, outside the repository, with npm lifecycle scripts disabled. Checkout does not persist its credential. The AWS task supplies temporary credentials only to the scan step; no PAT or Azure access token is explicitly passed to the CLI.
- Reports can contain source excerpts and vulnerability details. Restrict artifact access and configure your project's pipeline-run retention policy. The example retains selected reports, not raw scan state, transcripts, or authentication files.
- For automatic Azure Repos PR checks, configure a target-branch build validation
policy and a PR-aware checkout/pipeline design. YAML
pr:triggers do not enable Azure Repos PR validation. Attaching this manual pipeline unchanged to a policy would still scan its configured target ref, not necessarily the PR. See Azure Repos PR triggers.