A collection of +180 reusable WebAssembly modules for building composable CI/CD pipelines with FluentCI fluentci.io/modules
modules security cosign README.md
9.8 kB · 223 lines
Markdown
at main

Cosign #

Sign OCI images and release files, then enforce signature verification in CI/CD. Implemented in PureScript as a typed Wasm component for FluentCI v0.17.3+. Install the native CLI with setup-cosign. Blob operations target Cosign 3.x Sigstore bundles.

fluentci run setup-cosign setup --version 3.1.4
fluentci run cosign sign --run-dir /tmp/sign-image --image registry.example/app@sha256:DIGEST
fluentci run cosign verify --run-dir /tmp/verify-image \
  --image registry.example/app@sha256:DIGEST \
  --certificate-identity https://github.com/org/repo/.github/workflows/release.yml@refs/heads/main \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com
fluentci run cosign sign-blob --run-dir /tmp/sign-file \
  --file dist/app.tar.gz --bundle dist/app.sigstore.json
fluentci run cosign verify-blob --run-dir /tmp/verify-file \
  --file dist/app.tar.gz --bundle dist/app.sigstore.json \
  --certificate-identity https://github.com/org/repo/.github/workflows/release.yml@refs/heads/main \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

sign and sign-blob use ambient OIDC credentials unless --key selects a local key, an env:// reference, or supported KMS URI. Signing skips confirmation prompts and can publish to a transparency log; image signing also writes to its registry. Configure CI OIDC permissions (for example GitHub id-token: write), registry authentication, and key passwords through the runner environment. Never place secret key material or tokens in module arguments.

verify and verify-blob require exact expected certificate identity and issuer. verify-key and verify-blob-key instead require --key with the public key or KMS reference. Verification keeps native transparency-log and certificate checks; errors fail the pipeline. Prefer immutable image digests. run accepts literal arguments for additional Cosign commands; version reports the installed CLI.

Every call requires a fresh --run-dir; optional --project selects its working directory. Local input files and verification bundles are checked before starting the command. Output bundle parent directories must exist. Declare output bundles with --artifacts NAME=PATH to collect their sizes and SHA-256 in the report. Returns a typed execution result with outcome, report, stdout, and stderr paths; nonzero exits propagate as failures. Credentials remain inherited from the host.

The adapter accepts Linux, macOS, FreeBSD, NetBSD, and OpenBSD hosts with an installed native Cosign; repository availability still limits BSD installations. See COMPONENT.md and OPTIONS.md for named arguments, descriptions, and return types.

Cosign documentation · MIT License.

Setup component dependency #

This module declares setup-cosign as typed native component dependencies. FluentCI v0.17.3+ resolves their source references while building and composes them into the published Wasm. Consumers need no relative source paths. Available tools are reused; missing prerequisites invoke setup with default arguments. Explicit executable overrides remain caller-managed. Configure pinned versions or privileged/custom installations in an earlier setup step. See dependency behavior and publishing for command-specific prerequisites, validation, credential skips, and CI coverage.

Compose this module from code #

Requires FluentCI 0.17.6 or newer for generated pipeline bindings. From your caller module's directory, add the dependency:

fluentci add cosign --path /path/to/fluentci-modules/security/cosign

For a published module, use fluentci add @fluentci.io/cosign@VERSION with an available version. Commit the caller's manifest and lockfile. FluentCI generates named bindings from the installed component's WIT; no handwritten FFI or CLI subprocess is needed. Include generated source directories in the caller's SDK project. The callee can use a different SDK from the caller.

Verify an OCI image signature against an exact keyless identity and issuer; fail the pipeline on verification errors.

Replace the sample organization, paths and identifiers with your own. Configure credentials through your CI secret provider before running authenticated operations. Optional arguments use the callee's defaults, and public list fields use comma-separated strings. See COMPONENT.md for argument descriptions and return types.

These examples use the generated composition API and builder chaining in FluentCI 0.17.6; full cross-SDK compilation and execution coverage is still pending. See composition support and limitations.

PureScript #

module Main where

import Prelude
import Effect (Effect)
import FluentCI.Flow as Flow
import FluentCI.Modules.Cosign as Cosign

