Enforce slsa

From harness/harness-ai · View interactive version

Enforce slsa is an AI agent skill from the GitHub repository harness/harness-ai. Add an SLSA Verification (SlsaVerification) step to an existing Harness pipeline to verify SLSA provenance attestations and optionally enforce OPA policy sets on provenance data. Supports CI and CD (Deployment) including CI-only pipelines — append a Deploy stage via Phase 3b when verifying before de

How to use this skill

Skill file

Enforce SLSA

Add an SLSA Verification (SlsaVerification) step to an existing Harness pipeline. The step

verifies SLSA provenance attestations (when enabled) and optionally evaluates OPA policy sets against

provenance data.

This skill only works with existing pipelines — do not create standalone verification-only pipelines.

Prerequisites: SLSA provenance must already exist for the artifact (typically from a provenance

step via /generate-slsa — UI label SLSA Generation). Optional policy sets for provenance

enforcement (/create-policy, harness_list policy_set).

Supported stages: CI, CD (Deployment), and Security. CD requires a containerized step group.

Unlike SBOM enforcement, CI and CD both use SlsaVerification (no separate CD step type).

Guide the user through a step-by-step interactive wizard (same UX as /generate-slsa):


Interaction model (mandatory)

  1. One question per turn — use AskQuestion when available; otherwise numbered options with (Recommended).
  2. Opening message — add SLSA Verification; mention generation + optional policy prerequisites.
  3. Progress breadcrumb — after pipeline fetch:

Pipeline · Placement · Source · Details · Verify · Policy · Submit

  1. Record answers — running summary; do not re-ask unless the user changes direction.
  2. Fetch before configure — harness_get before placement/source questions.
  3. Show pipeline structure — highlight provenance (SLSA Generation) and connectors.
  4. Infer source from generation — when one provenance step exists (or identifier: slsageneration), reuse its source (map repo → image_path, lowercase → PascalCase types).
  5. Never guess image tags — default from generation step; ask if ambiguous.
  6. Confirm before write — summary + harness_update only after user confirms.
  7. Stop after update — after successful harness_update, provide a configuration summary and

point the user to /run-pipeline to execute. Do not call harness_execute, poll

executions, or run harness_diagnose in this skill (same pattern as /configure-repo-scan).

  1. CD on CI-only pipeline — do not reject CD verify; run Phase 3b to add Deploy stage + containerized group.
  2. Verify method must match generation — keyless ↔ keyless, keybased ↔ public key from same key pair.

Full phase prompts: references/interactive-wizard-flow.md.


Instructions

Wizard phases

| Phase | Breadcrumb | Action |

|-------|------------|--------|

| 0 | Pipeline | AskQuestion: pipeline URL ready? |

| 1 | Pipeline | Collect URL → harness_get |

| 2 | Pipeline | Display structure; note missing provenance (SLSA Generation) step |

| 3 | Placement | AskQuestion: after generation, CD before deploy, etc. |

| 3b | Placement (CD) | Service, env, infra, step group if new Deploy stage |

| 4 | Source | Infer from generation or pick registry tile |

| 5 | Source | Registry provider (Third-Party only) |

| 6 | Details | Connector (skip if obvious) |

| 7 | Details | Image / image_path (default from generation) |

| 8 | Verify | AskQuestion: verify attestation method |

| 9 | Policy | AskQuestion: policy set(s) or skip |

| 10 | Submit | AskQuestion: confirm pipeline update |

After Phase 10 confirm → insert step, harness_update, then provide summary (do not run the pipeline).

Supported stage types

| Stage type | Step type | Placement notes |

|------------|-------------|-----------------|

| CI | SlsaVerification | After provenance / slsageneration in the same stage |

| Deployment | SlsaVerification | Containerized step group; before deploy |

| Security | SlsaVerification | After generation when artifact is in registry |

CD edge case

If no Deployment stage and user chose CD verify:

No CD Deploy stage yet. We can add a Deployment stage with a containerized step group and

place SLSA Verification before deploy.

Run Phase 3b (service, environment, infrastructure, stepGroupInfra) — mirror /generate-slsa Phase 3b.

Use skills/security/generate-slsa/references/cd-containerized-step-group.md with SlsaVerification.

After the wizard — backend steps

Check prerequisites
  1. SLSA generation — pipeline contains type: provenance (SLSA Generation) or user confirms provenance exists.
  2. Policy sets (optional) — harness_list(resource_type="policy_set"). If user wants policy

enforcement and none exist, direct to /create-policy before continuing.

Extract context from pipeline YAML

From provenance step (if present — also match identifier: slsageneration), copy and transform:

| Generation | Verification |

|------------|--------------|

| source.type: docker | source.type: Docker |

| source.spec.repo | source.spec.image_path |

| source.spec.connector | source.spec.connector |

| spec.attestation | matching verify_attestation (private → public key for keybased) |

Generate SLSA verification step YAML

CI / Security — Docker Registry, keyless verify:

- step:
    identifier: slsaverification
    name: SLSA Verification
    type: SlsaVerification
    spec:
      source:
        type: Docker
        spec:
          connector: lavakush07
          image_path: lavakush07/easy-buggy-app:blog
      verify_attestation:
        type: keyless
        spec:
          oidcProvider: harness
    timeout: 15m

Key-based verify (generation used keybased + private key):

      verify_attestation:
        type: keybased
        spec:
          publicKey: account.cosign_public_key

If API validation rejects flat keyless / keybased, retry with nested cosign wrapper — see

references/slsa-verification-step.md.

Policy enforcement (Advanced tab — step-level enforce):

    enforce:
      policySets:
        - slsa_provenance_rules

No attestation verify (policy-only): omit verify_attestation.

CD Deploy — same step type inside containerized stepGroup; use <+artifact.image> for

image_path when verifying service artifacts.

Full provider mapping: references/slsa-verification-step.md.

Insert step into pipeline YAML
Update pipeline via MCP
harness_update
  resource_type: pipeline
  resource_id: <pipeline_identifier>
  org_id: <organization>
  project_id: <project>
  body: { yamlPipeline: "<updated pipeline YAML>" }

On validation errors, check PascalCase source.type, image_path vs repo, and verify_attestation

shape (prefer flat keyless; fallback nested cosign).

Provide summary

Report the results to the user (same pattern as /configure-repo-scan — do not execute the pipeline):

## SLSA Verification Configured

**Pipeline:** <pipeline_name>
**Step:** SLSA Verification (SlsaVerification)
**Location:** Stage "<stage_name>", <position>
**Source:** Docker — <connector> — <image_path>
**Verify attestation:** Keyless (Harness OIDC) — or as configured
**Policy sets:** <list or none>

**Pipeline URL:** https://app.harness.io/ng/account/<account_id>/module/ci/orgs/<org_id>/projects/<project_id>/pipelines/<pipeline_id>/pipeline-studio/

**Note:** Review the SLSA Verification step in Pipeline Studio to adjust Advanced settings.

### Next Steps
1. Run the pipeline via `/run-pipeline` to verify SLSA verification executes successfully
2. If the run fails, diagnose with `/debug-pipeline`
3. View verification outcome on the execution **Supply Chain** tab
4. If **Failed** due to policy deny, tune policies via `/create-policy`
5. Add generation with `/generate-slsa` if provenance was missing
6. Automate with `/create-trigger`

CD pipelines: note in the summary if runtime inputs (service artifact, environment, infrastructure)

will be required at run time — the user provides those via /run-pipeline or Harness UI Run.


Examples

Verify after SLSA Generation

/enforce-slsa
Add SLSA verification after slsa-generation — keyless verify, policy set slsa_prod_rules

CD before deploy

/enforce-slsa
Verify SLSA in deploy stage before K8s rolling deploy for easy-buggy-app:blog

Key-based verify (matches keybased generation)

/enforce-slsa
Verify SLSA with public key account.cosign_public_key — same image as generation step

Performance Notes


Troubleshooting

No SLSA Generation Step

Attestation Verification Failed

Wrong Image / No Provenance

Policy Evaluation Failed

YAML Validation Errors

CD Step Errors

User Chose CD on CI-Only Pipeline

Pipeline Run Failed

MCP Errors

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.