distribution

package
v0.86.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 4

Documentation

Index

Constants

View Source
const ListingFileName = "listing.json"
View Source
const MetadataFileName = "metadata.json"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ID                      clio.Identification
	DBRootDir               string
	ListingURL              string
	CACert                  string
	ValidateByHashOnGet     bool
	ValidateAge             bool
	MaxAllowedBuiltAge      time.Duration
	RequireUpdateCheck      bool
	ListingFileTimeout      time.Duration
	UpdateTimeout           time.Duration
	UpdateCheckMaxFrequency time.Duration
}

type Curator

type Curator struct {
	// contains filtered or unexported fields
}

func NewCurator

func NewCurator(cfg Config) (Curator, error)

func (*Curator) Delete

func (c *Curator) Delete() error

Delete removes the DB and metadata file for this specific schema.

func (*Curator) GetStore

func (c *Curator) GetStore() (v5.StoreReader, error)

func (*Curator) ImportFrom

func (c *Curator) ImportFrom(dbArchivePath string) error

ImportFrom takes a DB archive file and imports it into the final DB location.

func (*Curator) IsUpdateAvailable

func (c *Curator) IsUpdateAvailable() (bool, *Metadata, *ListingEntry, error)

IsUpdateAvailable indicates if there is a new update available as a boolean, and returns the latest listing information available for this schema.

func (Curator) ListingFromURL

func (c Curator) ListingFromURL() (Listing, error)

ListingFromURL loads a Listing from a URL.

func (*Curator) Status

func (c *Curator) Status() Status

func (Curator) SupportedSchema

func (c Curator) SupportedSchema() int

func (*Curator) Update

func (c *Curator) Update() (bool, error)

Update the existing DB, returning an indication if any action was taken.

func (*Curator) UpdateTo

func (c *Curator) UpdateTo(listing *ListingEntry, downloadProgress, importProgress *progress.Manual, stage *progress.AtomicStage) error

UpdateTo updates the existing DB with the specific other version provided from a listing entry.

func (*Curator) Validate

func (c *Curator) Validate() error

Validate checks the current database to ensure file integrity and if it can be used by this version of the application.

type Listing

type Listing struct {
	Available map[int][]ListingEntry `json:"available"`
}

Listing represents the json file which is served up and made available for applications to download and consume one or more vulnerability db flat files.

func NewListing

func NewListing(entries ...ListingEntry) Listing

NewListing creates a listing from one or more given ListingEntries.

func NewListingFromFile

func NewListingFromFile(fs afero.Fs, path string) (Listing, error)

NewListingFromFile loads a Listing from a given filepath.

func (*Listing) BestUpdate

func (l *Listing) BestUpdate(targetSchema int) *ListingEntry

BestUpdate returns the ListingEntry from a Listing that meets the given version constraints.

func (Listing) Write

func (l Listing) Write(toPath string) error

Write the current listing to the given filepath.

type ListingEntry

type ListingEntry struct {
	Built    time.Time // RFC 3339
	Version  int
	URL      *url.URL
	Checksum string
}

ListingEntry represents basic metadata about a database archive such as what is in the archive (built/version) as well as how to obtain and verify the archive (URL/checksum).

func NewListingEntryFromArchive

func NewListingEntryFromArchive(fs afero.Fs, metadata Metadata, dbArchivePath string, baseURL *url.URL) (ListingEntry, error)

NewListingEntryFromArchive creates a new ListingEntry based on the metadata from a database flat file.

func (*ListingEntry) MarshalJSON

func (l *ListingEntry) MarshalJSON() ([]byte, error)

func (ListingEntry) String

func (l ListingEntry) String() string

func (*ListingEntry) UnmarshalJSON

func (l *ListingEntry) UnmarshalJSON(data []byte) error

type ListingEntryJSON

type ListingEntryJSON struct {
	Built    string `json:"built"`
	Version  int    `json:"version"`
	URL      string `json:"url"`
	Checksum string `json:"checksum"`
}

ListingEntryJSON is a helper struct for converting a ListingEntry into JSON (or parsing from JSON)

func (ListingEntryJSON) ToListingEntry

func (l ListingEntryJSON) ToListingEntry() (ListingEntry, error)

ToListingEntry converts a ListingEntryJSON to a ListingEntry.

type Metadata

type Metadata struct {
	Built    time.Time
	Version  int
	Checksum string
}

Metadata represents the basic identifying information of a database flat file (built/version) and a way to verify the contents (checksum).

func NewMetadataFromDir

func NewMetadataFromDir(fs afero.Fs, dir string) (*Metadata, error)

NewMetadataFromDir generates a Metadata object from a directory containing a vulnerability.db flat file.

func (*Metadata) IsSupersededBy

func (m *Metadata) IsSupersededBy(entry *ListingEntry) bool

IsSupersededBy takes a ListingEntry and determines if the entry candidate is newer than what is hinted at in the current Metadata object.

func (Metadata) String

func (m Metadata) String() string

func (*Metadata) UnmarshalJSON

func (m *Metadata) UnmarshalJSON(data []byte) error

func (Metadata) Write

func (m Metadata) Write(toPath string) error

Write out a Metadata object to the given path.

type MetadataJSON

type MetadataJSON struct {
	Built    string `json:"built"` // RFC 3339
	Version  int    `json:"version"`
	Checksum string `json:"checksum"`
}

MetadataJSON is a helper struct for parsing and assembling Metadata objects to and from JSON.

func (MetadataJSON) ToMetadata

func (m MetadataJSON) ToMetadata() (Metadata, error)

ToMetadata converts a MetadataJSON object to a Metadata object.

type Status

type Status struct {
	Built         time.Time `json:"built"`
	SchemaVersion int       `json:"schemaVersion"`
	Location      string    `json:"location"`
	Checksum      string    `json:"checksum"`
	Err           error     `json:"error"`
}

Jump to

Keyboard shortcuts

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