payload

package
v0.0.0-...-3996087 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllFormats = FormatsList{
	"application/vnd.cyclonedx",
	"text/spdx",
	"application/vnd.slsa",
	"application/vnd.openvex",
}

Functions

This section is empty.

Types

type Document

type Document struct {
	Format Format
	// contains filtered or unexported fields
}

Document is an object that abstracts a security document handled by deployer.

func NewDocument

func NewDocument() *Document

func NewDocumentFromBytes

func NewDocumentFromBytes(data []byte) *Document

NewDocumentFromBytes creates a document from an already read byte array

func NewDocumentFromFile

func NewDocumentFromFile(path string) (*Document, error)

func (*Document) Cleanup

func (d *Document) Cleanup()

Cleanup is a function intended to be run just before a document is discarded. It takes care of closing its file and

func (*Document) Hash

func (d *Document) Hash() (hVal string, err error)

func (*Document) Read

func (d *Document) Read(b []byte) (n int, err error)

Read implements the reader interface to be able to use the document wherever io.Reader fits

func (*Document) ReadData

func (d *Document) ReadData(r io.Reader) (err error)

ReadData takes an io.Reader r and ingests the data of the document from it using Read(). Data will be kept in memory until maxInMemSize bytes are read, after which data will be dumped to a temporary file.

func (*Document) Seek

func (d *Document) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface. It delegates the seek operation to the backend the document is using (in memory or file on disk).

func (*Document) SetData

func (d *Document) SetData(data []byte)

SetData sets the document data from a byte array already in memory

type Format

type Format string

Format captures a format string that indicates the types of documents handled by deployer.

func NewFormatFromIntotoPredicate

func NewFormatFromIntotoPredicate(predicateType string) Format

NewFormatFromIntotoPredicate takes one of the registered in-toto predicate types (or an equivalent IRI of another recognized one) and returns a Format.

func (Format) Encoding

func (f Format) Encoding() string

Version returns the version value part of the format string

func (Format) MimeType

func (f Format) MimeType() string

MimeType returns the mime type part of the format

func (Format) Parse

func (f Format) Parse() map[string]string

Parse looks at the format string and extracts its main components:

  • Plain MIME type
  • Version
  • Encoding (json, xml, etc)

func (Format) Version

func (f Format) Version() string

Version returns the version value part of the format string

type FormatsList

type FormatsList []Format

func (*FormatsList) Has

func (fl *FormatsList) Has(f Format) bool

Has returns a bool flagging if the FormatsList includes format q

Jump to

Keyboard shortcuts

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