Model Fortress
CI/CD setup

Gate every model in your pipeline.

Add one step to your workflow so a model that breaches your severity policy fails the build instead of reaching production. The step runs the mf CLI, which triggers a scan, waits for the verdict and sets the exit code. It can also export a SARIF report to your code-scanning view.

The mf CLI is a small, dependency-free Python package. It talks to your instance's API base, so the same pipeline works whether you bought Model Fortress on the Azure, AWS or GCP marketplace. Only MF_API_BASE changes.

How the gate works

  1. Your pipeline installs the mf CLI and calls it with a token and the model you want to check.
  2. Model Fortress runs a static scan and, if you ask for it, a red-team campaign.
  3. The result is measured against your severity policy and reduced to one verdict.
  4. The command exits 0 when the model passes and non-zero when it breaches the gate, so the build stops.

Before you start

1. Create a token

In the app open your account settings, go to API keys & CI and create a Personal Access Token. Scope it to the tenant the pipeline should see. Copy the value once and store it straight away.

2. Store the token and endpoint

Never commit a token. Put it in your platform secret store and read it, with your API base and tenant, as environment variables at run time.

VariableMeaning
MF_API_BASEYour instance's API base, e.g. https://app.modelfortress.ai/api
MF_TOKENThe Personal Access Token you just created
MF_TENANTYour tenant id
PlatformWhere it goes
GitHubSettings then Secrets and variables then Actions
GitLabSettings then CI/CD then Variables, marked masked and protected
OtherYour secret manager, injected as environment variables

3. Install the CLI

The CLI ships on PyPI and is stdlib-only, so it installs in seconds in any CI image with Python.

pip install model-fortress-cli

Check it and confirm the connection to your instance:

export MF_API_BASE=https://app.modelfortress.ai/api
export MF_TOKEN=<your token>
export MF_TENANT=<your tenant id>

mf --version
mf models list

4. GitHub Actions

Add a job that runs the gate on every pull request. The job fails the check when the model breaches your policy so the pull request cannot merge.

.github/workflows/model-gate.ymlname: Model Fortress
on:
  pull_request:
  workflow_dispatch:

permissions:
  contents: read
  security-events: write   # needed to upload SARIF to the Security tab

jobs:
  model-security:
    runs-on: ubuntu-latest
    env:
      MF_API_BASE: ${{ secrets.MF_API_BASE }}
      MF_TOKEN: ${{ secrets.MF_TOKEN }}
      MF_TENANT: ${{ secrets.MF_TENANT }}
      MODEL_ID: ${{ vars.MODEL_ID }}
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install model-fortress-cli

      - name: Start scan
        id: scan
        run: echo "scan_id=$(mf scan --model-id "$MODEL_ID" --no-wait)" >> "$GITHUB_OUTPUT"

      - name: Wait and enforce the scan gate
        run: mf scan --scan-id "${{ steps.scan.outputs.scan_id }}" --tool modelscan

      - name: Export SARIF
        if: always()
        run: mf export --job-id "${{ steps.scan.outputs.scan_id }}" --format sarif -o mf.sarif.json

      - name: Upload SARIF to the Security tab
        if: always()
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: mf.sarif.json

      # Optional: also red-team the model and gate on it.
      - name: Red-team gate
        run: mf redteam --model-id "$MODEL_ID" --probes dan,encoding --generations 5

The gate step fails the job on a breach, which marks the check red on the pull request. The export and upload steps run with always() so the findings reach code scanning even when the gate fails.

GitLab CI

.gitlab-ci.ymlmodel_security:
  image: python:3.11-slim
  variables:
    GIT_STRATEGY: fetch
  script:
    - pip install model-fortress-cli
    - SCAN_ID=$(mf scan --model-id "$MODEL_ID" --no-wait)
    - mf scan --scan-id "$SCAN_ID" --tool modelscan      # waits + gates
    - mf export --job-id "$SCAN_ID" --format sarif -o mf.sarif.json
    - mf redteam --model-id "$MODEL_ID" --probes dan,encoding --generations 5
  artifacts:
    when: always
    paths:
      - mf.sarif.json
    reports:
      sast: mf.sarif.json      # surfaces findings in GitLab's Security dashboard
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH

