builtins

package
v1.138.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDiscoverHostFunctions

func CreateDiscoverHostFunctions(conn *grpc.ClientConn) []extism.HostFunction

CreateDiscoverHostFunctions creates Extism host functions for the discover builtin. Returns two host functions - one for each supported namespace: 1. "env" namespace for Go (TinyGo) policies 2. "extism:host/user" namespace for JavaScript policies

func RegisterDiscoverBuiltin

func RegisterDiscoverBuiltin(conn *grpc.ClientConn) error

RegisterDiscoverBuiltin registers chainloop's Discover endpoint as a builtin Rego function with signature:

chainloop.discover(digest, kind)

The result holds the references of all the pages of the API, up to a cap. When the read stops before the last page, the result has "truncated": true. This happens when the cap is reached, or when the control plane repeats its next cursor.

For instance, to get the references for an CONTAINER_IMAGE material, and fail if any of them is an attestation with policy violations: ```

violations contains msg if {
  digest := sprintf("sha256:%s",[input.chainloop_metadata.digest.sha256])
  discovered := chainloop.discover(digest, "")

  some ref in discovered.references
  ref.kind == "ATTESTATION"
  ref.metadata.hasPolicyViolations == "true"

  msg:= sprintf("attestation with digest %s contains policy violations [name: %s, project: %s, org: %s]", [ref.digest, ref.metadata.name, ref.metadata.project, ref.metadata.organization])
}

```

Types

type DiscoverResult added in v1.131.0

type DiscoverResult struct {
	*v1.ReferrerItem
	// Truncated is true when the read stopped before the last page of references: either the
	// page cap was reached, or the control plane repeated its next cursor (it ignores the cursor)
	Truncated bool `json:"truncated"`
}

DiscoverResult is the referrer with the references of all the pages read. It serializes to the same shape as a ReferrerItem, plus the truncated field.

func (DiscoverResult) MarshalJSON added in v1.138.0

func (r DiscoverResult) MarshalJSON() ([]byte, error)

MarshalJSON always writes references as an array, an empty one when there are no references. The proto field omits an empty list, and then a policy that counts the references gets an undefined value instead of 0. Rego converts the result through this JSON too.

type DiscoverService

type DiscoverService struct {
	// contains filtered or unexported fields
}

DiscoverService wraps the gRPC discover functionality to be shared across engines

func NewDiscoverService

func NewDiscoverService(conn *grpc.ClientConn) *DiscoverService

NewDiscoverService creates a new discover service

func (*DiscoverService) Discover

func (s *DiscoverService) Discover(ctx context.Context, digest, kind string) (*DiscoverResult, error)

Discover calls the DiscoverPrivate gRPC endpoint to get artifact graph data. It follows the pagination cursor and merges the references of all pages, up to discoverMaxPages requests.

A control plane without pagination support ignores the pagination request and returns all the references in one response with no next cursor, so the read ends after the first page. A next cursor that does not advance also ends the read, so the same page is never merged twice, and marks the result as truncated.

A digest with no node in the graph gives a result with no references. A NotFound on a later page is still an error, because the node existed for the first page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL