Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit 31e175e

Browse files
committed
Use ip as host id instead of hostname
1 parent 6f02eec commit 31e175e

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

scb-scanprocesses/nmap-process/src/main/resources/forms/nmap/approve-port-scanner-results.html

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@
3939
const openPorts = portScannerResult.filter((finding) => finding.category === 'Open Port');
4040
const hosts = portScannerResult.filter((finding) => finding.category === 'Host');
4141

42+
$scope.groupedResults = {};
43+
4244
for(const host of hosts){
43-
$scope.groupedResults[host.attributes.hostname] = [];
45+
$scope.groupedResults[host.attributes.ip_address] = { hostname: host.attributes.hostname, ports: [] };
4446
}
4547

4648
$scope.groupedResults = openPorts.reduce(
4749
function (carry, item) {
48-
if (!carry.hasOwnProperty(item.attributes.hostname)) {
49-
carry[item.attributes.hostname] = [];
50+
console.log(item);
51+
if (!carry.hasOwnProperty(item.attributes.ip_address)) {
52+
carry[item.attributes.ip_address] = { hostname: item.attributes.hostname, ports: [] };
53+
}
54+
if(item.attributes.ip_address !== null){
55+
carry[item.attributes.ip_address].ports.push(item);
5056
}
51-
carry[item.attributes.hostname].push(item);
5257
return carry;
5358
},
54-
{}
59+
$scope.groupedResults
5560
);
5661
});
5762
</script>
@@ -86,21 +91,25 @@ <h2>
8691
</p>
8792
</div>
8893

89-
<div class="well well-sm" style="color: inherit;" ng-repeat="(address, ports) in groupedResults">
90-
<strong>Results for Host: {{ address }}</strong>
91-
<span class="table table-striped" ng-if="ports.length === 0">
94+
<div class="well well-sm" style="color: inherit;" ng-repeat="(ip, host) in groupedResults">
95+
<strong>
96+
Results for Host:
97+
<span>{{ ip }}</span>
98+
<span ng-if="host.hostname">({{host.hostname}})</span>
99+
</strong>
100+
<span class="table table-striped" ng-if="host.ports.length === 0">
92101
No ports identified for this host.
93102
</span>
94-
<table class="table table-striped" ng-if="ports.length > 0">
103+
<table class="table table-striped" ng-if="host.ports.length > 0">
95104
<tr>
96105
<th>Host:</th>
97106
<th>Port:</th>
98107
<th>Name:</th>
99108
<th>Protocol:</th>
100109
<th>State:</th>
101110
</tr>
102-
<tr class="danger" ng-repeat="port in ports">
103-
<td>{{ address }} ({{ port.attributes.ip_address }})</td></td>
111+
<tr class="danger" ng-repeat="port in host.ports">
112+
<td>{{ port.attributes.ip_address }}</td></td>
104113
<td>{{ (port.category === 'Open Port' || port.category === 'Http Header') ? port.attributes.port : '' }}</td>
105114
<td>{{ (port.category === 'Open Port' && !port.name) ? port.attributes.service : port.name}}</td>
106115
<td>{{ (port.category === 'Open Port' || port.category === 'Http Header') ? port.attributes.protocol : '' }}</td>

0 commit comments

Comments
 (0)