types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 15 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
  • COSE Envelopes schema
    • Versions: 0.0.1
  • HashedRekord 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
  • TUF Metadata 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 {
	AdditionalAuthenticatedData []byte
	ArtifactPath                *url.URL
	ArtifactHash                string
	ArtifactBytes               []byte
	SignaturePath               *url.URL
	SignatureBytes              []byte
	PublicKeyPaths              []*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 BaseProposedEntryTester added in v0.9.0

type BaseProposedEntryTester struct{}

func (BaseProposedEntryTester) ContextValidate added in v0.9.0

func (b BaseProposedEntryTester) ContextValidate(ctx context.Context, r strfmt.Registry) error

func (BaseProposedEntryTester) Kind added in v0.9.0

func (BaseProposedEntryTester) SetKind added in v0.9.0

func (b BaseProposedEntryTester) SetKind(v string)

func (BaseProposedEntryTester) Validate added in v0.9.0

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

func (BaseUnmarshalTester) Verifier added in v1.1.0

func (u BaseUnmarshalTester) Verifier() (pki.PublicKey, 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
	CreateFromArtifactProperties(context.Context, ArtifactProperties) (models.ProposedEntry, error)
	Verifier() (pki.PublicKey, error)
}

EntryImpl specifies the behavior of a versioned type

func CreateVersionedEntry added in v0.12.0

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

CreateVersionedEntry returns the specific instance for the type and version specified in the doc This method should be used on the insertion flow, which validates that the specific version proposed is permitted to be entered into the log.

func UnmarshalEntry added in v0.12.0

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

UnmarshalEntry returns the specific instance for the type and version specified in the doc This method does not check for whether the version of the entry could be currently inserted into the log, and is useful when dealing with entries that have been persisted to the log.

type EntryWithAttestationImpl added in v0.9.1

type EntryWithAttestationImpl interface {
	EntryImpl
	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
}

EntryWithAttestationImpl specifies the behavior of a versioned type that also stores attestations

type ProposedEntryIterator added in v0.12.1

type ProposedEntryIterator interface {
	models.ProposedEntry
	HasNext() bool
	Get() models.ProposedEntry
	GetNext() models.ProposedEntry
}

ProposedEntryIterator is an iterator over a list of proposed entries

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) IsSupportedVersion added in v0.12.0

func (rt *RekorType) IsSupportedVersion(proposedVersion string) bool

IsSupportedVersion returns true if the version can be inserted into the log, and false if not

func (*RekorType) SupportedVersions added in v0.3.0

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

SupportedVersions returns a list of versions of this type that can be currently entered into the log

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
	IsSupportedVersion(string) bool
	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

Jump to

Keyboard shortcuts

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