intoto

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Overview

Package intoto implements a parser and a statement variant for attestations in the in-toto format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct{}

func (*Parser) Parse

func (p *Parser) Parse(b []byte) (attestation.Statement, error)

func (*Parser) ParseBase64

func (p *Parser) ParseBase64(b []byte) (attestation.Statement, error)

type Statement

type Statement struct {
	PredicateType attestation.PredicateType `json:"predicateType"`
	Predicate     attestation.Predicate     `json:"predicate"`
	Type          string                    `json:"_type"`
	gointoto.Statement
}

Statement is the collector's in-toto statement. The exported fields are the JSON-facing ones; the embedded proto carries the subjects and the raw predicate as decoded, and its own type and predicate type fields are kept empty so they never render under their Go JSON names.

func NewStatement

func NewStatement(opts ...StatementOption) *Statement

func (*Statement) AddSubject

func (s *Statement) AddSubject(sbj attestation.Subject)

func (*Statement) GetPredicate

func (s *Statement) GetPredicate() attestation.Predicate

func (*Statement) GetPredicateType

func (s *Statement) GetPredicateType() attestation.PredicateType

func (*Statement) GetSubjects

func (s *Statement) GetSubjects() []attestation.Subject

GetSubjects returns the statement's subjects

func (*Statement) GetType added in v0.3.12

func (s *Statement) GetType() string

GetType returns the statement type URI. It shadows the embedded proto's getter, which reads the proto field this type keeps empty.

func (*Statement) GetVerification

func (s *Statement) GetVerification() attestation.Verification

GetVerifications returns the verifications from the underlying predicate

func (*Statement) MarshalJSON added in v0.3.12

func (s *Statement) MarshalJSON() ([]byte, error)

MarshalJSON renders the statement in its in-toto JSON form: _type, subject, predicateType and predicate. The embedded proto's fields are not rendered directly, which keeps its Go JSON names (type, predicate_type) out of the output whichever way the statement was built. Subjects are rendered with protojson for the same reason: encoding/json would use the proto's Go names (download_location, media_type) instead of the in-toto ones (downloadLocation, mediaType). An unset type is rendered as the in-toto statement type URI.

func (*Statement) ParsePredicate

func (s *Statement) ParsePredicate() error

ParsePredicate reparses the underlying intoto predicate and regenerates the statement's predicate.

func (*Statement) ToJson

func (s *Statement) ToJson() ([]byte, error)

ToJson returns a byte slice with the predicate in JSON

func (*Statement) WriteJson

func (s *Statement) WriteJson(w io.Writer) error

type StatementOption

type StatementOption func(*Statement)

var _ attestation.Subject = (*Subject)(nil)

func WithPredicate

func WithPredicate(pred attestation.Predicate) StatementOption

func WithSubject

func WithSubject(subjects ...*gointoto.ResourceDescriptor) StatementOption

Jump to

Keyboard shortcuts

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