types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 13 Imported by: 19

README

Pluggable Types

Description

Rekor supports pluggable types (aka different schemas) for entries stored in the transparency log.

Currently supported types
  • Alpine Packages schema
    • Versions: 0.0.1
  • Helm Provenance Files schema
    • Versions: 0.0.1
  • In-Toto Attestations schema
    • Versions: 0.0.1
  • Java Archives (JAR Files) schema
    • Versions: 0.0.1
  • Rekord (default type) schema
    • Versions: 0.0.1
  • RFC3161 Timestamps schema
    • Versions: 0.0.1
  • RPM Packages schema
    • Versions: 0.0.1

Refer to Rekor docs for adding support for new types.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeMap sync.Map

TypeMap stores mapping between type strings and entry constructors entries are written once at process initialization and read for each transaction, so we use sync.Map which is optimized for this case

Functions

func CanonicalizeEntry added in v0.4.0

func CanonicalizeEntry(ctx context.Context, entry EntryImpl) ([]byte, error)

CanonicalizeEntry returns the entry marshalled in JSON according to the canonicalization rules of RFC8785 to protect against any changes in golang's JSON marshalling logic that may reorder elements

func DecodeEntry added in v0.2.0

func DecodeEntry(input, output interface{}) error

DecodeEntry maps the (abstract) input structure into the specific entry implementation class; while doing so, it detects the case where we need to convert from string to []byte and does the base64 decoding required to make that happen. This also detects converting from string to strfmt.DateTime

func ListImplementedTypes added in v0.3.0

func ListImplementedTypes() []string

ListImplementedTypes returns a list of all type strings currently known to be implemented

func NewProposedEntry added in v0.3.0

func NewProposedEntry(ctx context.Context, kind, version string, props ArtifactProperties) (models.ProposedEntry, error)

func PipeCloser added in v0.5.0

func PipeCloser(errClosers ...errCloser) func(err error) error

Types

type ArtifactProperties added in v0.3.0

type ArtifactProperties struct {
	ArtifactPath   *url.URL
	ArtifactHash   string
	ArtifactBytes  []byte
	SignaturePath  *url.URL
	SignatureBytes []byte
	PublicKeyPath  *url.URL
	PublicKeyBytes []byte
	PKIFormat      string
}

ArtifactProperties provide a consistent struct for passing values from CLI flags to the type+version specific CreateProposeEntry() methods

type BaseUnmarshalTester added in v0.5.0

type BaseUnmarshalTester struct{}

func (BaseUnmarshalTester) APIVersion added in v0.5.0

func (u BaseUnmarshalTester) APIVersion() string

func (BaseUnmarshalTester) AttestationKey added in v0.7.0

func (u BaseUnmarshalTester) AttestationKey() string

func (BaseUnmarshalTester) AttestationKeyValue added in v0.7.0

func (u BaseUnmarshalTester) AttestationKeyValue() (string, []byte)

func (BaseUnmarshalTester) Canonicalize added in v0.5.0

func (u BaseUnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error)

func (BaseUnmarshalTester) CreateFromArtifactProperties added in v0.5.0

func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error)

func (BaseUnmarshalTester) IndexKeys added in v0.5.0

func (u BaseUnmarshalTester) IndexKeys() ([]string, error)

func (BaseUnmarshalTester) NewEntry added in v0.5.0

func (u BaseUnmarshalTester) NewEntry() EntryImpl

func (BaseUnmarshalTester) Unmarshal added in v0.5.0

func (BaseUnmarshalTester) Validate added in v0.5.0

func (u BaseUnmarshalTester) Validate() error

type EntryFactory added in v0.2.0

type EntryFactory func() EntryImpl

EntryFactory describes a factory function that can generate structs for a specific versioned type

type EntryImpl

type EntryImpl interface {
	APIVersion() string                               // the supported versions for this implementation
	IndexKeys() ([]string, error)                     // the keys that should be added to the external index for this entry
	Canonicalize(ctx context.Context) ([]byte, error) // marshal the canonical entry to be put into the tlog
	Unmarshal(e models.ProposedEntry) error           // unmarshal the abstract entry into the specific struct for this versioned type
	AttestationKey() string                           // returns the key used to look up the attestation from storage (should be sha256:digest)
	AttestationKeyValue() (string, []byte)            // returns the key to be used when storing the attestation as well as the attestation itself
	CreateFromArtifactProperties(context.Context, ArtifactProperties) (models.ProposedEntry, error)
}

EntryImpl specifies the behavior of a versioned type

func NewEntry

func NewEntry(pe models.ProposedEntry) (EntryImpl, error)

NewEntry returns the specific instance for the type and version specified in the doc

type RekorType added in v0.2.0

type RekorType struct {
	Kind       string                 // this is the unique string that identifies the type
	VersionMap VersionEntryFactoryMap // this maps the supported versions to implementation
}

RekorType is the base struct that is embedded in all type implementations

func (*RekorType) SupportedVersions added in v0.3.0

func (rt *RekorType) SupportedVersions() []string

func (*RekorType) VersionedUnmarshal added in v0.2.0

func (rt *RekorType) VersionedUnmarshal(pe models.ProposedEntry, version string) (EntryImpl, error)

VersionedUnmarshal extracts the correct implementing factory function from the type's version map, creates an entry of that versioned type and then calls that versioned type's unmarshal method

type SemVerEntryFactoryMap added in v0.2.0

type SemVerEntryFactoryMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SemVerEntryFactoryMap implements a map that allows implementations to specify their supported versions using semver-compliant strings

func (*SemVerEntryFactoryMap) Count added in v0.2.0

func (s *SemVerEntryFactoryMap) Count() int

func (*SemVerEntryFactoryMap) GetEntryFactory added in v0.2.0

func (s *SemVerEntryFactoryMap) GetEntryFactory(version string) (EntryFactory, error)

func (*SemVerEntryFactoryMap) SetEntryFactory added in v0.2.0

func (s *SemVerEntryFactoryMap) SetEntryFactory(constraint string, ef EntryFactory) error

func (*SemVerEntryFactoryMap) SupportedVersions added in v0.3.0

func (s *SemVerEntryFactoryMap) SupportedVersions() []string

type TypeImpl

type TypeImpl interface {
	CreateProposedEntry(context.Context, string, ArtifactProperties) (models.ProposedEntry, error)
	DefaultVersion() string
	SupportedVersions() []string
	UnmarshalEntry(pe models.ProposedEntry) (EntryImpl, error)
}

TypeImpl is implemented by all types to support the polymorphic conversion of abstract proposed entry to a working implementation for the versioned type requested, if supported

type ValidationError added in v0.3.0

type ValidationError error

ValidationError indicates that there is an issue with the content in the HTTP Request that should result in an HTTP 400 Bad Request error being returned to the client

type VersionEntryFactoryMap added in v0.2.0

type VersionEntryFactoryMap interface {
	GetEntryFactory(string) (EntryFactory, error) // return the entry factory for the specified version
	SetEntryFactory(string, EntryFactory) error   // set the entry factory for the specified version
	Count() int                                   // return the count of entry factories currently in the map
	SupportedVersions() []string                  // return a list of versions currently stored in the map
}

VersionEntryFactoryMap defines a map-like interface to find the correct implementation for a version string This could be a simple map[string]EntryFactory, or something more elegant (e.g. semver)

func NewSemVerEntryFactoryMap added in v0.2.0

func NewSemVerEntryFactoryMap() VersionEntryFactoryMap

Directories

Path Synopsis
jar
rpm
tuf

Jump to

Keyboard shortcuts

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