1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-11 02:09:03 +00:00

Don't ignore host state changes when the change is to the state "unknown". This

happens when a host was scanned in the A scan but wasn't scanned in the B scan.
I previously had it ignore such changes using the logic that the diff should be
like scan aggregation: no new information means no state change. But I think
it's more useful to see those changes in which hosts were scanned.

This is analogous to r10263, which did the same thing for port state changes.
This commit is contained in:
david
2009-01-20 21:02:15 +00:00
parent 47198b7159
commit c4b27a31b4
3 changed files with 18 additions and 6 deletions

View File

@@ -36,6 +36,12 @@ Here is a sample of the text output:
Add ipv4 address 10.242.160.155.
Add hostname ywnleu-108.example.com.
1000 tcp ports are filtered.
fiyrownc-307.example.com (10.65.53.252):
Host is unknown, was up.
Remove ipv4 address 10.65.53.252.
Remove hostname fiyrownc-307.example.com.
8089/tcp is unknown, was open.
999 tcp ports changed state from filtered to unknown.
Here is an abbreviated sample of the XML output:

View File

@@ -447,7 +447,6 @@ def scan_diff(a, b):
for id in all_host_ids:
host_a = a_hosts.get(id)
host_b = b_hosts.get(id)
if host_b is not None and host_b.state != Host.UNKNOWN:
h_diff = host_diff(host_a or Host(), host_b or Host())
if len(h_diff) > 0:
diff.append((host_a or host_b, h_diff))

View File

@@ -487,7 +487,7 @@ class scan_diff_test(unittest.TestCase):
for host, h_diff in diff:
for hunk in h_diff:
if hunk.type == HOST_STATE_CHANGE:
self.assertTrue(hunk.a_state == Port.UNKNOWN)
self.assertTrue(hunk.a_state == Host.UNKNOWN)
self.assertTrue(hunk.b_state == u"up")
break
else:
@@ -499,7 +499,14 @@ class scan_diff_test(unittest.TestCase):
b = Scan()
b.load_from_file("test-scans/empty.xml")
diff = scan_diff(a, b)
self.assertTrue(len(diff) == 0)
for host, h_diff in diff:
for hunk in h_diff:
if hunk.type == HOST_STATE_CHANGE:
self.assertTrue(hunk.a_state == u"up")
self.assertTrue(hunk.b_state == Port.UNKNOWN)
break
else:
fail("No host state change found.")
def test_diff_is_effective(self):
"""Test that a scan diff is effective.