-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validation for MAC and IP addresses in Measurement.Valid method #143
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ravjot Singh <[email protected]>
Signed-off-by: Ravjot Singh <[email protected]>
Signed-off-by: Ravjot Singh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ravjot07 thanks again for your contribution.
I have left a comment about supporting EUI-64 which should be easy to fix.
comid/measurement.go
Outdated
// Validate MAC Address | ||
if o.MACAddr != nil { | ||
if len(*o.MACAddr) != 6 { // MAC address must be exactly 6 bytes | ||
return fmt.Errorf("invalid MAC address length: expected 6 bytes, got %d", len(*o.MACAddr)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CoRIM spec allows for {MAC,EUI}-48 as well as EUI-64 formatted MAC addresses:
mac-addr-type-choice = eui48-addr-type / eui64-addr-type
eui48-addr-type = bytes .size 6
eui64-addr-type = bytes .size 8
Therefore, 8 is acceptable too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomas-fossati i have updated MAC address validation to allow EUI-48 and EUI-64 formats
Signed-off-by: Ravjot Singh <[email protected]>
Signed-off-by: Ravjot Singh <[email protected]>
@@ -26,7 +26,7 @@ var ( | |||
}) | |||
TestOID = "2.5.2.8192" | |||
TestRegID = "https://acme.example" | |||
TestMACaddr, _ = net.ParseMAC("02:00:5e:10:00:00:00:01") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last thing, I promise ;-)
If you revert this, the diff is smaller since the change to comid/example_test.go
becomes unnecessary.
Measurement.Valid
method, addressing the TODO comment: "MAC addr & friends."This PR close #18