syft

package
v0.0.0-...-5cb193c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAllFor

func MatchAllFor[T Match](filtersValues *filters.Filters, match T) bool

MatchAllFor returns true if all filters return true for the given Match object

Types

type CPE

type CPE struct {
	Value  string `json:"cpe"`
	Source string `json:"source,omitempty"`
}

CPE represents a Common Platform Enumeration, with the source that has generated it

type Coordinates

type Coordinates struct {
	RealPath     string `json:"path"`              // The path where all path ancestors have no hardlinks / symlinks
	FileSystemID string `json:"layerID,omitempty"` // An ID representing the filesystem. For container images, this is a layer digest. For directories or a root filesystem, this is blank.
}

Coordinates represents the coordinates for a file. Imported from file.Coordinates in syft

type Descriptor

type Descriptor struct {
	Name          string `json:"name"`
	Version       string `json:"version"`
	Configuration any    `json:"configuration,omitempty"`
}

Descriptor describes what created the document as well as surrounding metadata

type Digest

type Digest struct {
	Algorithm string `json:"algorithm"`
	Value     string `json:"value"`
}

Digest represents a file digest. Imported from file.Digest in syft

type Document

type Document struct {
	Artifacts             []Package      `json:"artifacts"` // Artifacts is the list of packages discovered and placed into the catalog
	ArtifactRelationships []Relationship `json:"artifactRelationships"`
	Files                 []File         `json:"files,omitempty"` // note: must have omitempty
	Source                Source         `json:"source"`          // Source represents the original object that was cataloged
	Distro                LinuxRelease   `json:"distro"`          // Distro represents the Linux distribution that was detected from the source
	Descriptor            Descriptor     `json:"descriptor"`      // Descriptor is a block containing self-describing information about syft
	Schema                Schema         `json:"schema"`          // Schema is a block reserved for defining the version for the shape of this JSON document and where to find the schema document to validate the shape
}

Document represents the syft cataloging findings as a JSON document

func Diff

func Diff(before, after *Document) (addedArtifacts, removedArtifacts *Document)

Diff takes 2 syft reports and returns the difference between them for introduced or removed dependencies.

func (*Document) Filter

func (d *Document) Filter(filtersValues *filters.Filters) *Document

Filter applies the given filters and returns a new document containing only matches still matching. Note if no filters are defined the original document will be returned, not a copy.

func (*Document) Sort

func (d *Document) Sort() *Document

Sort returns a new shallow copy of a document with the packages sorted by multiple keys as follows: - id - name - version - path

type File

type File struct {
	ID       string             `json:"id"`
	Location Coordinates        `json:"location"`
	Metadata *FileMetadataEntry `json:"metadata,omitempty"`
	Contents string             `json:"contents,omitempty"`
	Digests  []Digest           `json:"digests,omitempty"`
	Licenses []FileLicense      `json:"licenses,omitempty"`
}

File is a struct that represents a specific file that has been scanned

type FileLicense

type FileLicense struct {
	Value          string               `json:"value"`
	SPDXExpression string               `json:"spdxExpression"`
	Type           string               `json:"type"` // converted from license.Type
	Evidence       *FileLicenseEvidence `json:"evidence,omitempty"`
}

FileLicense represents a license associated to a file

type FileLicenseEvidence

type FileLicenseEvidence struct {
	Confidence int `json:"confidence"`
	Offset     int `json:"offset"`
	Extent     int `json:"extent"`
}

FileLicenseEvidence represents the evidence associated to a file license

type FileMetadataEntry

type FileMetadataEntry struct {
	Mode            int    `json:"mode"`
	Type            string `json:"type"`
	LinkDestination string `json:"linkDestination,omitempty"`
	UserID          int    `json:"userID"`
	GroupID         int    `json:"groupID"`
	MIMEType        string `json:"mimeType"`
	Size            int64  `json:"size"`
}

FileMetadataEntry metadata associated to a file

type IDLikes

type IDLikes []string

IDLikes is a slice of strings that represents the IDLike field of a LinuxRelease struct.

type License

type License struct {
	Value          string     `json:"value"`
	SPDXExpression string     `json:"spdxExpression"`
	Type           string     `json:"type"`
	URLs           []string   `json:"urls"`
	Locations      []Location `json:"locations"`
}

License represents a License of a package

type LinuxRelease

