8000 Add validation for MAC and IP addresses in Measurement.Valid method by ravjot07 · Pull Request #143 · veraison/corim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add validation for MAC and IP addresses in Measurement.Valid method #143

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

Merged
merged 6 commits into from
Jan 11, 2025

Conversation

ravjot07
Copy link
Contributor
  • Implemented validation for MAC and IP addresses in the Measurement.Valid method, addressing the TODO comment: "MAC addr & friends."
  • Ensured the method correctly validates the format and presence of MAC and IP addresses where applicable.
  • Added test cases to verify the behavior of the validation logic.

This PR close #18

Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
Copy link
Contributor
@thomas-fossati thomas-fossati left a 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.

Comment on lines 464 to 469
// 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))
}
}
Copy link
Contributor

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.

Copy link
Contributor Author

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 <ravu2004@gmail.com>
Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
@@ -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")
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomas-fossati pl review sir

Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
Copy link
Contributor
@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my comments.

@ravjot07
Copy link
Contributor Author
ravjot07 commented Jan 11, 2025

Thank you for addressing my comments.

Thanks @thomas-fossati for your reviews and guidance, any other changes??

@thomas-fossati thomas-fossati merged commit 8f38e74 into veraison:main Jan 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate binary MAC and IP addresses
3 participants
0