run :: Effect String
run =
  Flow.pipeline "cosign-verify"
    # Flow.workdir "."
    # Cosign.verify (Cosign.verifyArgs { "certificateIdentity": "https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", "certificateOidcIssuer": "https://token.actions.githubusercontent.com", "image": "ghcr.io/acme/api:1.0.0" })
    # Flow.map (\result -> result.reportPath)
    # Flow.run

Gleam #

import fluentci/flow
import fluentci_modules/cosign

pub fn run() -> String {
  flow.pipeline("cosign-verify")
  |> flow.workdir(".")
  |> cosign.verify(cosign.verify_args("https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", "https://token.actions.githubusercontent.com", "ghcr.io/acme/api:1.0.0"))
  |> flow.map(fn(result) { result.report_path })
  |> flow.run
}

Use Gleam's JavaScript target for the Wasm guest. BEAM escripts used for repository automation are separate from component guests.

Elixir #

defmodule Main do
  use FluentCI.Plugin
  alias FluentCI.Flow
  alias FluentCI.Modules.Cosign

  defplugin run do
    Flow.pipeline("cosign-verify")
    |> Flow.workdir(".")
    |> Cosign.verify(%{"certificate_identity" => "https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", "certificate_oidc_issuer" => "https://token.actions.githubusercontent.com", "image" => "ghcr.io/acme/api:1.0.0"})
    |> Flow.stdout()
  end
end

Elixir compiles this sequence to Rust/Wasm. Its initial Flow API does not yet provide the typed result callbacks or cleanup combinators of the other examples.

ClojureScript #

(ns main.plugin
  (:require [fluentci.flow :as flow]
            [fluentci-modules.cosign :as cosign]))

(defn run []
  (-> (flow/pipeline "cosign-verify")
      (flow/workdir ".")
      (cosign/verify {:certificateIdentity "https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", :certificateOidcIssuer "https://token.actions.githubusercontent.com", :image "ghcr.io/acme/api:1.0.0"})
      flow/run!))

ReScript #

let run = (): string =>
  Flow.pipeline("cosign-verify")
  ->Flow.workdir(".")
  ->FluentciModulesCosign.verify(FluentciModulesCosign.verifyArgs(~certificateIdentity="https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", ~certificateOidcIssuer="https://token.actions.githubusercontent.com", ~image="ghcr.io/acme/api:1.0.0"))
  ->Flow.map(result => result.reportPath)
  ->Flow.run

Python #

from fluentci.flow import pipeline
from fluentci_modules import cosign


def run() -> str:
    return (
        pipeline("cosign-verify")
        .workdir(".")
        .pipe(cosign.verify, {"certificate_identity": "https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0", "certificate_oidc_issuer": "https://token.actions.githubusercontent.com", "image": "ghcr.io/acme/api:1.0.0"})
        .map(lambda result: result.report_path)
        .run()
    )

TypeScript #

import * as flow from "./fluentci_modules/flow";
import * as cosign from "./fluentci_modules/cosign/index";

export function run(): string {
  return flow.pipeline("cosign-verify")
    .workdir(".")
    .pipe(cosign.verify, {"certificateIdentity":"https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.0.0","certificateOidcIssuer":"https://token.actions.githubusercontent.com","image":"ghcr.io/acme/api:1.0.0"})
    .map(result => result.reportPath)
    .run();
}

Python and TypeScript use FluentCI builder chains: .pipe(module.function, args) composes generated module functions with .workdir, .env, and .exec. Functions return a pipeline carrying their typed result. Use a generated result callback (With/_with, or a callback argument in TypeScript/Python) when a later module needs a preceding result; use Flow's map operation to select a result field. Execution begins at run (or the Elixir plugin terminal), in declared order.

Exported functions #

Function Purpose
run Run arbitrary Cosign commands with literal arguments.
version Report the installed Cosign version.
sign Sign an OCI image using a key or ambient CI OIDC credentials; publish the signature to its registry.
sign_blob Sign a local release artifact and write its Sigstore verification bundle.
verify Verify an OCI image signature against an exact keyless identity and issuer; fail the pipeline on verification errors.
verify_key Verify an OCI image signature against an explicit public key or KMS key.
verify_blob Verify a release artifact and Sigstore bundle against an exact keyless identity and issuer.
verify_blob_key Verify a release artifact and Sigstore bundle against an explicit public key or KMS key.