openvnet
openvnet copied to clipboard
Check IP address network range in the WebAPI
Problem
https://github.com/axsh/openvnet/pull/311 fixed an issue where IP addresses assigned in a Network without being in the correct subnet. It has implemented that check in the Model classes which is correct, but it also needs to be done in the WebAPI.
We should fail as early as possible and don't have to wait until the code reaches the database layer.
Solution
- Leave the check in the Model classes in place. Not all database access will come form the WebAPI.
- Implement the same check in the WebAPI. Optionally this can be done by adding a new file
ip_address_helper.rb
in the helpers directory and implementing the check in a module there that will be included in both the Model classes and the WebAPI.
Something like this https://github.com/axsh/openvnet/commit/d074fe63abd6de80f2afe63d2e26c1bfc0cc1231 ?
Isn't this related to https://github.com/axsh/openvnet/issues/263 ?
It is similar to https://github.com/axsh/openvnet/issues/263. That one implemented a check in the model classes. The thing is we should have a check in the WebAPI too.
If a user sends a faulty IP/subnet combo on their API request, we should return an error immediately and not let it go all the way to the model classes.
The check in the model classes still needs to stay in place since IP addresses can also be created without using the WebAPI.