Skip to main content
Experimental Feature - WASM Policy EngineThese examples are specifically for writing WASM policies using Chainloop’s experimental WASM policy engine. The WASM policy engine is NOT the default policy engine in Chainloop.
  • Default engine: Rego-based (recommended for most users)
  • WASM engine: Experimental alternative for Go/JavaScript policies
  • Currently supported languages: Go and JavaScript only
  • Status: Experimental preview - APIs may change in future releases
For the default Rego-based policy engine, see Writing Custom Policies.

Common Patterns

Required Fields Validation

Ensure critical fields are present and non-empty.

Allowlist/Blocklist Validation

Check values against approved or forbidden lists.

Nested Structure Validation

Validate arrays of objects (SBOM components, attestation subjects).

External API Validation

Verify data against external sources.
Important HTTP Request Notes:
  • Always use skip() when external APIs are unavailable - don’t fail policies due to network issues
  • All domains are blocked by default except www.chainloop.dev and www.cisa.gov
  • Use --allowed-hostnames flag to allowlist domains: --allowed-hostnames registry.npmjs.org

Complete Examples

SBOM License Validation

Validate component licenses in a CycloneDX SBOM.
Test data (sbom.json):
Test:

Attestation Signature Validation

Validate in-toto attestation has git commit subjects.

HTTP API Integration

Verify package version exists in npm registry.
Domain Allowlisting RequiredBy default, all HTTP requests are blocked except for:
  • www.chainloop.dev
  • www.cisa.gov
You must explicitly allowlist any domains your policy needs to access using the --allowed-hostnames flag:
In production, configure allowed hostnames in your policy engine settings.
Test:

Artifact Discovery

Check if related attestations have policy violations.

Next Steps

Go SDK Guide

Learn how to use the Go SDK

JavaScript SDK Guide

Learn how to use the JavaScript SDK