cpe

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package cpe provides for handling Common Platform Enumeration (CPE) names.

Index

Constants

View Source
const NumAttr = 11

NumAttr is the number of attributes in a 2.3 WFN.

Variables

View Source
var ErrUnset = errors.New("cpe: wfn is empty")

ErrUnset is returned from (WFN).Valid() if it is the zero value.

Functions

This section is empty.

Types

type Attribute

type Attribute int

Attribute is a type for enumerating the valid CPE attributes.

const (
	Part      Attribute = iota // part
	Vendor                     // vendor
	Product                    // product
	Version                    // version
	Update                     // update
	Edition                    // edition
	SwEdition                  // sw_edition
	TargetSW                   // target_sw
	TargetHW                   // target_hw
	Language                   // language
	Other                      // other
)

These are the valid Attributes

func (Attribute) String

func (i Attribute) String() string

type Value

type Value struct {
	Kind ValueKind
	V    string
}

Value represents all the states for an attribute's value.

func NewValue

func NewValue(v string) (Value, error)

NewValue constructs a specific value and ensures it's a valid string.

This function does not quote the provided string, only validates that the quoting is proper.

func (*Value) Scan

func (v *Value) Scan(i interface{}) error

Scan implements sql.Scanner.

func (*Value) String

func (v *Value) String() string

func (Value) Value

func (v Value) Value() (driver.Value, error)

Value implements driver.Valuer.

type ValueKind

type ValueKind uint

ValueKind indicates what "kind" a value is.

const (
	ValueUnset ValueKind = iota
	ValueAny
	ValueNA
	ValueSet
)

These are the valid states for a wfn attribute's value.

func (ValueKind) String

func (i ValueKind) String() string

type WFN

type WFN struct {
	Attr [NumAttr]Value
}

WFN is a well-formed name as defined by the Common Platform Enumeration (CPE) spec: https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf

This package does not implement binding into URI form.

func MustUnbind

func MustUnbind(s string) WFN

MustUnbind calls Unbind on the provided string, but panics if any errors are encountered.

This is primarily useful for static data where any error is a programmer error.

func Unbind

func Unbind(s string) (WFN, error)

Unbind attempts to unbind a string regardless of it be a formatted string or URI.

func UnbindFS

func UnbindFS(s string) (WFN, error)

UnbindFS attempts to unbind a string as CPE 2.3 formatted string into a WFN.

func UnbindURI

func UnbindURI(s string) (WFN, error)

UnbindURI attempts to unbind a string as CPE 2.2 URI into a WFN.

This function supports unpacking attributes from the "edition" component as specified in CPE 2.3.

func (WFN) BindFS

func (w WFN) BindFS() string

BindFS returns the WFN bound as CPE 2.3 formatted string.

func (*WFN) MarshalText

func (w *WFN) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*WFN) Scan

func (w *WFN) Scan(i interface{}) (err error)

Scan implements sql.Scanner.

func (WFN) String

func (w WFN) String() string

func (*WFN) UnmarshalText

func (w *WFN) UnmarshalText(b []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler.

func (WFN) Valid

func (w WFN) Valid() error

Valid reports an error if a WFN is not, in fact, well-formed.

Functions returning a WFN call this before returning, but if a WFN is constructed in code, the user should check it via this method.

func (WFN) Value

func (w WFN) Value() (driver.Value, error)

Value implements driver.Valuer.

Jump to

Keyboard shortcuts

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