From 2580300f01b30ce7ec99df4986e9c9489f7c5d9b Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 3 Feb 2022 08:34:46 -0500 Subject: internal/cpe: s/Binding/V23Binding/ --- internal/cpe/binding.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'internal/cpe/binding.go') diff --git a/internal/cpe/binding.go b/internal/cpe/binding.go index f58752e..24fb7b2 100644 --- a/internal/cpe/binding.go +++ b/internal/cpe/binding.go @@ -8,7 +8,7 @@ import ( ) // CPE 2.3 binding. -type Binding struct { +type V23Binding struct { Part Part // Part attribute (NISTIR7695 5.3.3.1). Vendor AvString // Vendor attribute (NISTIR7695 5.3.3.2). Product AvString // Product attribute (NISTIR7695 5.3.3.3). @@ -29,40 +29,40 @@ var cpe23Prefix = "cpe:2.3:" var missingPrefix = errors.New("missing CPE 2.3 prefix") // Create binding from CPE 2.3 formatted string. -func NewBinding(s string) (Binding, error) { +func NewV23Binding(s string) (V23Binding, error) { // check prefix if s[0:len(cpe23Prefix)] != cpe23Prefix { - return Binding{}, missingPrefix + return V23Binding{}, missingPrefix } // tokenize string, check for error toks, err := tokenize([]byte(s[len(cpe23Prefix):])) if err != nil { - return Binding{}, err + return V23Binding{}, err } // check token count if len(toks) != 11 { err = fmt.Errorf("invalid attribute count: %d != 11", len(toks)) - return Binding{}, err + return V23Binding{}, err } // create part part, err := newPart(toks[0]) if err != nil { - return Binding{}, err + return V23Binding{}, err } // parse tokens into strings strs := make([]AvString, len(toks) - 1) for i, t := range(toks[1:]) { if strs[i], err = newAvString(t); err != nil { - return Binding{}, err + return V23Binding{}, err } } // build and return result - return Binding { + return V23Binding { Part: part, Vendor: strs[0], Product: strs[1], @@ -77,8 +77,8 @@ func NewBinding(s string) (Binding, error) { }, nil } -// Serialize binding as CPE 2.3 formatted string. -func (v Binding) String() string { +// Serialize CPE 2.3 binding as formatted string. +func (v V23Binding) String() string { return cpe23Prefix + strings.Join([]string { v.Part.String(), v.Vendor.String(), @@ -94,8 +94,8 @@ func (v Binding) String() string { }, ":") } -// Unmarshal CPE binding from JSON string. -func (me *Binding) UnmarshalJSON(b []byte) error { +// Unmarshal CPE 2.3 binding from JSON string. +func (me *V23Binding) UnmarshalJSON(b []byte) error { // decode json string var s string if err := json.Unmarshal(b, &s); err != nil { @@ -103,7 +103,7 @@ func (me *Binding) UnmarshalJSON(b []byte) error { } // create binding - binding, err := NewBinding(s) + binding, err := NewV23Binding(s) if err != nil { return err } @@ -114,6 +114,6 @@ func (me *Binding) UnmarshalJSON(b []byte) error { } // Marshal CPE binding as JSON string. -func (v Binding) MarshalJSON() ([]byte, error) { +func (v V23Binding) MarshalJSON() ([]byte, error) { return json.Marshal(v.String()) } -- cgit v1.2.3