1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

Fix saving of host comments in Zenmap. Fixes #133

Sometimes (all the time?) hosts are "cloned" or deep-copied instead of being
copied by reference, so testing whether a host is "in" a scan is insufficient.
Now we check by address, the same way that Zenmap uses to determine 2 hosts are
the "same" for merging their output.

Also, avoid considering a scan as having unsaved changes if the comment field is
merely focused but unchanged.
This commit is contained in:
dmiller
2015-05-31 02:47:26 +00:00
parent 939d42209f
commit 41e06e9e9c

View File

@@ -831,12 +831,18 @@ class ScanInterface(HIGVBox):
"""Sets the comment on a host from the contents of the comment text
entry."""
buff = widget.get_buffer()
host.comment = buff.get_text(
comment = buff.get_text(
buff.get_start_iter(), buff.get_end_iter())
if host.comment == comment:
# no change, ignore
return
host.comment = comment
for scan in self.inventory.get_scans():
if host in scan.get_hosts():
scan.unsaved = True
break
for h in scan.get_hosts():
if h.get_ip() == host.get_ip() and h.get_ipv6() == host.get_ipv6():
h.set_comment(host.comment)
scan.unsaved = True
break
def build_host_details(self, hosts):
"""Builds and returns a list of "Host Details" pages corresponding to