github.com/quay/claircore@v1.5.28/pkg/cpe/cpe.go (about)

     1  // Package cpe provides for handling Common Platform Enumeration (CPE) names.
     2  //
     3  // Deprecated: This package is a re-export of "github.com/quay/claircore/toolkit/types/cpe".
     4  // Users should migrate to that package.
     5  package cpe
     6  
     7  import "github.com/quay/claircore/toolkit/types/cpe"
     8  
     9  // Attribute is a type for enumerating the valid CPE attributes.
    10  type Attribute = cpe.Attribute
    11  
    12  // These are the valid Attributes, in CPE 2.3 binding order.
    13  const (
    14  	Part      = cpe.Part
    15  	Vendor    = cpe.Vendor
    16  	Product   = cpe.Product
    17  	Version   = cpe.Version
    18  	Update    = cpe.Update
    19  	Edition   = cpe.Edition
    20  	Language  = cpe.Language
    21  	SwEdition = cpe.SwEdition
    22  	TargetSW  = cpe.TargetSW
    23  	TargetHW  = cpe.TargetHW
    24  	Other     = cpe.Other
    25  )
    26  
    27  // NumAttr is the number of attributes in a 2.3 WFN.
    28  const NumAttr = cpe.NumAttr
    29  
    30  // Value represents all the states for an attribute's value.
    31  type Value = cpe.Value
    32  
    33  // NewValue constructs a specific value and ensures it's a valid string.
    34  //
    35  // This function does not quote the provided string, only validates that the
    36  // quoting is proper.
    37  func NewValue(v string) (Value, error) {
    38  	return cpe.NewValue(v)
    39  }
    40  
    41  // ValueKind indicates what "kind" a value is.
    42  type ValueKind = cpe.ValueKind
    43  
    44  // These are the valid states for a wfn attribute's value.
    45  const (
    46  	ValueUnset = cpe.ValueUnset
    47  	ValueAny   = cpe.ValueAny
    48  	ValueNA    = cpe.ValueNA
    49  	ValueSet   = cpe.ValueSet
    50  )
    51  
    52  // WFN is a well-formed name as defined by the Common Platform Enumeration (CPE)
    53  // spec: https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf
    54  //
    55  // This package does not implement binding into URI form.
    56  type WFN = cpe.WFN
    57  
    58  // ErrUnset is returned from (WFN).Valid() if it is the zero value.
    59  var ErrUnset = cpe.ErrUnset
    60  
    61  // Unbind attempts to unbind a string regardless of it be a formatted string or
    62  // URI.
    63  func Unbind(s string) (WFN, error) {
    64  	return cpe.Unbind(s)
    65  }
    66  
    67  // MustUnbind calls Unbind on the provided string, but panics if any errors are
    68  // encountered.
    69  //
    70  // This is primarily useful for static data where any error is a programmer
    71  // error.
    72  func MustUnbind(s string) WFN {
    73  	return cpe.MustUnbind(s)
    74  }
    75  
    76  // UnbindURI attempts to unbind a string as CPE 2.2 URI into a WFN.
    77  //
    78  // This function supports unpacking attributes from the "edition" component as
    79  // specified in CPE 2.3.
    80  func UnbindURI(s string) (WFN, error) {
    81  	return cpe.UnbindURI(s)
    82  }
    83  
    84  // UnbindFS attempts to unbind a string as CPE 2.3 formatted string into a WFN.
    85  func UnbindFS(s string) (WFN, error) {
    86  	return cpe.UnbindFS(s)
    87  }