Set MF_API_BASE, MF_TOKEN, MF_TENANT and MODEL_ID as CI/CD variables. Mark MF_TOKEN masked and protected so it is only exposed to protected branches and never printed in a log.

Any pipeline with a shell

If there is no ready-made step for your platform the gate is a short script. It installs the CLI, starts a scan, waits and reads the verdict. Save this as model-fortress-gate.sh.

model-fortress-gate.sh#!/usr/bin/env bash
# Needs MF_API_BASE, MF_TOKEN, MF_TENANT and MODEL_ID in the environment.
# A non-zero exit fails the build.
set -euo pipefail

pip install model-fortress-cli

# Static scan: submit, wait, and fail on a policy-gate breach.
SCAN_ID=$(mf scan --model-id "$MODEL_ID" --no-wait)
echo "scan $SCAN_ID"
mf scan --scan-id "$SCAN_ID" --tool modelscan

# Keep the findings regardless of pass or fail.
mf export --job-id "$SCAN_ID" --format sarif -o mf.sarif.json || true

# Red-team gate (optional).
mf redteam --model-id "$MODEL_ID" --probes dan,encoding --generations 5

CLI commands

CommandWhat it does
mf scan --model-id <id> --tool <tool>Submit a static scan, wait, and fail on a gate breach. Tools: modelscan, modelaudit, picklescan, gguf-scan.
mf redteam --model-id <id> --probes dan,encodingSubmit a red-team run, wait, and fail on a gate breach.
mf gate --scan-id <id> / --run-id <id>Read the verdict for an existing job without waiting.
mf export --job-id <id> --format sarif -o out.jsonDownload findings. Formats: sarif, json, csv, pdf.
mf models listList the models registered in your tenant with their ids.

Useful flags on scan and redteam: --no-wait submits and prints the id, --no-gate prints the verdict but never fails, --timeout sets the maximum wait (default 1800s), --poll sets the seconds between polls (default 5). Config comes from the environment above or from --api-base, --token and --tenant flags.

Exit codes

CodeMeaningBuild
0Gate passed, or run with --no-gatePass
1Gate breached, job failed, or timed outFail
2Usage or transport error (bad flags, unreachable API, auth)Error

The gate is fail-closed: a failed scan or run never passes, a breach fails the build, and a job with no governing policy does not fail on its own. Treat code 2 as a failure in anything headed to production so a pipeline problem never lets an unchecked model through.

SARIF upload

SARIF is the format GitHub and GitLab read to show findings inline on a change. Run mf export --format sarif then hand the file to your platform. On GitHub that is the upload-sarif action shown above. On GitLab it is the sast report artifact. Each finding then appears against the exact file and line.

Severity policy

The policy is the bar the gate measures against. It is attached to the model in the app, so a change applies everywhere at once. A typical setup keeps a lenient policy for experiments and a strict one for release branches.

PolicyFails onUse for
baselinecritical onlyEarly experiments
productionhigh and criticalRelease branches
strictmedium, high and criticalRegulated workloads

Blocking merges

A red check does not stop a merge on its own. Make the gate required so a breach actually blocks the change.

Troubleshooting

SymptomLikely cause
401 UnauthorizedToken missing, expired or scoped to another tenant.
mf: command not foundThe install step did not run, or ran in a different stage. Keep pip install model-fortress-cli in the same job as the mf calls.
Step hangs then times outA large model is still downloading. Raise --timeout or pre-register the model.
Red-team run fails straight awayThe model is not generative. Scan it statically instead or point the run at an endpoint.
Gate skippedQuota ran out for the period. Buy a credit pack or upgrade the plan.
Home Documentation Pricing Contact © 2026 Au2mAiT Ltd · Model Fortress