Skip to content
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

Added "vendor" to host response #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Rickyc81
Copy link

Hi, I needed to read the network card vendor of the devices contacted, I saw that you didn't add it in your code, I did it.. it's my first PR, let me know..
Thank you!!

Riccardo

Copy link
Owner

@Ayrx Ayrx left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I've left some quick comments.

tests/test.xml Outdated
@@ -7,7 +7,7 @@
<verbose level="0"/>
<debugging level="0"/>
<host starttime="1588318812" endtime="1588318814"><status state="up" reason="echo-reply" reason_ttl="53"/>
<address addr="45.33.32.156" addrtype="ipv4"/>
<address addr="45.33.32.156" addrtype="ipv4" vendor="VMware"/>
Copy link
Owner

Choose a reason for hiding this comment

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

This is very clearly wrong as addrtype="ipv4". tests/issue_1.xml has a valid example of a addrtype="mac".

src/host.rs Outdated
@@ -97,8 +97,15 @@ fn parse_address_node(node: Node) -> Result<Address, Error> {
.attribute("addr")
.ok_or_else(|| Error::from("expected `addr` attribute in `address` node"))?;

let vendor = node
.attribute("vendor")
.unwrap_or_default();
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like this approach. If the vendor field is always present, we should just use .expect() here with the expectation that it should never fail. If the vendor field is option, it should be an Option<String>.

Copy link
Author

Choose a reason for hiding this comment

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

The problem is that the vendor field isnt always present on nmap output..
image
Check this..
And for this i set the vendor field to an empty string if the field is not found..

what do you think about it?

Ric

Copy link
Owner

Choose a reason for hiding this comment

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

In that case, Option<String> is the perfect type for that.

Copy link
Author

Choose a reason for hiding this comment

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

In that case, Option<String> is the perfect type for that.

Ok thanks, i'll try to fix it.. :)

@Rickyc81
Copy link
Author

Thanks for reply!!!!! :)

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.

2 participants