Production-ready, turn-key GitHub Actions workflows and configuration templates for integrating Google Cloud CodeMender (cm) into your continuous integration and deployment pipelines.
CodeMender transforms your CI/CD pipeline from a passive static analyzer into an autonomous AI Security Co-developer powered by Gemini reasoning models (gemini-3.8-flash, gemini-3.8-flash-cyber, and gemini-4-argon).
- π Zero-Trust Keyless Auth & Preflight Diagnostics: Authenticate GitHub Actions runners to Google Cloud IAM via Workload Identity Federation (WIF)βzero static service account JSON keysβand validate credentials, configuration, network reachability, and Vertex AI IAM authorization upfront with
cm health --strict. - β‘ Adaptive 3-Tier Scan Modes:
- Differential AST PR Scans (
--diff): Restrict Pull Request scanning to modified files and their 1-hop callers/callees (--diff="origin/$BASE_REF" --diff-workers=16) for fast PR feedback loops. - Rapid Baseline Audits (
--quick): Run single-session repository scans onmain/masterbranch pushes in minutes. - Concurrent File-by-File Deep Scans (Default
cm find): Run exhaustive multi-worker deep audits (--deep-workers=8) on weekly schedules or on-demandworkflow_dispatch.
- Differential AST PR Scans (
- π‘οΈ Legacy Debt Noise Suppression: Findings in untouched code during PR scans are labeled
[LEGACY / UNTOUCHED]in SARIF reports for visibility, without failing the PR merge gate or triggering unrelated autofixes. - π¦ Quality Hard Gates (
--fail-on): Automatically block PR merges with non-zero exit codes when newly introduced Critical or High vulnerabilities are detected, while safely exporting and uploading SARIF alerts via exit-code (steps.scan.outputs.completed == 'true') and file (!cancelled() && hashFiles('results.sarif') != '') guards. - π‘οΈ OASIS SARIF v2.1.0 & Native Step Summaries: Export standardized SARIF for GitHub Code Scanning and publish Markdown executive summary tables directly to
$GITHUB_STEP_SUMMARY. - π€ Autonomous Remediation & Auto-PR: Automatically synthesize language-aware security patches (parameterization, input sanitization), verify against regression test suites inside isolated runners, and open review Pull Requests (
create-pull-request@v8). - π¦ Artifact-Driven State Transfer (
cm report import): Seamlessly hand off actionable findings between scanning and remediation jobs via JSON artifacts, eliminating fragile cross-runner SQLite database restoration. - π Polyglot AST Support: Works natively with JavaScript/TypeScript, Python, Go, Java, C/C++, C#, Rust, Kotlin, Ruby, and PHP without external plugins.
.
βββ .github/
β βββ workflows/
β βββ codemender-scan.yml # Continuous scanning, SARIF export & Step Summary
β βββ codemender-remediate.yml # Autonomous patch generation & Auto-PR (Public Repos)
β βββ codemender-remediate-private-repo.yml # Full PoC verification & Auto-PR (Private Repos)
βββ .codemender/
β βββ config.yaml # Headless CI profile & automated test gate
βββ .gitignore
βββ LICENSE
βββ README.md
Run the following commands from the root of your existing Git repository to fetch these pre-configured templates:
# 1. Create target directories
mkdir -p .github/workflows .codemender
# 2. Download Security Scanning & SARIF Export Workflow
curl -fsSL https://raw.githubusercontent.com/edwardc-gcp/codemender-github-actions/main/.github/workflows/codemender-scan.yml \
-o .github/workflows/codemender-scan.yml
# 3. Download Autonomous Remediation & Auto-PR Workflow
curl -fsSL https://raw.githubusercontent.com/edwardc-gcp/codemender-github-actions/main/.github/workflows/codemender-remediate.yml \
-o .github/workflows/codemender-remediate.yml
# 4. Download CI Headless Configuration Profile
curl -fsSL https://raw.githubusercontent.com/edwardc-gcp/codemender-github-actions/main/.codemender/config.yaml \
-o .codemender/config.yamlConfigure the following secrets in your repository settings (Settings > Secrets and variables > Actions):
| Secret Name | Example / Description |
|---|---|
GCP_WORKLOAD_IDENTITY_PROVIDER |
projects/1234567890/locations/global/workloadIdentityPools/my-pool/providers/my-provider |
GCP_SERVICE_ACCOUNT |
codemender-ci-runner@my-project-id.iam.gserviceaccount.com |
Run these commands in Google Cloud Shell to provision keyless authentication:
# Set your environment variables
export PROJECT_ID=$(gcloud config get-value project)
export GITHUB_ORG="YOUR_GITHUB_ORG_OR_USERNAME"
export GITHUB_REPO="YOUR_REPO_NAME"
export POOL_NAME="codemender-github-pool"
export PROVIDER_NAME="codemender-github-provider"
export SA_NAME="codemender-ci-runner"
export SA_EMAIL="${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"
# 1. Enable required APIs
gcloud services enable iam.googleapis.com iamcredentials.googleapis.com sts.googleapis.com aiplatform.googleapis.com cloudresourcemanager.googleapis.com --project="${PROJECT_ID}"
# 2. Create Service Account and grant Gemini Agent Platform permissions
gcloud iam service-accounts create ${SA_NAME} --display-name="CodeMender CI Runner" --project="${PROJECT_ID}"
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/aiplatform.user"
# 3. Create Workload Identity Pool and OIDC Provider
gcloud iam workload-identity-pools create ${POOL_NAME} --location="global" --project="${PROJECT_ID}"
gcloud iam workload-identity-pools providers create-oidc ${PROVIDER_NAME} \
--workload-identity-pool=${POOL_NAME} \
--location="global" \
--issuer-uri="https://token.actions.githubusercontent.com" \
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository,attribute.repository_owner=assertion.repository_owner" \
--attribute-condition="assertion.repository == '${GITHUB_ORG}/${GITHUB_REPO}'" \
--project="${PROJECT_ID}"
# 4. Bind Service Account Impersonation
export POOL_ID=$(gcloud iam workload-identity-pools describe ${POOL_NAME} \
--project="${PROJECT_ID}" \
--location="global" \
--format="value(name)")
gcloud iam service-accounts add-iam-policy-binding "${SA_EMAIL}" \
--project="${PROJECT_ID}" \
--role="roles/iam.workloadIdentityUser" \
--member="principalSet://iam.googleapis.com/${POOL_ID}/attribute.repository/${GITHUB_ORG}/${GITHUB_REPO}"
# 5. Output Provider Name for GitHub Secrets
gcloud iam workload-identity-pools providers describe ${PROVIDER_NAME} \
--workload-identity-pool=${POOL_NAME} \
--location="global" \
--project="${PROJECT_ID}" \
--format="value(name)"- Trigger: Pull requests and pushes targeting
main/master, scheduled weekly audits, and manual dispatch. - Scan Modes:
- Differential PR Scan (
--diff): Onpull_requestevents, analyzes modified files and their 1-hop AST callers/callees (--diff="origin/$BASE_REF" --diff-workers=16 --fail-on="CRITICAL,HIGH"), blocking merges on newly introduced Critical/High flaws. - Quick Baseline Scan (
--quick): Onpushevents tomain/master(and default manual runs), runs a rapid single-session repository scan in 3β5 minutes. - Deep Scan Mode (Default
cm find .): On weekly scheduled cron audits or when toggled viaworkflow_dispatch (deep_scan: true), runs an exhaustive concurrent file-by-file deep scan (--deep-workers=8) across all discovered source files.
- Differential PR Scan (
- Key Steps:
- Checks out code with
persist-credentials: false, authenticates via WIF (google-github-actions/auth@v2), configures.git/info/exclude, and runscm health --strictpreflight diagnostics. - Executes the event-appropriate autonomous scan (
--diff,--quick, or--deep-workers=8) and inspects the exit code (0clean or1findings threshold vs.10β60setup/capacity errors). - Exports native OASIS SARIF v2.1.0 (
cm report -f sarif > results.sarif) andcodemender-findings.jsonartifact (filtering out[LEGACY / UNTOUCHED]) strictly when the scan completed (steps.scan.outputs.completed == 'true'), preventing aborted runs from uploading empty SARIF reports. - Publishes formatted Markdown summary tables to
$GITHUB_STEP_SUMMARY. - Ingests findings into GitHub Code Scanning via
github/codeql-action/upload-sarif@v4whenresults.sarifis non-empty (!cancelled() && hashFiles('results.sarif') != '').
- Checks out code with
- Target Audience: Public & Open-Source Repositories (Responsible Disclosure Mode).
- Trigger: Nightly scheduled runs (
0 3 * * *) or manual dispatch (workflow_dispatch) with optional finding ID target. - Key Features:
- Clones repository with full Git history (
fetch-depth: 0,persist-credentials: false), pinsproject_pathsto$GITHUB_WORKSPACE, and validates readiness viacm health --strict. - Resumes instantly without re-scanning by importing
codemender-findings.json(cm report import -f ...), falling back tocm find . --quickonly when no cached findings exist. - Synthesizes security patches via
cm fix <id> --sandbox=false --yes --bypass-warning < /dev/null(preserving cumulative edits with--no-resetin batch mode). - Purges internal
.cm_project,.exploit/, and temporary metadata so commits strictly touch production code. - Generates dynamic, context-aware PR titles (
π‘οΈ [CodeMender] Fix: <Title>orπ‘οΈ [CodeMender] Fix Finding <ID>). - Submits an automated, review-ready Pull Request (
peter-evans/create-pull-request@v8) linking to GitHub Code Scanning SARIF alerts without exposing raw attack vectors publicly.
- Clones repository with full Git history (
- Target Audience: Private Repositories & Enterprise Organizations (Full Audit Evidence Mode).
- Trigger: Nightly scheduled runs (
0 3 * * *) or manual dispatch (workflow_dispatch) with optional finding ID target. - Key Features:
- Everything in the public remediation workflow, plus dynamic PoC exploit verification (
cm verify <id> --no-reset) prior to patch generationβautomatically skippingcm fixif verification marks an unexploitable finding asDISMISSED. - Detailed Context PR Titles: Displays precise vulnerability headline and severity (e.g.
π‘οΈ [CodeMender] Fix: SQL Injection in User Authentication Route (CRITICAL)). - Structured Evidence Breakdown Table: Renders complete Finding ID, Severity, CWE category, Headline, and exact file/line coordinates directly in the PR description.
- Embedded Verification Evidence (Zero Repo Pollution): Embeds CodeMender's
.exploit/audit artifacts (REPORT.md,PLAN.md,exploit.sh) inside collapsible sections of the PR description and archives them as a workflow artifact (codemender-verification-evidence), while excluding exploit scripts from Git commits.
- Everything in the public remediation workflow, plus dynamic PoC exploit verification (
- Least-Privilege GitHub Permissions & Credential Hygiene:
- Scanning job strictly uses
contents: read,id-token: write,security-events: write, andactions: read(required by CodeQL SARIF uploader on private repositories). - Remediation job uses
contents: write,id-token: write, andpull-requests: write. - All checkouts set
persist-credentials: falseso GitHub tokens are never persisted in.git/configwhile autonomous agents inspect the workspace.
- Scanning job strictly uses
- Orthogonal Sandbox & Policy Boundaries:
- Although
--sandbox=falsedisables Linux user-namespace isolation inside unprivileged CI containers, CodeMender continues to enforce workspace path boundaries (project_paths) and command denylists (command_policy.yaml) unless--allow-all-pathsor--allow-all-commandsis explicitly passed.
- Although
- Untrusted Fork & Bot PR Guardrails:
- Restrict WIF token issuance with attribute condition:
assertion.repository == '${GITHUB_ORG}/${GITHUB_REPO}'. - The scan workflow includes a job-level
if:condition that skips untrusted fork Pull Requests anddependabot[bot]PRs where repository WIF secrets are unavailable.
- Restrict WIF token issuance with attribute condition:
- Concurrency & Timeout Controls:
- Workflows enforce explicit
timeout-minutesbounds andconcurrencygroups to prevent runaway runner billing and branch merge collisions.
- Workflows enforce explicit
Distributed under the Apache License, Version 2.0.