Code Scanning — CI/CD Integration
Add CoreFix code scanning to your existing pipeline with a single step. The step installs the corefix CLI and runs corefix code, which runs the CoreFix scanner container (corefixhq/cfix) for you. It can be dropped into any job that already checks out your code.
--patch is not used in CI/CD
--patch (CodeFix) is not usually used in CI/CD pipelines, because nobody applies patches inside a pipeline run. In a pipeline, corefix code scans your code and reports the findings; apply fixes from your own machine with corefix code --patch. See CodeFix — Automated Remediation.
For detailed CLI options, scanner flags, and BYOK model configuration, refer to CoreFix CLI.
How It Works
- Your pipeline checks out the repository as it normally does.
- The CoreFix scan step sets
CFIX_API_KEY, installs thecorefixCLI, and runscorefix code. The CLI pulls thecorefixhq/cfixDocker image and scans the checked-out workspace. - Results are written to
~/.corefix/scan-resultson the runner, pushed to the CoreFix dashboard, and optionally emailed.
You can add the CoreFix scan as a standalone workflow file or as a step in an existing job.
Every example on this page uses the same three commands:
export CFIX_API_KEY=<your-api-key>
curl -fsSL https://get.corefix.dev/corefix | sudo sh
corefix codeYour runner needs Docker available and permission to run sudo for the install. Use CFIX_API_KEY for authentication in pipelines — corefix login opens a browser and isn't suitable for CI.
Secrets & Permissions
Store sensitive values as secrets in your CI/CD platform.
| Variable | Storage | Description |
|---|---|---|
CFIX_API_KEY | Secret (required) | Your CoreFix API key — see Creating an API Key |
GITHUB_TOKEN | Secret | GitHub token for pushing SARIF to GitHub Code Scanning (see below) |
OPENAI_API_KEY | Secret | Only if bringing your own AI model |
A secret can have any name you like — the examples call it
CFIX_API_KEYto match the environment variable the CLI reads. If you already have a secret namedX_CFIX_API_KEY, keep it and map it in the step, for exampleexport CFIX_API_KEY=${{ secrets.X_CFIX_API_KEY }}.
GitHub Token for SARIF Upload
You have two options for providing GITHUB_TOKEN:
Option 1 — Use the built-in GITHUB_TOKEN (GitHub Actions only)
GitHub Actions automatically exposes a GITHUB_TOKEN. Add the following permissions to your workflow so it can upload SARIF results:
permissions:
contents: write
packages: write
security-events: write # required to upload SARIF results to code scanningOption 2 — Use a Personal Access Token (PAT)
If you are not using GitHub Actions, or prefer a PAT, create one with Code Scanning — Read and Write access under the token's repository permissions. Store it as a secret in your CI/CD platform and pass it with --github-token.
Supported Platforms
| Platform | Status |
|---|---|
| GitHub Actions | Supported |
| GitLab CI | Supported |
| Jenkins | Supported |
| CircleCI | Supported |
| Travis CI | Coming soon |
| Bitbucket Pipelines | Coming soon |
| Azure DevOps Pipelines | Coming soon |
GitHub Actions
Add secrets in your repository under Settings → Secrets and variables → Actions → New repository secret. See GitHub Actions encrypted secrets for details.
Create .github/workflows/corefix-code-scan.yml:
name: CoreFix Code Security Scan
on:
push:
branches: [main, master]
pull_request:
permissions:
security-events: write
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run CoreFix Code Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export CFIX_API_KEY=${{ secrets.CFIX_API_KEY }}
curl -fsSL https://get.corefix.dev/corefix | sudo sh
corefix code --github-token "$GITHUB_TOKEN"
- name: Upload scan results
if: always()
uses: actions/upload-artifact@v4
with:
name: corefix-scan-results
path: /home/runner/.corefix/scan-results/GitLab CI
Add variables in your project under Settings → CI/CD → Variables. Create CFIX_API_KEY and mark it as Masked and Protected. See GitLab CI/CD variables for details.
GitLab exposes CI/CD variables as environment variables, so CFIX_API_KEY is already set inside the job. The docker:24 image is Alpine-based, so curl and sudo are installed first.
Create or add to .gitlab-ci.yml:
stages:
- security
corefix-code-scan:
stage: security
image: docker:24
services:
- docker:24-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- apk add --no-cache curl sudo
- curl -fsSL https://get.corefix.dev/corefix | sudo sh
script:
- corefix code
after_script:
- mkdir -p scan-results
- cp -r ~/.corefix/scan-results/. scan-results/ || true
artifacts:
when: always
paths:
- scan-results/
expire_in: 7 daysJenkins
Add credentials in Manage Jenkins → Credentials → System → Global credentials as Secret text entries. See Jenkins credentials for details.
withCredentials exposes the secret as the CFIX_API_KEY environment variable for the commands inside it.
Create a Jenkinsfile for a dedicated security scan pipeline:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('CoreFix Code Scan') {
steps {
withCredentials([
string(credentialsId: 'corefix-api-key', variable: 'CFIX_API_KEY')
]) {
sh '''
curl -fsSL https://get.corefix.dev/corefix | sudo sh
corefix code
'''
}
}
post {
always {
sh '''
mkdir -p scan-results
cp -r ~/.corefix/scan-results/. scan-results/ || true
'''
archiveArtifacts artifacts: 'scan-results/**', allowEmptyArchive: true
}
}
}
}
}CircleCI
Add environment variables in your project under Project Settings → Environment Variables. Create CFIX_API_KEY — CircleCI exposes it to every step as an environment variable. See CircleCI environment variables for details.
Create .circleci/config.yml:
version: 2.1
jobs:
corefix-code-scan:
machine:
image: ubuntu-2204:current
steps:
- checkout
- run:
name: Run CoreFix Code Scanner
command: |
curl -fsSL https://get.corefix.dev/corefix | sudo sh
corefix code
- store_artifacts:
path: /home/circleci/.corefix/scan-results
destination: corefix-scan-results
workflows:
security:
jobs:
- corefix-code-scanUse the
machineexecutor (notdocker) so that Docker is available to the CLI.
Choosing Scanners
Run specific scanners to keep pipeline time down, or run all for a full audit. Use these in place of corefix code in the examples above:
# All scanners (default — omit positional argument)
corefix code
# Dependencies only
corefix code osv
# Secrets detection + SAST
corefix code secrets,sast
# IaC + Kubernetes
corefix code iac,k8s
# Full scan, explicit
corefix code osv,iac,secrets,k8s,sastComing Soon
Support for the following platforms is in progress:
- Travis CI
- Bitbucket Pipelines
- Azure DevOps Pipelines