Skip to content

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 ​

  1. Your pipeline checks out the repository as it normally does.
  2. The CoreFix scan step sets CFIX_API_KEY, installs the corefix CLI, and runs corefix code. The CLI pulls the corefixhq/cfix Docker image and scans the checked-out workspace.
  3. Results are written to ~/.corefix/scan-results on 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:

bash
export CFIX_API_KEY=<your-api-key>
curl -fsSL https://get.corefix.dev/corefix | sudo sh
corefix code

Your 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.

VariableStorageDescription
CFIX_API_KEYSecret (required)Your CoreFix API key — see Creating an API Key
GITHUB_TOKENSecretGitHub token for pushing SARIF to GitHub Code Scanning (see below)
OPENAI_API_KEYSecretOnly if bringing your own AI model

A secret can have any name you like — the examples call it CFIX_API_KEY to match the environment variable the CLI reads. If you already have a secret named X_CFIX_API_KEY, keep it and map it in the step, for example export 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:

yaml
permissions:
  contents: write
  packages: write
  security-events: write   # required to upload SARIF results to code scanning

Option 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 ​

PlatformStatus
GitHub ActionsSupported
GitLab CISupported
JenkinsSupported
CircleCISupported
Travis CIComing soon
Bitbucket PipelinesComing soon
Azure DevOps PipelinesComing 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:

yaml
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:

yaml
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 days

Jenkins ​

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:

groovy
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:

yaml
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-scan

Use the machine executor (not docker) 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:

bash
# 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,sast

Coming Soon ​

Support for the following platforms is in progress:

  • Travis CI
  • Bitbucket Pipelines
  • Azure DevOps Pipelines