parseadvisory

package
v0.0.0-...-080fdaf Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package parseadvisory contains core functionality for converting the advisories -- the "source of truth" for the Xen Project XSAs -- into machine-readable information.

The core function of the library is ParseAdvisory.

Index

Constants

View Source
const (
	SectionIssueDescription  = "ISSUE DESCRIPTION"
	SectionImpact            = "IMPACT"
	SectionVulnerableSystems = "VULNERABLE SYSTEMS"
	SectionMitigation        = "MITIGATION"
	SectionResolution        = "RESOLUTION"
	SectionEmbargoDeployment = "DEPLOYMENT DURING EMBARGO"
	SectionCredits           = "CREDITS"
	SectionPatchInformation  = "PATCH INFORMATION"
)

Variables

This section is empty.

Functions

func IsBlank

func IsBlank(s string) bool

IsBlank returns true if s is empty or contains nothing but space characters, as defined by `strings.TrimSpace`

func IsUpper

func IsUpper(s string) bool

IsUpper returns false if s contains any letters (`unicode.IsLetter`) which are not upper case (`unicode.IsUpper`), and true otherwise.

Types

type Advisory

type Advisory struct {
	Xsa         int
	Title       string
	Version     int
	Deallocated bool
	Embargoed   bool
	EmbargoTime time.Time
	Cve         []string
	// NB Sections is a slice rather than a map so that we can reconstruct the
	// advisory after editing it
	Sections    []Section
	Errors      []error
	Files       []FileInfo
	VersionTags []VersionTag
}

func ParseAdvisory

func ParseAdvisory(input io.Reader) (a *Advisory, err error)

ParseAdvisory takes an input and attempts to parse it as an advisory. Generally speaking, errors are only returned for circumstances that prevent further processing; either IO errors, or egregious format violations which probably indicate that the wrong type of data was passed in.

More subtle errors in formating or specification compliance will be returned in a.Errors.

func (Advisory) GetSection

func (a Advisory) GetSection(title string) []string

GetSection will look for the section with the given title, and return the content as an array of lines.

type FileInfo

type FileInfo struct {
	Name     string
	Versions []Version // Extrapolated from VersionTag.Versions
	Projects []Project // Extrapolated from Versions.  NB we can have multiple project w/in the same upstream.
	Upstream string    // Extrapolated from Versions
}

type Project

type Project string

func (Project) Upstream

func (prj Project) Upstream() string

Upstream returns the defined upstream of the project

type ProjectVersion

type ProjectVersion struct {
	Project Project `parser:"@Project"`
	Version string  `parser:"(Space @(VersionString | Master | RCVersionString | AltVersionString))?"`
}

type Section

type Section struct {
	Name    string
	Content []string
}

type Version

type Version struct {
	Range []VersionSingle `parser:"@@ ( VersionDash @@ )?"`
}

func (Version) String

func (v Version) String() string

type VersionSingle

type VersionSingle struct {
	TipVersion     *string         `parser:"@TipVersion"`
	ProjectVersion *ProjectVersion `parser:"| @@"`
	// ProjectVersion *string `parser:"| ProjectVersionString"`
	Version *string `parser:"| @(VersionString | Master | RCVersionString | AltVersionString)"`
}

func (VersionSingle) Project

func (v VersionSingle) Project() Project

func (VersionSingle) String

func (v VersionSingle) String() string

type VersionTag

type VersionTag struct {
	Target   VersionTarget `parser:"@@"`
	Versions []Version     `parser:"ColSpacer @@ ( CommaSpacer @@ )*"`
	Selector *string       `parser:"((Space | ColSpacer) Selector)?"`
	Comment  *string       `parser:"((Space | ColSpacer) Comment)?"`
	Projects []Project
}

type VersionTarget

type VersionTarget struct {
	Globs   []string `parser:"@Glob ( CommaSpacer @Glob )*"`
	Comment *string  `parser:"| @VersionComment"`
}

Jump to

Keyboard shortcuts

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