Skip to content
Mikoshi

Docs

CI/CD

Run Mikoshi on every pull request so exploitable bugs are caught before they merge, and on a schedule for deeper coverage. Any CI system with Docker can run it.

The pattern

  1. Install Mikoshi on a runner that has Docker.
  2. Pass your model settings as secrets.
  3. Run headless: mikoshi -n -t ./ --scan-mode quick. On pull requests a quick scan automatically narrows to the changed files.
  4. Gate the build on the exit code, and keep mikoshi_runs/ as an artifact.
SecretValue
MIKOSHI_LLMModel id, for example openrouter/z-ai/glm-5.3
LLM_API_KEYAPI key for that provider
Exit codeMeaningCI result
0No findings (or none at or above --fail-on)Pass
1Error: missing settings, Docker unavailable, bad configFail
2Vulnerabilities found (at or above --fail-on, if set)Fail

--fail-on high fails the build only on high and critical findings. Lower ones are still in every report, so a green build doesn’t mean an empty report.

GitHub Actions

This workflow scans each pull request, posts findings as review comments on the changed lines, uploads SARIF to GitHub code scanning, and keeps the full run as an artifact.

.github/workflows/mikoshi.yml
name: Mikoshi security scan

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write     # review comments
  security-events: write   # SARIF upload

jobs:
  mikoshi:
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0   # full history, so the diff against the base branch resolves

      - name: Install Mikoshi
        run: curl -sSL https://www.mikoshi.digital/install | bash

      - name: Scan
        env:
          MIKOSHI_LLM: ${{ secrets.MIKOSHI_LLM }}
          LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          mikoshi -n -t ./ --scan-mode quick \
            --max-budget 10 --fail-on high --pr-comments

      - name: Collect SARIF
        if: always()
        run: |
          run_dir=$(ls -td mikoshi_runs/*/ 2>/dev/null | head -1)
          if [ -n "$run_dir" ] && [ -f "$run_dir/findings.sarif" ]; then
            cp "$run_dir/findings.sarif" mikoshi.sarif
          fi

      - name: Upload to code scanning
        if: always() && hashFiles('mikoshi.sarif') != ''
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: mikoshi.sarif
          category: mikoshi

      - name: Keep the run
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: mikoshi-run
          path: mikoshi_runs

How pull-request comments work

  • Findings on lines the PR changed become inline comments; everything else goes in one summary review.
  • Re-runs don’t duplicate comments. The summary is updated in place.
  • Add --pr-request-changes to submit “Request changes” when findings meet --fail-on. Mikoshi dismisses its own request once a later run is clean.
  • Posting never changes the exit code. Failures are recorded in run.json.

Nightly deep scan

Pair fast PR checks with a deeper scheduled scan of the whole codebase and your staging site:

.github/workflows/mikoshi-nightly.yml
name: Mikoshi nightly scan

on:
  schedule:
    - cron: "0 1 * * *"
  workflow_dispatch:

jobs:
  mikoshi:
    runs-on: ubuntu-latest
    timeout-minutes: 300
    steps:
      - uses: actions/checkout@v4
      - run: curl -sSL https://www.mikoshi.digital/install | bash
      - name: Scan
        env:
          MIKOSHI_LLM: ${{ secrets.MIKOSHI_LLM }}
          LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
        run: |
          mikoshi -n -t ./ -t https://staging.example.com \
            --scan-mode deep --scope-mode full --max-budget 50 \
            --instruction-file ./security/pentest-instructions.md
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          name: mikoshi-nightly
          path: mikoshi_runs

GitLab CI

Run the job on a runner with the shell executor and Docker installed on the same host, and tag it (here docker-host).

.gitlab-ci.yml
mikoshi:
  tags: [docker-host]
  variables:
    GIT_DEPTH: 0
  script:
    - curl -sSL https://www.mikoshi.digital/install | bash
    - ~/.mikoshi/bin/mikoshi -n -t ./ --scan-mode quick --fail-on high --max-budget 10
  artifacts:
    when: always
    paths:
      - mikoshi_runs/
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

Add MIKOSHI_LLM and LLM_API_KEY as masked CI/CD variables. For merge requests, pass --diff-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME if the base branch isn’t detected.

Jenkins

Jenkinsfile
pipeline {
  agent any
  environment {
    MIKOSHI_LLM = credentials('mikoshi-llm')
    LLM_API_KEY = credentials('llm-api-key')
  }
  stages {
    stage('Security scan') {
      steps {
        sh 'curl -sSL https://www.mikoshi.digital/install | bash'
        sh '$HOME/.mikoshi/bin/mikoshi -n -t ./ --scan-mode quick --fail-on high --max-budget 10'
      }
    }
  }
  post {
    always { archiveArtifacts artifacts: 'mikoshi_runs/**', allowEmptyArchive: true }
  }
}

CircleCI

.circleci/config.yml
version: 2.1
jobs:
  mikoshi:
    machine:
      image: ubuntu-2404:current
    steps:
      - checkout
      - run: curl -sSL https://www.mikoshi.digital/install | bash
      - run: ~/.mikoshi/bin/mikoshi -n -t ./ --scan-mode quick --fail-on high --max-budget 10
      - store_artifacts:
          path: mikoshi_runs
workflows:
  scan:
    jobs: [mikoshi]

Diff scope

FlagEffect
--scope-mode autoDefault. Changed-files scope in CI and headless pull-request runs.
--scope-mode diffAlways scan only what changed.
--scope-mode fullAlways scan everything.
--diff-base origin/mainThe branch or commit to compare against.

If diff resolution fails, fetch full history (fetch-depth: 0, GIT_DEPTH: 0) or set --diff-base.

What to keep in your repository

  • An instruction file (security/pentest-instructions.md) with test roles, focus areas and exclusions. See instructions.
  • Custom skills for your own stack, loaded with --skills-dir. See skills.
  • Never keys or real credentials. Use your CI’s secret store and staging-only test accounts.