← Back to Platform
Developer Experience · CI/CD

CI/CD Native Integration
A security scan on every PR.

One workflow file. Trivy checks dependencies, infrastructure-as-code and committed secrets on every pull request, results show in your Git provider's security view, and LenzAI keeps them next to the repo. Only published tools, pinned, and it never fails your build.

1workflow file
3scan types
3CI providers
100%pinned actions
How It Works

One file. Real scanners. Results where you already look.

01

PR Opened

A pull request is opened, or code is pushed to main, master or develop.

02

Trivy Scans

Dependencies (known CVEs), Terraform/Kubernetes/Docker misconfigurations, and secrets committed by mistake.

03

Code Scanning

Results go to GitHub's Security tab (SARIF) on public repos, or private repos with Advanced Security.

04

In LenzAI

With a CI key saved as a repo secret, findings also appear next to the repo in LenzAI.

Integration

Works with your CI. Already.

Copy the workflow file and commit it, or let LenzAI open the pull request for you on GitHub. Add a LENZAI_CI_KEY secret to send results to LenzAI; without it the scan still runs.

.github/workflows/lenzai-security.yml
# LenzAI security scan: Trivy checks dependencies, IaC and secrets on every PR and push.
# Results appear under Security → Code scanning (public repos, or private repos with GitHub Advanced
# Security; otherwise that step is skipped without failing). To see them in LenzAI, create a CI key
# in LenzAI (Repos → this repo → CI key) and save it as the repository secret LENZAI_CI_KEY.
name: LenzAI security scan

on:
  pull_request:
  push:
    branches: [main, master, develop]
  workflow_dispatch:

permissions:
  contents: read
  security-events: write
  actions: read     # upload-sarif reads the run on private repos

concurrency:
  group: lenzai-security-${{ github.ref }}
  cancel-in-progress: true

