GitHub Actions Setup Example
Use our GitHub Action saving this as .github/workflows/threatcanvas.yml:
# GitLab CI example for SecureFlag CI Runner
#
# Add this to your repository's .gitlab-ci.yml
name: Generate Threat Model with ThreatCanvas
on:
push:
tags:
- '*'
jobs:
threat-model:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: secureflag/actions/.github/actions/repo_to_threat_model@main
with:
SECUREFLAG_API_KEY: ${{ secrets.SECUREFLAG_API_KEY }}
SECUREFLAG_MODEL_UUID: ${{ vars.SECUREFLAG_MODEL_UUID }}
# AI Provider - choose ONE of the following options:
# Option 1 - Anthropic:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
# ANTHROPIC_MODEL: claude-sonnet-4-20250514 # optional
# Option 2 - OpenAI:
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# OPENAI_MODEL: gpt-4o # optional
# Option 3 - Azure OpenAI:
# AZURE_OPENAI_KEY: ${{ secrets.AZURE_OPENAI_KEY }}
# AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
# AZURE_OPENAI_DEPLOYMENT: ${{ secrets.AZURE_OPENAI_DEPLOYMENT }}
# AZURE_OPENAI_API_VERSION: 2024-02-15-preview # optional
# Option 4 - Gemini:
# GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
# GEMINI_MODEL: gemini-2.5-flash # optional
Configure GitHub Secrets and Variables:
- Go to your repository → Settings → Secrets and variables → Actions
- Add SECUREFLAG_API_KEY secret using your SecureFlag API key
- Add the AI Environment Variables as secrets depending on your AI provider.
After configuring this, you need to create a new tag and publish a new release.
In this example, the job runs automatically on any tag push (e.g., when you create a release).
You can read more about this GitHub Action
here.
GitLab CI Setup Example
Add this to your repository's .gitlab-ci.yml:
# GitLab CI example for SecureFlag CI Runner
#
# Add this to your repository's .gitlab-ci.yml
#
# Required CI/CD variables (set as masked/protected):
# - SECUREFLAG_API_KEY: SecureFlag API authentication
#
# Required CI/CD variables:
# - SECUREFLAG_MODEL_UUID: SecureFlag model UUID
#
# AI Provider variables (choose one, set as masked/protected):
# Option 1 - Anthropic:
# - ANTHROPIC_API_KEY: Anthropic API key
# - ANTHROPIC_MODEL: (optional) Model name, default: claude-sonnet-4-20250514
# Option 2 - OpenAI:
# - OPENAI_API_KEY: OpenAI API key
# - OPENAI_MODEL: (optional) Model name, default: gpt-4o
# Option 3 - Azure OpenAI:
# - AZURE_OPENAI_KEY: Azure OpenAI API key
# - AZURE_OPENAI_ENDPOINT: Azure endpoint URL (e.g., https://your-resource.openai.azure.com/)
# - AZURE_OPENAI_DEPLOYMENT: Azure deployment name
# - AZURE_OPENAI_API_VERSION: (optional) API version, default: 2024-02-15-preview
# Option 4 - Gemini:
# - GEMINI_API_KEY: Google Gemini API key
# - GEMINI_MODEL: (optional) Model name, default: gemini-2.5-flash
#
# Optional CI/CD variables:
# - SECUREFLAG_REPO_PATH: Absolute path to restrict analysis to a directory (prepend with $CI_PROJECT_DIR)
# - SECUREFLAG_COMPONENT_LIMIT: (for 'model-repo') Hinted number of nodes in TC diagrams
stages:
- tests
secureflag_ci:
stage: tests
image: registry.gitlab.com/secureflag-community/sf-runner:latest
variables:
SECUREFLAG_COMMANDS: model-repo
script:
- /app/entrypoint.sh
rules:
# Run on tags
- if: $CI_COMMIT_TAG
# Run on schedules
- if: '$CI_PIPELINE_SOURCE == "schedule"'
allow_failure: true
Configure GitLab CI/CD Secrets and Variables:
- Go to your project → Settings → CI/CD → Variables
- Add SECUREFLAG_API_KEY secret using your SecureFlag API key
- Add the AI Environment Variables as secrets depending on your AI provider.
After configuring this, you need to create a new tag and publish a new release.
In this example, the job runs automatically on:
- Any tag push (e.g., when you create a release)
- Scheduled pipelines (configure in CI/CD → Schedules)