Documentation ¶
Index ¶
- Variables
- func AddKeyToKeyRingFromReader(keyring *KeyRing, name string, reader io.Reader) error
- func AuthToClient(ctx context.Context, auth Auth, image reference.Named) (*http.Client, error)
- func GetCheckFactories(names ...string) (map[string]Check, error)
- func IsCheckFactoryRegistered(name string) bool
- func NewVulnerabilityError(vuls []Vulnerability) (err error)
- func RegisterCheckFactory(name string, creator CheckFactory)
- func ShouldIncludeVulnerability(test Vulnerability, baseline Severity) bool
- func Sign(signer *openpgp.Entity, msg string) (string, error)
- func ToMapStringBool(in map[string]interface{}) (out map[string]bool)
- func Verify(keyring openpgp.KeyRing, signed string) (string, error)
- type AttestationPayload
- type Auth
- type AuthorizedCheck
- type Check
- type CheckFactories
- type CheckFactory
- type CheckResult
- type ImageData
- type KeyRing
- func (keyring *KeyRing) AddEntities(name string, input openpgp.EntityList)
- func (keyring *KeyRing) DecryptionKeys() []openpgp.Key
- func (keyring *KeyRing) GetSignerByName(name string) (*openpgp.Entity, error)
- func (keyring *KeyRing) KeysById(id uint64) []openpgp.Key
- func (keyring *KeyRing) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key
- type MetadataCheck
- type MetadataClient
- type MetadataItem
- type MetadataType
- type RepoValidatorCheck
- type Request
- type Response
- type Severity
- type Suite
- func (cs *Suite) Add(name string, check Check)
- func (cs *Suite) Attest(metadataClient MetadataClient, results []CheckResult) []CheckResult
- func (cs *Suite) Get(name string) (Check, error)
- func (cs *Suite) Has(name string) bool
- func (cs *Suite) Run(imageData ImageData) []CheckResult
- func (cs *Suite) RunAndAttest(metadataClient MetadataClient, imageData ImageData) []CheckResult
- type VulnerabilitiesError
- type Vulnerability
- type VulnerabilityCheck
- type VulnerabilityScanner
Constants ¶
This section is empty.
Variables ¶
var DefaultCheckFactories = make(CheckFactories)
DefaultCheckFactories is the default CheckFactory collection.
var ErrNoAuth = errors.New("no configured Auth")
ErrNoAuth should be returned when something that depends on an Auth does not have one.
var ErrNoCheck = errors.New("requested check doesn't exist")
ErrNoCheck is an error that is returned when a requested check hasn't been registered.
Functions ¶
func AddKeyToKeyRingFromReader ¶
AddKeyToKeyRingFromReader imports the PGP keys stored in a Reader into the passed KeyRing.
func AuthToClient ¶
AuthToClient takes a struct implementing Auth and returns a new http.Client with the authentication details setup by Auth.GetTokenSource.
DEPRECATED: This function has been superceded by Auth.ToClient. This function now calls that method directly.
func GetCheckFactories ¶
GetCheckFactories gets new copies of the Checks from their registered CheckFactories.
func IsCheckFactoryRegistered ¶
IsCheckFactoryRegistered returns true if the passed CheckFactory was registered.
func NewVulnerabilityError ¶
func NewVulnerabilityError(vuls []Vulnerability) (err error)
NewVulnerabilityError creates a new VulnerabilityError with the passed Vulnerabilities.
func RegisterCheckFactory ¶
func RegisterCheckFactory(name string, creator CheckFactory)
RegisterCheckFactory adds a CheckFactory to the DefaultCheckFactories that can be run. Once a Check is added, it can be referenced by the name that was passed in when this function was called.
func ShouldIncludeVulnerability ¶
func ShouldIncludeVulnerability(test Vulnerability, baseline Severity) bool
ShouldIncludeVulnerability returns true if the passed vulnerability should be included in our vulnerability report.
func ToMapStringBool ¶
ToMapStringBool takes a map[string]interface{} and converts it to a map[string]bool (dropping any values that do not cast to booleans cleanly).
Types ¶
type AttestationPayload ¶
AttestationPayload is a structure that contains the Attestation data that we want to create an MetadataItem from.
func NewAttestationPayload ¶
func NewAttestationPayload(checkName string, payload string) AttestationPayload
NewAttestationPayload creates a new AttestationPayload for the check with the passed name, with the payload as the body. The payload will then be signed by the key associated with the check (referenced by the checkName).
type Auth ¶
type Auth interface { GetTokenSource(context.Context, reference.Named) (oauth2.TokenSource, error) ToClient(ctx context.Context, image reference.Named) (*http.Client, error) }
Auth is an interface that wraps an to an OAuth2 system, to simplify the path from having an image reference to getting access to the data that makes up that image from the registry it lives in.
type AuthorizedCheck ¶
AuthorizedCheck represents a Voucher check that needs to be authorized. For example, a check that needs to connect to the registry will need to implement AuthorizedCheck.
type CheckFactories ¶
type CheckFactories map[string]CheckFactory
CheckFactories is a map of registered CheckFactories.
func (CheckFactories) Get ¶
func (cf CheckFactories) Get(name string) CheckFactory
Get returns the CheckFactory with the passed name.
func (CheckFactories) GetNewChecks ¶
func (cf CheckFactories) GetNewChecks(names ...string) (map[string]Check, error)
GetNewChecks gets new copies of the Checks from each of their registered CheckFactory.
func (CheckFactories) Register ¶
func (cf CheckFactories) Register(name string, creator CheckFactory)
Register adds a new CheckFactory to this CheckFactories.
type CheckFactory ¶
type CheckFactory func() Check
CheckFactory is a type of function that creates a new Check.
type CheckResult ¶
type CheckResult struct { ImageData ImageData `json:"-"` Name string `json:"name"` Err string `json:"error,omitempty"` Success bool `json:"success"` Attested bool `json:"attested"` Details interface{} `json:"details,omitempty"` }
CheckResult describes the result of a Check. If a check failed, it will have a status of false. If a check succeeded, but its Attestation creation failed, Succes will be true, Attested will be false. Err will contain the first error to occur.
type ImageData ¶
ImageData is a Canonical Reference to the Image (includes digest and URL).
func NewImageData ¶
NewImageData creates a new ImageData item with the passed URL as a reference to the target image.
type KeyRing ¶
type KeyRing struct {
// contains filtered or unexported fields
}
KeyRing wraps an OpenPGP EntityList (which implements openpgp.KeyRing), adding support for determining which key is associated with which check. KeyRing implements openpgp.KeyRing, thus can be used in place of it where appropriate.
func NewKeyRing ¶
func NewKeyRing() *KeyRing
NewKeyRing creates a new keyring from the passed EntityList. The keys in the input EntityList are then associated with the
func (*KeyRing) AddEntities ¶
func (keyring *KeyRing) AddEntities(name string, input openpgp.EntityList)
AddEntities adds new keys from the passed EntityList to the keyring for use.
func (*KeyRing) DecryptionKeys ¶
DecryptionKeys returns all private keys that are valid for decryption.
func (*KeyRing) GetSignerByName ¶
GetSignerByName gets the first available signing key associated with the passed name.
type MetadataCheck ¶
type MetadataCheck interface { Check SetMetadataClient(MetadataClient) }
MetadataCheck represents a Voucher check that interacts directly with a metadata server.
type MetadataClient ¶
type MetadataClient interface { CanAttest() bool NewPayloadBody(ImageData) (string, error) GetMetadata(ImageData, MetadataType) ([]MetadataItem, error) AddAttestationToImage(ImageData, AttestationPayload) (MetadataItem, error) }
MetadataClient is an interface that represents something that communicates with the Metadata server.
type MetadataItem ¶
type MetadataItem interface {
String() string // String returns a string representation of the MetadataItem.
}
MetadataItem is a type which can be returned as a string.
type MetadataType ¶
type MetadataType string
MetadataType is a type which represents a MetadataClient's MetadataItem type.
const ( // VulnerabilityType is specific to MetadataItem containing vulnerabilities. VulnerabilityType MetadataType = "vulnerability" // BuildDetailsType refers to MetadataItems containing image build details. BuildDetailsType MetadataType = "build details" // AttestationType refers to MetadataItems containing Binary Authorization Attestations. AttestationType MetadataType = "attestation" )
type RepoValidatorCheck ¶ added in v1.1.0
RepoValidatorCheck represents a Voucher check that validates the passed image is from a valid repo.
type Request ¶
type Request struct {
ImageURL string `json:"image_url"`
}
Request describes the Voucher API request structure.
type Response ¶
type Response struct { Image string `json:"image"` Success bool `json:"success"` Results []CheckResult `json:"results"` }
Response describes the response from a Check call.
func NewResponse ¶
func NewResponse(reference reference.Reference, results []CheckResult) (checkResponse Response)
NewResponse creates a new Response for the passed ImageData, with the passed results.
type Severity ¶
type Severity int
Severity is a integer that represents how severe a vulnerability is.
const ( NegligibleSeverity Severity = iota LowSeverity Severity = iota MediumSeverity Severity = iota UnknownSeverity Severity = iota HighSeverity Severity = iota CriticalSeverity Severity = iota )
Severity constants, which represent the severities that we track. Other systems' severities should be converted to one of the following.
func StringToSeverity ¶
StringToSeverity returns the matching Severity to the passed string. Returns an error if there isn't a matching Severity.
type Suite ¶
type Suite struct {
// contains filtered or unexported fields
}
Suite is a suite of Checks, which
func (*Suite) Add ¶
Add adds a Check to the checks that can be run. Once a Check is added, it can be referenced by the name that was passed in when this function was called.
func (*Suite) Attest ¶
func (cs *Suite) Attest(metadataClient MetadataClient, results []CheckResult) []CheckResult
Attest runs through the passed []CheckResult and if a CheckResult is marked as successful, runs the CreateAttestion function in the Check corresponding to that CheckResult. Each CheckResult is updated with the details (or error) and the resulting []CheckResult is returned.
func (*Suite) Run ¶
func (cs *Suite) Run(imageData ImageData) []CheckResult
Run executes each of the Checks specified by the activeChecks parameter.
For example, if a Suite has the "diy" and "nobody" tests, calling
Run(imageData)
will run the "diy" and "nobody" tests.
Run returns a []CheckResult with a CheckResult for each Check that was run.
func (*Suite) RunAndAttest ¶
func (cs *Suite) RunAndAttest(metadataClient MetadataClient, imageData ImageData) []CheckResult
RunAndAttest calls Run, followed by Attest, and returns the final []CheckResult.
type VulnerabilitiesError ¶
type VulnerabilitiesError struct {
Vulnerabilities []Vulnerability
}
VulnerabilitiesError is an error that also contains a list of vulnerabilities.
func (VulnerabilitiesError) Error ¶
func (err VulnerabilitiesError) Error() string
Error returns the error message for the VulnerabilitiesError
type Vulnerability ¶
type Vulnerability struct { Name string `json:"name"` // Name of the Vulnerability, or it's CVE number. Description string `json:"description"` // Description of the Vulnerability. Severity Severity `json:"severity"` // Severity of the Vulnerability. FixedBy string `json:"fixed_by"` // If this vulnerability was fixed, what it was fixed by. }
Vulnerability is a type that describes a security vulnerability. Third-party scanner vulnerabilities should be converted to this type.
type VulnerabilityCheck ¶
type VulnerabilityCheck interface { Check SetScanner(VulnerabilityScanner) }
VulnerabilityCheck represents a Voucher test.
type VulnerabilityScanner ¶
type VulnerabilityScanner interface { // FailOn sets the minimum Severity to consider an image vulnerable. FailOn(Severity) // Scan runs a scan against the passed ImageData and returns a slice of // Vulnerabilities. Scan(ImageData) ([]Vulnerability, error) }
VulnerabilityScanner is an interface which represents a scanners that can be used to check an image for vulnerabilities. VulnerabilityScanners implement the Scan method, which takes ImageData as input and returns a slice of Vulnerabilities.
Source Files ¶
- attestationpayload.go
- auth.go
- authorizedcheck.go
- cast.go
- check.go
- imagedata.go
- keyring.go
- metadatacheck.go
- metadataclient.go
- metadataitem.go
- metadatatype.go
- register.go
- request.go
- response.go
- result.go
- severity.go
- sign.go
- suite.go
- validrepocheck.go
- vulnerability.go
- vulnerability_error.go
- vulnerability_scanner.go
- vulnerabilitycheck.go