Docs / INTEGRATIONS
INTEGRATIONS
CI/CD Integration
Written and maintained by Hendrik Schneider · Last reviewed · How we check this
Korthex is designed to run in automated pipelines. The check command provides exit codes suitable for gate checks, and output formats like SARIF integrate directly with code scanning platforms.
GitHub Actions
name: Korthex Crypto Scan on: [push, pull_request] jobs: scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # Signature-verified install: the script pins the Ed25519 release key and # aborts (non-zero, nothing written) if the manifest or artifact does not # verify against it. - name: Install Korthex run: curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash - name: Run Scan run: korthex check . --fail-on high --format sarif --output results.sarif - name: Upload SARIF if: always() uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif
GitLab CI
korthex-scan: image: ubuntu:22.04 stage: test script: # ubuntu:22.04 is a minimal image: curl and CA certificates are not preinstalled. - apt-get update -qq && apt-get install -y -qq curl ca-certificates - curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash - export PATH="$HOME/.korthex/bin:$PATH" # --format gitlab-cq is what the Code Quality widget parses. --format json # emits the check SUMMARY, which GitLab accepts and then renders as nothing. - korthex check . --fail-on high --format gitlab-cq --output gl-korthex-report.json artifacts: when: always reports: codequality: gl-korthex-report.json paths: - gl-korthex-report.json
Azure DevOps
- task: Bash@3 displayName: 'Korthex Crypto Scan' inputs: targetType: 'inline' script: | curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash korthex check . --fail-on high --format sarif --output $(Build.ArtifactStagingDirectory)/korthex.sarif - task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)/korthex.sarif' ArtifactName: 'KorthexResults'
Jenkins
pipeline { agent any stages { stage('Korthex Scan') { steps { // Without this the agent has no korthex on PATH. sh 'curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash' sh 'export PATH="$HOME/.korthex/bin:$PATH" && korthex check . --fail-on high --format sarif --output korthex.sarif' } post { always { archiveArtifacts artifacts: 'korthex.sarif' } } } } }
Bitbucket Pipelines
Bitbucket Pipelines has no native SARIF ingestion. There is no bundled step that renders a SARIF file into the pull request view, so the gate publishes korthex.sarif , the JSON check summary and the encrypted .krx report as build artifacts instead of claiming an inline annotation it does not implement. Bitbucket’s Code Insights Reports API can render inline annotations, but wiring it needs a repository-scoped access token and hand-written REST calls, and that is left to the operator. The whole gate runs as one block scalar. Bitbucket captures $? per script list item, so a gate split across list entries cannot reliably read its own exit code. KORTHEX_CI_TOKEN needs no wiring: a secured repository variable of that name is already in the step environment, and leaving it undefined is the full offline run. image: ubuntu:22.04 clone: depth: full # the baseline diff needs full history definitions: steps: - step: &korthex-scan name: Korthex crypto scan gate script: - | set +e # ubuntu:22.04 is a minimal image: curl and CA certificates are not preinstalled. apt-get update -qq && apt-get install -y -qq curl ca-certificates curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash export PATH="$HOME/.korthex/bin:$PATH" # One command for what used to be three: scan, judge against policy, # baseline and the --fail-on ceiling, write the SARIF, exit with the # code naming the hardest failure. No --policy: check picks up # .korthex_policy.json from the scanned root itself. korthex check . --fail-on high --baseline .korthex_baseline.krx --context pr --format sarif --output korthex.sarif --json > korthex-check.json code=$? # The scanner writes the .krx next to its own executable, not into the # clone. --json puts that path in "report"; copy it into the workspace # so the artifact list has something to match. sed rather than jq: # ubuntu:22.04 carries neither jq nor python3. report="$(sed -n 's/.*"report"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' korthex-check.json | head -n 1)" if [ -n "$report" ] && [ -f "$report" ]; then cp "$report" korthex-report.krx; fi cat korthex-check.json exit $code artifacts: - korthex.sarif - korthex-check.json - korthex-report.krx pipelines: default: - step: *korthex-scan pull-requests: '**': - step: *korthex-scan No warm-scan cache, and that is a refusal rather than an omission. Bitbucket runs cold every time. Elsewhere Korthex preserves .korthex_cache/ between runs, and that directory holds two things: the content-hash snapshot that decides which files are re-analysed, and the per-file findings reused for the ones judged unchanged. A cache entry can therefore make the gate skip a file and supply that file’s findings, which means whoever can write the cache decides what the gate sees. GitHub and Azure scope a cache to a branch and deny a parent branch the right to read a child’s; GitLab keeps protected and non-protected branches apart. Bitbucket identifies a cache by a name plus an optional set of files to hash, with no branch or commit expression, and whether the platform additionally scopes it per branch is not stated in its cache documentation. The deciding fact is unknown and the cost of guessing wrong is suppressed findings, so the cache goes in when the scoping rule can be shown, not before.
CircleCI
CircleCI has no native SARIF ingestion either. korthex.sarif , the JSON check summary and the encrypted .krx report are published through store_artifacts with when: always , because the gate exits non-zero by design whenever it finds something and that is exactly when the report is wanted. Without it CircleCI skips the remaining steps of a failed job and the report of every failing build would be the one nobody could download. The gate runs as one command block for the same reason as on GitLab, Azure and Bitbucket: CircleCI gives every run step its own shell, so a gate split across steps cannot read its own exit code. Define KORTHEX_CI_TOKEN as a project or context environment variable and korthex check reads it from the job environment on its own; leaving it undefined is the full offline run. version: 2.1 jobs: korthex-scan: docker: # A real, always-pullable image. There is no published Korthex container # image yet, so a template naming korthex/cli would name a tag that only # exists for whoever built it themselves. - image: cimg/base:current steps: - checkout - run: name: Korthex crypto scan gate command: | set +e # cimg/base ships curl and CA certificates already. curl -fsSL https://api.global.korthex.io/api/version/install.sh | bash export PATH="$HOME/.korthex/bin:$PATH" korthex check . --fail-on high --baseline .korthex_baseline.krx --context pr --format sarif --output korthex.sarif --json > korthex-check.json code=$? # The scanner writes the .krx next to its own executable, not into the # clone. --json puts that path in "report"; copy it into the workspace. report="$(sed -n 's/.*"report"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' korthex-check.json | head -n 1)" if [ -n "$report" ] && [ -f "$report" ]; then cp "$report" korthex-report.krx; fi # The summary names every gate that ran and every gate that did not, # so the log carries the reasoning and not only the verdict. cat korthex-check.json exit $code - store_artifacts: path: korthex.sarif destination: korthex.sarif when: always - store_artifacts: path: korthex-check.json destination: korthex-check.json when: always - store_artifacts: path: korthex-report.krx destination: korthex-report.krx when: always workflows: korthex: jobs: - korthex-scan No warm-scan cache here either, and this refusal rests on evidence rather than on the absence of it. CircleCI cache keys live in a project-wide namespace with no platform-enforced branch scope. restore_cache matches a key by prefix, and pull requests from the same repository share a cache with each other and with the main repository’s cache. Putting {{ .Branch }} in a key is therefore a convention the pipeline author adopts, not a boundary the platform builds. Since a cache entry can make the gate skip a file and supply that file’s findings, an unscoped shared cache is a channel through which findings can be suppressed, so save_cache and restore_cache stay out until CircleCI enforces a per-branch scope. Note the difference from Bitbucket: there the deciding fact is unknown, here it is known and it points the wrong way.