Skip to content

Commit

Permalink
fix(measurement): enhance Valid method to check Extensions for measur…
Browse files Browse the repository at this point in the history
…ement values

Signed-off-by: Priyanshu Thapliyal <[email protected]>
  • Loading branch information
Priyanshuthapliyal2005 committed Dec 24, 2024
1 parent b690f86 commit e6b0fdc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion comid/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ func (o Mval) MarshalJSON() ([]byte, error) {
}

func (o Mval) Valid() error {
// Check if all base types are nil and Extensions are not nil
if o.Ver == nil &&
o.SVN == nil &&
o.Digests == nil &&
Expand All @@ -436,7 +437,10 @@ func (o Mval) Valid() error {
o.UEID == nil &&
o.UUID == nil &&
o.IntegrityRegisters == nil {
return fmt.Errorf("no measurement value set")

if o.Extensions.IsEmpty() {
return fmt.Errorf("no measurement value set")
}
}

if o.Ver != nil {
Expand Down

0 comments on commit e6b0fdc

Please sign in to comment.