jobs:
  scan:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    env:
      LENZAI_CI_KEY: ${{ secrets.LENZAI_CI_KEY }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Trivy (dependencies, IaC, secrets)
        uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
        with:
          scan-type: fs
          scanners: vuln,misconfig,secret
          severity: CRITICAL,HIGH,MEDIUM
          ignore-unfixed: true
          format: sarif
          output: trivy.sarif
          version: v0.76.1

      - name: Show results in GitHub code scanning
        if: always() && hashFiles('trivy.sarif') != ''
        continue-on-error: true   # private repos without code scanning still pass
        uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
        with:
          sarif_file: trivy.sarif
          category: lenzai-trivy

      - name: Summarise for LenzAI
        if: always() && env.LENZAI_CI_KEY != ''
        uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
        with:
          scan-type: fs
          scanners: vuln,misconfig,secret
          severity: CRITICAL,HIGH,MEDIUM
          ignore-unfixed: true
          format: json
          output: trivy.json
          skip-setup-trivy: true

      - name: Send results to LenzAI
        if: always() && env.LENZAI_CI_KEY != '' && hashFiles('trivy.json') != ''
        env:
          PR_NUMBER: ${{ github.event.pull_request.number }}
        run: |
          jq -c --arg pr "$PR_NUMBER" --arg sha "$GITHUB_SHA" '{prNumber: $pr, commit: $sha, findings: ([.Results[]? as $r | (($r.Vulnerabilities // [])[] | {severity: .Severity, pillar: "Vulnerabilities", resource: "\($r.Target) \(.PkgName)@\(.InstalledVersion)", message: "\(.VulnerabilityID) \(.Title // "")"}), (($r.Misconfigurations // [])[] | {severity: .Severity, pillar: "Misconfiguration", resource: "\($r.Target):\(.CauseMetadata.StartLine // 0)", message: "\(.ID) \(.Title)"}), (($r.Secrets // [])[] | {severity: .Severity, pillar: "Secrets", resource: "\($r.Target):\(.StartLine)", message: .Title})] | .[:200])}' trivy.json > lenzai.json
          curl -sS --fail-with-body -X POST "https://YOUR-LENZAI-HOST/api/ci/scan-result" \
            -H "Authorization: Bearer $LENZAI_CI_KEY" -H "Content-Type: application/json" --data @lenzai.json
.gitlab-ci.yml (add this job)
# LenzAI security scan: Trivy checks dependencies, IaC and secrets on merge requests and the default branch.
# To also see results in LenzAI, add a masked CI/CD variable LENZAI_CI_KEY with your LenzAI CI key.
lenzai-security-scan:
  stage: test
  image:
    name: aquasec/trivy:0.76.1
    entrypoint: [""]
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  allow_failure: true
  script:
    - trivy fs --scanners vuln,misconfig,secret --severity CRITICAL,HIGH,MEDIUM --ignore-unfixed --format json --output trivy.json .
    - trivy convert --format table trivy.json
    - |
      if [ -n "$LENZAI_CI_KEY" ]; then
        apk add --no-cache curl jq >/dev/null
        jq -c --arg pr "$CI_MERGE_REQUEST_IID" --arg sha "$CI_COMMIT_SHA" '{prNumber: $pr, commit: $sha, findings: ([.Results[]? as $r | (($r.Vulnerabilities // [])[] | {severity: .Severity, pillar: "Vulnerabilities", resource: "\($r.Target) \(.PkgName)@\(.InstalledVersion)", message: "\(.VulnerabilityID) \(.Title // "")"}), (($r.Misconfigurations // [])[] | {severity: .Severity, pillar: "Misconfiguration", resource: "\($r.Target):\(.CauseMetadata.StartLine // 0)", message: "\(.ID) \(.Title)"}), (($r.Secrets // [])[] | {severity: .Severity, pillar: "Secrets", resource: "\($r.Target):\(.StartLine)", message: .Title})] | .[:200])}' trivy.json > lenzai.json
        curl -sS --fail-with-body -X POST "https://YOUR-LENZAI-HOST/api/ci/scan-result" -H "Authorization: Bearer $LENZAI_CI_KEY" -H "Content-Type: application/json" --data @lenzai.json
      fi
  artifacts:
    when: always
    paths: [trivy.json]
    expire_in: 30 days
bitbucket-pipelines.yml
# LenzAI security scan: Trivy checks dependencies, IaC and secrets on pull requests.
# To also see results in LenzAI, add a secured repository variable LENZAI_CI_KEY with your LenzAI CI key.
pipelines:
  pull-requests:
    '**':
      - step:
          name: LenzAI security scan
          image: aquasec/trivy:0.76.1
          script:
            - trivy fs --scanners vuln,misconfig,secret --severity CRITICAL,HIGH,MEDIUM --ignore-unfixed --format json --output trivy.json .
            - trivy convert --format table trivy.json
            - >
              if [ -n "$LENZAI_CI_KEY" ]; then
              apk add --no-cache curl jq >/dev/null &&
              jq -c --arg pr "$BITBUCKET_PR_ID" --arg sha "$BITBUCKET_COMMIT" '{prNumber: $pr, commit: $sha, findings: ([.Results[]? as $r | (($r.Vulnerabilities // [])[] | {severity: .Severity, pillar: "Vulnerabilities", resource: "\($r.Target) \(.PkgName)@\(.InstalledVersion)", message: "\(.VulnerabilityID) \(.Title // "")"}), (($r.Misconfigurations // [])[] | {severity: .Severity, pillar: "Misconfiguration", resource: "\($r.Target):\(.CauseMetadata.StartLine // 0)", message: "\(.ID) \(.Title)"}), (($r.Secrets // [])[] | {severity: .Severity, pillar: "Secrets", resource: "\($r.Target):\(.StartLine)", message: .Title})] | .[:200])}' trivy.json > lenzai.json &&
              curl -sS --fail-with-body -X POST "https://YOUR-LENZAI-HOST/api/ci/scan-result" -H "Authorization: Bearer $LENZAI_CI_KEY" -H "Content-Type: application/json" --data @lenzai.json;
              fi
          artifacts:
            - trivy.json
Security

A key that can only report results.

The scan itself needs no LenzAI credentials at all. To send results to LenzAI, each repository gets its own CI key that can do exactly one thing: post that repository's scan results.

  1. 1Create the key in LenzAI: Repos → your repository → CI key. It's shown once.
  2. 2Save it as the repository secret LENZAI_CI_KEY.
  3. 3The key can only post scan results for that one repository. It can't read code, change settings or reach other repos.
  4. 4LenzAI stores only a hash of it. Replace it any time; the old one stops working at once.
Send results step
- name: Send results to LenzAI
  if: always() && env.LENZAI_CI_KEY != ''
  run: |
    curl -sS --fail-with-body -X POST "$LENZAI_URL/api/ci/scan-result" \
      -H "Authorization: Bearer $LENZAI_CI_KEY" --data @lenzai.json
  # Skipped when the secret isn't set: the scan still runs
✅ Least privilege. One key per repository, write-only for scan results, hashed at rest, replaceable in one click.
Included Out of the Box

Good defaults.
Nothing extra to configure.

Pinned Actions

Every action is pinned to a full commit SHA, so a compromised tag can't change what runs.

SARIF Integration

Findings appear in GitHub's Security tab (public repos, or private with Advanced Security); otherwise the step is skipped without failing.

Cancel on Push

New commits cancel the stale scan via a concurrency group. No wasted minutes.

Dependency CVEs

Known vulnerabilities in npm, pip, Maven, Go, NuGet and more, with fixed versions only by default.

IaC Misconfigurations

Terraform, Kubernetes, Dockerfile and CloudFormation checks, like SSH open to the internet.

Never Blocks by Default

The scan reports; it doesn't fail the build. Set exit-code: 1 when you're ready to gate merges.

Secrets Detection

Cloud keys, tokens and private keys committed by mistake, with file and line.

Works Without LenzAI

No LenzAI key needed to scan. Add one later to see results next to the repo in LenzAI.

Configuration Reference

The options that matter.

Set these on the Trivy step's with: block (they're trivy-action inputs).

OptionDefaultDescription
severityCRITICAL,HIGH,MEDIUMWhich severities to report. Add LOW for everything.
scannersvuln,misconfig,secretDependency CVEs, IaC misconfigurations and committed secrets. Drop any you don't want.
ignore-unfixedtrueOnly report vulnerabilities that have a fixed version you can upgrade to.
exit-code0Set to 1 to fail the job (and block the merge) when anything is found.
trivyignores.trivyignoreFile listing finding IDs you've accepted, one per line.
skip-dirsnoneDirectories to leave out, such as test fixtures or vendored code.
Get Started

Scan every PR,
starting today.

Commit one workflow file and open a pull request. Results appear in your Security tab, and in LenzAI with a CI key.

No credit card · Integrates with your existing CI in minutes

CloudLenz Platform

Every operational surface, one agentic layer.

Explore →