Skip to content

Commit 4efe108

Browse files
committed
docs: add documentation comments to validation helper methods
Add proper godoc comments to Tag validation methods: - Valid(): Documents tag content validation strategy - validateComidTag(): Describes CoMID tag validation - validateCoswidTag(): Describes CoSWID tag validation - validateGenericCBOR(): Describes generic CBOR validation These comments improve code documentation and help future maintainers understand the validation flow for different tag types. Signed-off-by: 7908837174 <[email protected]> Signed-off-by: Kallal Mukherjee <[email protected]>
1 parent 85a4062 commit 4efe108

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

corim/unsignedcorim.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ type Tag struct {
342342
Content []byte
343343
}
344344

345+
// Valid validates the tag content based on its tag number.
346+
// For CoMID tags (506), it unmarshals and validates the content.
347+
// For CoSWID tags (505), it validates the CoSWID structure.
348+
// For other tags, it ensures the content is valid CBOR.
345349
func (o Tag) Valid() error {
346350
if len(o.Content) == 0 {
347351
return errors.New("empty tag")
@@ -357,6 +361,7 @@ func (o Tag) Valid() error {
357361
}
358362
}
359363

364+
// validateComidTag unmarshals and validates CoMID tag content.
360365
func (o Tag) validateComidTag() error {
361366
var c comid.Comid
362367
if err := dm.Unmarshal(o.Content, &c); err != nil {
@@ -370,6 +375,7 @@ func (o Tag) validateComidTag() error {
370375
return nil
371376
}
372377

378+
// validateCoswidTag validates CoSWID tag content by attempting to unmarshal it.
373379
func (o Tag) validateCoswidTag() error {
374380
var s swid.SoftwareIdentity
375381
if err := dm.Unmarshal(o.Content, &s); err != nil {
@@ -379,6 +385,7 @@ func (o Tag) validateCoswidTag() error {
379385
return nil
380386
}
381387

388+
// validateGenericCBOR ensures the tag content is valid CBOR for unknown tag types.
382389
func (o Tag) validateGenericCBOR() error {
383390
var raw interface{}
384391
if err := dm.Unmarshal(o.Content, &raw); err != nil {

0 commit comments

Comments
 (0)