Chainloop Documentation
repository·main·Indexed 20 days ago
https://github.com/chainloop-dev/chainloopChainloop is an open-source evidence store for Software Supply Chain attestations, SBOMs, and security reports. It features an Artifact Content Addressable Storage (CAS) Proxy for immutable artifact management via gRPC, a Go-based CLI for operator tasks and attestation crafting, and a plugin system with integrations for Dependency-Track, Discord webhooks, and GUAC.
What's inside Chainloop
- Chainloop WASM Policy SDKs allow you to write validation rules (policies) in Go or JavaScript/TypeScript that compile to WebAssembly (WASM). These policies run automatically when artifacts—such as SBOMs, attestations, or evidence files—are uploaded to Chainloop. The SDKs provide a secure execution environment and high-level APIs to access uploaded material, make HTTP calls, and explore the artifact graph.
Overview of Artifact Content Addressable Storage (CAS) Proxy
mainThe Artifact CAS Proxy is a service that sits in front of storage backends (currently supporting OCI storage) to ensure that uploaded artifacts are immutable and uniquely identifiable by their content digest (
sha256sum).Key technical details:
- API: Implements a bytestream gRPC service for efficient streaming over HTTP/2.
- Architecture: Built with Go, leveraging protocol buffers, gRPC, wire for dependency injection, and the Kratos framework for middleware and configuration.
- Multi-tenancy: Achieved by retrieving OCI repository credentials (path + key pair) from a secret storage backend at runtime.
Use the Artifact Content Addressable Storage (CAS) Client
mainThe CAS Client is a bytestream gRPC client used to communicate with the Artifact Storage Proxy (
/app/artifact-cas/). It allows for managing artifacts using content-addressable storage principles. Currently, the client supports two primary operations:- Download: Retrieve artifacts using their content digest (specifically
sha256). - Upload: Send artifact data to the storage proxy.
The client implements the
google.golang.org/api/transport/bytestreaminterface for efficient data transfer.// The client is a bytestream gRPC client supporting: // - Download by content digest (sha256) // - Upload methods- Download: Retrieve artifacts using their content digest (specifically
Dependency-Track fan-out Plugin overview
mainThe Dependency-Track fan-out Plugin is a Chainloop plugin that automatically sends CycloneDX Software Bill of Materials (SBOM) to a Dependency-Track instance. This allows for automated security analysis and dependency tracking as part of your supply chain workflow.Use the Chainloop CLI for management and attestation
mainThe Chainloop CLI is a Go-based client used for two primary workflows:
- Operator Management Tasks: Operating on the control plane and uploading/downloading artifacts to the artifact proxy (CAS).
- Attestation Crafting Process: Performing the attestation process within a CI/CD system.
The CLI communicates with the control plane and Artifact CAS APIs via gRPC and integrates with
cosign,in-toto,DSEE, andSLSAfor attestation tasks.Manage Artifact CAS backends
mainThechainloop cas-backendcommand group allows you to manage the Content Addressable Storage (CAS) backends used by your organization. You can add, delete, list, and update different types of storage backends including AWS S3, Azure Blob, and OCI registries.Configure AuthN/AuthZ for the Artifact CAS Proxy
mainThe Artifact CAS API requires a JSON Web Token (JWT) for every request. The token must contain:
- The allowed operation (e.g.,
downloadorupload). - A reference to the location where the CAS can find the target OCI credentials.
Tokens are signed by the Control Plane using a private key and verified by the CAS using a pre-configured public key. Future support for JWKS endpoints is planned to facilitate credential rotation.
- The allowed operation (e.g.,
Identify Control Plane system dependencies
mainThe Control Plane relies on four primary external components:
- OpenID Connect (OIDC) provider: Used for authentication (e.g., Google, GitHub, or Auth0).
- PostgreSQL: Used as the persistence layer.
- Secret Storage Backend: Used for sensitive information like OCI registry credentials. Supported backends include Hashicorp Vault, AWS Secret Manager, and GCP Secret Manager.
- Artifact CAS: Chainloop's own Artifact Content Addressable Storage, used to forward attestations to the user's storage backend (e.g., an OCI registry).
Note: The control plane does not store artifacts directly; it forwards them via the Artifact CAS.
Understanding Chainloop FanOut plugins
mainChainloop currently supports a single plugin type called fanOut plugins. These plugins implement logic that is triggered whenever attestations or materials are received by the system.
Common use cases for FanOut plugins include:
- Sending notifications (e.g., to Slack).
- Uploading attestations to a storage backend.
- Sending Software Bill of Materials (SBOMs) to external analysis tools like Dependency-Track.
Core concepts of the WASM Policy SDK
mainWhen developing policies using the WASM SDK, you will interact with several key patterns and functions:
- ExecutePolicyTyped: The primary type-safe policy function that handles automatic I/O for your policy logic.
- Result Builders: Used to construct the outcome of a policy evaluation:
Success(): Indicates the policy passed without issues.AddViolation(): Records a specific policy violation.AddViolationf(): Records a formatted policy violation.
- Logging: Provides debug output during policy execution via
LogInfo()andLogError(). - Result Checking: Use
HasViolations()to inspect the state of the result and determine if the policy failed.
Follow TinyGo compatibility constraints for policies
mainBecause the SDK runs in a WASM environment via TinyGo, you must adhere to specific type constraints to avoid runtime panics (like
wasm error: unreachable).Supported Types:
- Flat structs with simple types.
- Slices and maps with
stringkeys. json.Unmarshalfor parsing.
Unsupported/Avoid:
- Generics (limited support).
- Complex nested types containing interfaces.
- Maps with
anyvalues.
Recommended Pattern: Use simple, flat structs for data modeling.
// Good: Simple struct type Component struct { Name string `json:"name"` Version string `json:"version"` Hashes []Hash `json:"hashes"` } // Avoid: Complex types type Complex struct { Metadata any `json:"metadata"` Data map[string]any `json:"data"` }Use global variables for credentials in complex deployments
mainIn scenarios where multiple sub-charts need to connect to the same PostgreSQL instance, instead of repeating credentials for every sub-chart (e.g.,
subchart1.postgresql.auth.password), use theglobalobject. This makes the credentials available to all sub-charts automatically.global.postgresql.auth.username=testuser global.postgresql.auth.password=testpass global.postgresql.auth.database=testdb