aboutsummaryrefslogtreecommitdiff
path: root/internal/cpe
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cpe')
-rw-r--r--internal/cpe/binding.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/cpe/binding.go b/internal/cpe/binding.go
index 8c51d7d..f58752e 100644
--- a/internal/cpe/binding.go
+++ b/internal/cpe/binding.go
@@ -7,7 +7,7 @@ import (
"strings"
)
-// Common Platform Enumeration binding.
+// CPE 2.3 binding.
type Binding struct {
Part Part // Part attribute (NISTIR7695 5.3.3.1).
Vendor AvString // Vendor attribute (NISTIR7695 5.3.3.2).
@@ -22,13 +22,13 @@ type Binding struct {
Other AvString // Other attribute (NISTIR7695 5.3.3.11).
}
-// cpe 2.3 formatted string prefix
+// formatted string prefix
var cpe23Prefix = "cpe:2.3:"
// missing prefix error
var missingPrefix = errors.New("missing CPE 2.3 prefix")
-// Create CPE 2.3 binding from formatted string.
+// Create binding from CPE 2.3 formatted string.
func NewBinding(s string) (Binding, error) {
// check prefix
if s[0:len(cpe23Prefix)] != cpe23Prefix {
@@ -77,6 +77,7 @@ func NewBinding(s string) (Binding, error) {
}, nil
}
+// Serialize binding as CPE 2.3 formatted string.
func (v Binding) String() string {
return cpe23Prefix + strings.Join([]string {
v.Part.String(),
@@ -93,7 +94,7 @@ func (v Binding) String() string {
}, ":")
}
-// Unmarshal CPE formatted string from JSON string.
+// Unmarshal CPE binding from JSON string.
func (me *Binding) UnmarshalJSON(b []byte) error {
// decode json string
var s string
@@ -112,7 +113,7 @@ func (me *Binding) UnmarshalJSON(b []byte) error {
return nil
}
-// Marshal CPE formatted string as JSON string.
+// Marshal CPE binding as JSON string.
func (v Binding) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
}