-
Notifications
You must be signed in to change notification settings - Fork 3
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 scan subnet functionality #4
base: master
Are you sure you want to change the base?
Conversation
@fklement I chose to use the same add_target/1 function to do the subnet scan. It would be intuitive for most nmap users to just add the "/24", "16" subnet at the end eg (add_target("192.168.100.1/24") instead of having add_target(ip, "/24"). |
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.
Overall a good implementation. Would be nice if you address my comments.
Since I also want to increase the test coverage of this library, it would be nice if you could write some tests for different use cases.
case Helpers.check_ip_address(target_ip) do | ||
{:ok, ip} -> ip | ||
case Helpers.check_ip_address(ip_address) do | ||
{:ok, ip} -> if subnet == nil do ip else "#{ip}#{"/"}#{subnet}" end |
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.
I'm not quite sure why you first split the target and then stitch it back together without any checking.
It would be nice if you could include some test here to see if the subnet mask one specified is valid.
|
||
port = | ||
Port.open({:spawn, "nmap #{option} -oX #{path} #{target}"}, [ | ||
Port.open({:spawn, command}, [ |
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.
I think the code would look cleaner if you continue to use the old "structure" nmap #{option} -oX #{path}...
.
Just use the target
variable to compose the given #{target} / #{subnet}
or #{target}
.
Another option that just came in my mind would be to build the target string in the hades.ex
module so you don't have to handle this here. I think this would reduce the overall loc a bit.
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.
I agree on making the code cleaner. Will work on this.
Hey, any merge timeline on this? |
I have not had the time to work on the suggestions requested by @fklement but my fork does have a working implementation. |
This feature contains the following changes: