Documentation
¶
Overview ¶
Package intoto implements a parser and a statement variant for attestations in the in-toto format.
Index ¶
- type Parser
- type Statement
- func (s *Statement) AddSubject(sbj attestation.Subject)
- func (s *Statement) GetPredicate() attestation.Predicate
- func (s *Statement) GetPredicateType() attestation.PredicateType
- func (s *Statement) GetSubjects() []attestation.Subject
- func (s *Statement) GetType() string
- func (s *Statement) GetVerification() attestation.Verification
- func (s *Statement) MarshalJSON() ([]byte, error)
- func (s *Statement) ParsePredicate() error
- func (s *Statement) ToJson() ([]byte, error)
- func (s *Statement) WriteJson(w io.Writer) error
- type StatementOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct{}
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
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
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 ¶
ParsePredicate reparses the underlying intoto predicate and regenerates the statement's predicate.
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