type LinuxRelease struct {
	PrettyName       string  `json:"prettyName,omitempty"`
	Name             string  `json:"name,omitempty"`
	ID               string  `json:"id,omitempty"`
	IDLike           IDLikes `json:"idLike,omitempty"`
	Version          string  `json:"version,omitempty"`
	VersionID        string  `json:"versionID,omitempty"`
	VersionCodename  string  `json:"versionCodename,omitempty"`
	BuildID          string  `json:"buildID,omitempty"`
	ImageID          string  `json:"imageID,omitempty"`
	ImageVersion     string  `json:"imageVersion,omitempty"`
	Variant          string  `json:"variant,omitempty"`
	VariantID        string  `json:"variantID,omitempty"`
	HomeURL          string  `json:"homeURL,omitempty"`
	SupportURL       string  `json:"supportURL,omitempty"`
	BugReportURL     string  `json:"bugReportURL,omitempty"`
	PrivacyPolicyURL string  `json:"privacyPolicyURL,omitempty"`
	CPEName          string  `json:"cpeName,omitempty"`
	SupportEnd       string  `json:"supportEnd,omitempty"`
}

LinuxRelease is a struct that represents a Linux version for a specific scanned artifact.

type Location

type Location struct {
	LocationData     `cyclonedx:""`
	LocationMetadata `cyclonedx:""`
}

Location represents a path relative to a particular filesystem resolved to a specific file.Reference. This struct is used as a key in content fetching to uniquely identify a file relative to a request (the AccessPath).

type LocationData

type LocationData struct {
	Coordinates `cyclonedx:""` // Empty string here means there is no intermediate property name, e.g. syft:locations:0:path without "coordinates"
	// note: it is IMPORTANT to ignore anything but the coordinates for a Location when considering the ID (hash value)
	// since the coordinates are the minimally correct ID for a location (symlinks should not come into play)
	AccessPath string    `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks
	Ref        Reference `hash:"ignore"`                   // The file reference relative to the stereoscope.FileCatalog that has more information about this location.
}

LocationData is a struct that represents the location of a file.

func (LocationData) Reference

func (l LocationData) Reference() Reference

Reference The file reference relative to the stereoscope.FileCatalog that has more information about this location. Imported from https://github.com/anchore/stereoscope/blob/main/pkg/file/reference.go

type LocationMetadata

type LocationMetadata struct {
	Annotations map[string]string `json:"annotations,omitempty"` // Arbitrary key-value pairs that can be used to annotate a location
}

LocationMetadata is a struct that represents the metadata associated to a location.

type Match

type Match interface {
	File | Package | Relationship
}

Match a syft match could be a file, a package or a relationship

type Package

type Package struct {
	PackageBasicData
	PackageCustomData
}

Package represents a pkg.Package object specialized for JSON marshaling and unmarshalling.

func (*Package) UniqueID

func (m *Package) UniqueID() string

UniqueID returns a string that uniquely identifies an artifact it's made of the ID and a digest of the artifact location paths.

type PackageBasicData

type PackageBasicData struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Version   string    `json:"version"`
	Type      string    `json:"type"`
	FoundBy   string    `json:"foundBy"`
	Locations locations `json:"locations"`
	Licenses  licenses  `json:"licenses"`
	Language  string    `json:"language"`
	CPEs      cpes      `json:"cpes"`
	PURL      string    `json:"purl"`
}

PackageBasicData contains non-ambiguous values (type-wise) from pkg.Package.

type PackageCustomData

type PackageCustomData struct {
	MetadataType string `json:"metadataType,omitempty"`
	Metadata     any    `json:"metadata,omitempty"`
}

PackageCustomData contains ambiguous values (type-wise) from pkg.Package.

type Reference

type Reference struct {
	RealPath string
	// contains filtered or unexported fields
}

Reference ported from https://github.com/anchore/stereoscope/blob/main/pkg/file/reference.go

type Relationship

type Relationship struct {
	Parent   string `json:"parent"`
	Child    string `json:"child"`
	Type     string `json:"type"`
	Metadata any    `json:"metadata,omitempty"`
}

Relationship is a struct that represents the relationships between packages.

func (*Relationship) UniqueID

func (m *Relationship) UniqueID() string

UniqueID returns a string that uniquely identifies a relationship it's made of the parent, child and type of the relationship hashed together

type Schema

type Schema struct {
	Version string `json:"version"`
	URL     string `json:"url"`
}

Schema is a block reserved for defining the version for the shape of this JSON document and where to find the schema document to validate the shape

type SearchResult

type SearchResult struct {
	Classification string `json:"classification"`
	LineNumber     int64  `json:"lineNumber"`
	LineOffset     int64  `json:"lineOffset"`
	SeekPosition   int64  `json:"seekPosition"`
	Length         int64  `json:"length"`
	Value          string `json:"value,omitempty"`
}

SearchResult is a struct that represents the result of a secrets scan.

type Secrets

type Secrets struct {
	Location Coordinates    `json:"location"` // from file.Coordinates
	Secrets  []SearchResult `json:"secrets"`  // from file.SearchResult
}

Secrets is a struct that represents the output of a secrets scan.

type Source

type Source struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Version  string `json:"version"`
	Type     string `json:"type"`
	Metadata any    `json:"metadata"`
}

Source object represents the thing that was cataloged

Jump to

Keyboard shortcuts

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