cpe

package module
v0.0.0-...-cdd6c3c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2019 License: MIT Imports: 3 Imported by: 6

README

umisama/go-cpe Build Status

A Common Platform Enumeration 2.3 implementation for golang.

installation

go get github.com/umisama/go-cpe

usage

Simple example is here:

// Create new item with Setter functions.
item1 := cpe.NewItem(
item1.SetPart(cpe.Application)
item1.SetVendor(cpe.NewStringAttr("microsoft"))
item1.SetProduct(cpe.NewStringAttr("internet_explorer"))

// create new item with WFN.  You can use also other formats(url, formatted string and WFN).
item2, err := cpe.NewItemFromWfn(`wfn:[part="a",vendor="microsoft",product="internet_explorer",version="8\.0\.6001",update="beta"]`)
if err != nil {
        panic(err)
}
fmt.Println("Vendor :", item2.Vendor()

// Compare functions
fmt.Println("is relation superset between item1 and item2? : ", cpe.CheckSuperset(item1, item2))
fmt.Println("is relation equal between item1 and item2? : ", cpe.CheckEqual(item1, item2))
))

document

godoc.org

reference

license

under the MIT License.

Documentation

Index

Constants

View Source
const (
	Disjoint = Relation(iota)
	Equal
	Subset
	Superset
	Undefined
)

Variables

View Source
var (
	Application      = PartAttr('a')
	OperationgSystem = PartAttr('o')
	Hardware         = PartAttr('h')
	PartNotSet       = PartAttr(0x00)
	Any              = StringAttr{}
	Na               = StringAttr{/* contains filtered or unexported fields */}
)

Functions

func CheckDisjoint

func CheckDisjoint(src, trg *Item) bool

CheckDisjoint implements CPE_DISJOINT. Returns true if the set-theoretic reration between the names is DISJOINT.

func CheckEqual

func CheckEqual(src, trg *Item) bool

CheckEqual implements CPE_EQUAL. Returns true if the set-theoretic relation between src and trg is EQUAL.

func CheckSubset

func CheckSubset(src, trg *Item) bool

CheckSubset implements CPE_SUBSET. Returns true if the set-theoretic relation between src and trg is SUBSET.

func CheckSuperset

func CheckSuperset(src, trg *Item) bool

CheckSuperset implements CPE_SUPERSET. Returns true if the set-theoretic relation between src and trg is SUPERSET.

Types

type Attribute

type Attribute interface {
	String() string
	IsEmpty() bool
	IsValid() bool
	Comparison(Attribute) Relation
	// contains filtered or unexported methods
}

Attribute groups PartAttr and StringAttr.

type Item

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

Item reprecents a CPE item.

func NewItem

func NewItem() *Item

NewItem returns empty Item.

func NewItemFromFormattedString

func NewItemFromFormattedString(str string) (*Item, error)

func NewItemFromUri

func NewItemFromUri(uri string) (*Item, error)

func NewItemFromWfn

func NewItemFromWfn(wfn string) (*Item, error)

func (*Item) Edition

func (i *Item) Edition() StringAttr

Edition returns edition of item.

func (*Item) Formatted

func (m *Item) Formatted() string

Wfn returns a formatted string binding.

func (*Item) Language

func (i *Item) Language() StringAttr

Language returns language of item.

func (*Item) Other

func (i *Item) Other() StringAttr

Other returns other of item.

func (*Item) Part

func (i *Item) Part() PartAttr

Part returns part of item.

func (*Item) Product

func (i *Item) Product() StringAttr

Vendor returns product of item.

func (*Item) SetEdition

func (i *Item) SetEdition(s StringAttr) error

SetEdition sets edition of item. returns error if s is invalid.

func (*Item) SetLanguage

func (i *Item) SetLanguage(s StringAttr) error

SetLanguage sets language of item. returns error if s is invalid.

func (*Item) SetOther

func (i *Item) SetOther(s StringAttr) error

SetOther sets other of item. returns error if s is invalid.

func (*Item) SetPart

func (i *Item) SetPart(p PartAttr) error

SetPart sets part of item. returns error if p is invalid.

func (*Item) SetProduct

func (i *Item) SetProduct(s StringAttr) error

SetProduct sets vendor of item. returns error if s is invalid.

func (*Item) SetSwEdition

func (i *Item) SetSwEdition(s StringAttr) error

SetSwEdition sets sw_edition of item. returns error if s is invalid.

func (*Item) SetTargetHw

func (i *Item) SetTargetHw(s StringAttr) error

SetTargetHw sets target_hw of item. returns error if s is invalid.

func (*Item) SetTargetSw

func (i *Item) SetTargetSw(s StringAttr) error

SetTargetSw sets target_sw of item. returns error if s is invalid.

func (*Item) SetUpdate

func (i *Item) SetUpdate(s StringAttr) error

SetUpdate sets update of item. returns error if s is invalid.

func (*Item) SetVendor

func (i *Item) SetVendor(s StringAttr) error

SetVendor sets vendor of item. returns error if s is invalid.

func (*Item) SetVersion

func (i *Item) SetVersion(s StringAttr) error

SetVersion sets version of item. returns error if s is invalid.

func (*Item) SwEdition

func (i *Item) SwEdition() StringAttr

SwEdition returns sw_edition of item.

func (*Item) TargetHw

func (i *Item) TargetHw() StringAttr

TargetHw returns target_hw of item.

func (*Item) TargetSw

func (i *Item) TargetSw() StringAttr

TargetSw returns target_sw of item.

func (*Item) Update

func (i *Item) Update() StringAttr

Update returns update of item.

func (*Item) Uri

func (m *Item) Uri() string

Wfn returns a string of uri binding.

func (*Item) Vendor

func (i *Item) Vendor() StringAttr

Vendor returns vendor of item.

func (*Item) Version

func (i *Item) Version() StringAttr

Version returns version of item.

func (*Item) Wfn

func (m *Item) Wfn() string

Wfn returns a string of Well-Formed string data model.

type PartAttr

type PartAttr rune

PartAttr reprecents part attribute of cpe item.

func (PartAttr) Comparison

func (src PartAttr) Comparison(trg Attribute) Relation

func (PartAttr) IsEmpty

func (m PartAttr) IsEmpty() bool

func (PartAttr) IsValid

func (m PartAttr) IsValid() bool

func (PartAttr) String

func (m PartAttr) String() string

type Relation

type Relation int

type StringAttr

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

StringAttr reprecents other than part attribute of cpe item.

func NewStringAttr

func NewStringAttr(str string) StringAttr

NewStringAttr returns attribute of item with str.

func (StringAttr) Comparison

func (src StringAttr) Comparison(trg Attribute) Relation

func (StringAttr) IsEmpty

func (s StringAttr) IsEmpty() bool

Empty StringAttr means ANY.

func (StringAttr) IsValid

func (s StringAttr) IsValid() bool

func (StringAttr) String

func (s StringAttr) String() string

Jump to

Keyboard shortcuts

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