Documentation ¶
Index ¶
- Constants
- Variables
- func ContainsQuestions(str string) bool
- func ContainsWildcards(str string) bool
- func CountEscapeCharacters(str string) (result int)
- func GetUnescapedColonIndex(str string) (idx int)
- func IndexOf(str1, str2 string, off int) int
- func IsAlpha(r rune) bool
- func IsAlphanum(s string) bool
- func IsValidAttribute(attribute string) (valid bool)
- func LengthWithEscapeCharacters(str string) (result int)
- func ValidateFS(in string) error
- func ValidateStringValue(svalue string) (err error)
- func ValidateURI(in string) error
- type LogicalValue
- type WellFormedName
Constants ¶
const ( AttributePart = "part" AttributeVendor = "vendor" AttributeProduct = "product" AttributeVersion = "version" AttributeUpdate = "update" AttributeEdition = "edition" AttributeLanguage = "language" AttributeSwEdition = "sw_edition" AttributeTargetSw = "target_sw" AttributeTargetHw = "target_hw" AttributeOther = "other" )
Variables ¶
var ( // ErrIllegalAttribute is returned when illegal argument ErrIllegalAttribute = errors.New("Illegal attribute") // ErrParse is returned when parse error ErrParse = errors.New("Parse error") )
var ( // ErrIllegalArgument is returned when illegal argument ErrIllegalArgument = errors.New("Illegal argument") )
Functions ¶
func ContainsQuestions ¶
ContainsQuestions searches string for special characters ? @param string String to be searched @return true if string contains wildcard, false otherwise
func ContainsWildcards ¶
ContainsWildcards searches string for special characters * and ? @param string String to be searched @return true if string contains wildcard, false otherwise
func CountEscapeCharacters ¶
CountEscapeCharacters counts the number of escape characters in the string beginning and ending at the given indices @param str string to search @param start beginning index @param end ending index @return number of escape characters in string
func GetUnescapedColonIndex ¶
GetUnescapedColonIndex searches a string for the first unescaped colon and returns the index of that colon @param str string to search @return index of first unescaped colon, or 0 if not found
func IndexOf ¶
IndexOf searches a string for the first occurrence of another string, starting at a given offset. @param str1 String to search. @param str2 String to search for. @param off Integer offset or -1 if not found.
func IsAlphanum ¶
IsAlphanum returns true if the string contains only alphanumeric characters or the underscore character, false otherwise. @param c the string in question @return true if c is alphanumeric or underscore, false if not
func IsValidAttribute ¶
IsValidAttribute validates an attribute name
func LengthWithEscapeCharacters ¶
LengthWithEscapeCharacters counts the number of characters with escape characters
func ValidateFS ¶
ValidateFS is not part of the reference implementation pseudo code found in the CPE 2.3 specification. It enforces three rules found in the specification:
Formatted string must start with the characters "cpe:2.3:" A formatted string must contain 11 components A formatted string must not contain empty components
If any rule is violated, a ParseException is thrown.
func ValidateStringValue ¶
ValidateStringValue validates an string value
func ValidateURI ¶
ValidateURI is not part of the reference implementation pseudo code found in the CPE 2.3 specification. It enforces two rules in the specification:
URI must start with the characters "cpe:/" A URI may not contain more than 7 components
If either rule is violated, a ParseErr is thrown.
Types ¶
type LogicalValue ¶
LogicalValue represents a Logical Value. @see <a href="http://cpe.mitre.org">cpe.mitre.org</a> for more information. @author JKRAUNELIS @email jkraunelis@mitre.org
func NewLogicalValue ¶
func NewLogicalValue(t string) (lv LogicalValue, err error)
NewLogicalValue returns Logicalvalue
type WellFormedName ¶
type WellFormedName map[string]interface{}
WellFormedName represents a Well Formed Name, as defined in the CPE Specification version 2.3.
@see <a href="http://cpe.mitre.org">cpe.mitre.org</a> for details.
func NewWellFormedName ¶
func NewWellFormedName() WellFormedName
NewWellFormedName constructs a new WellFormedName object, with all components set to the default value "ANY".
func (WellFormedName) Get ¶
func (wfn WellFormedName) Get(attribute string) interface{}
Get gets attribute @param attribute String representing the component value to get @return the String value of the given component, or default value "ANY" if the component does not exist
func (WellFormedName) GetString ¶
func (wfn WellFormedName) GetString(attribute string) string
GetString gets attribute as string @param attribute String representing the component value to get @return the String value of the given component, or default value "ANY" if the component does not exist
func (WellFormedName) Initialize ¶
func (wfn WellFormedName) Initialize(part, vendor, product, version, update, edition, language, swEdition, targetSw, targetHw, other interface{})
Initialize sets each component to the given parameter value. If a parameter is null, the component is set to the default value "ANY". @param part string representing the part component @param vendor string representing the vendor component @param product string representing the product component @param version string representing the version component @param update string representing the update component @param edition string representing the edition component @param language string representing the language component @param sw_edition string representing the sw_edition component @param target_sw string representing the target_sw component @param target_hw string representing the target_hw component @param other string representing the other component
func (WellFormedName) Set ¶
func (wfn WellFormedName) Set(attribute string, value interface{}) (err error)
Set sets the given attribute to value, if the attribute is in the list of permissible components @param attribute String representing the component to set @param value Object representing the value of the given component
func (WellFormedName) String ¶
func (wfn WellFormedName) String() string
String returns string representation of the WellFormedName