|
39 | 39 | const openPorts = portScannerResult.filter((finding) => finding.category === 'Open Port'); |
40 | 40 | const hosts = portScannerResult.filter((finding) => finding.category === 'Host'); |
41 | 41 |
|
| 42 | + $scope.groupedResults = {}; |
| 43 | + |
42 | 44 | for(const host of hosts){ |
43 | | - $scope.groupedResults[host.attributes.hostname] = []; |
| 45 | + $scope.groupedResults[host.attributes.ip_address] = { hostname: host.attributes.hostname, ports: [] }; |
44 | 46 | } |
45 | 47 |
|
46 | 48 | $scope.groupedResults = openPorts.reduce( |
47 | 49 | 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); |
50 | 56 | } |
51 | | - carry[item.attributes.hostname].push(item); |
52 | 57 | return carry; |
53 | 58 | }, |
54 | | - {} |
| 59 | + $scope.groupedResults |
55 | 60 | ); |
56 | 61 | }); |
57 | 62 | </script> |
|
86 | 91 | </p> |
87 | 92 | </div> |
88 | 93 |
|
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"> |
92 | 101 | No ports identified for this host. |
93 | 102 | </span> |
94 | | - <table class="table table-striped" ng-if="ports.length > 0"> |
| 103 | + <table class="table table-striped" ng-if="host.ports.length > 0"> |
95 | 104 | <tr> |
96 | 105 | <th>Host:</th> |
97 | 106 | <th>Port:</th> |
98 | 107 | <th>Name:</th> |
99 | 108 | <th>Protocol:</th> |
100 | 109 | <th>State:</th> |
101 | 110 | </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> |
104 | 113 | <td>{{ (port.category === 'Open Port' || port.category === 'Http Header') ? port.attributes.port : '' }}</td> |
105 | 114 | <td>{{ (port.category === 'Open Port' && !port.name) ? port.attributes.service : port.name}}</td> |
106 | 115 | <td>{{ (port.category === 'Open Port' || port.category === 'Http Header') ? port.attributes.protocol : '' }}</td> |
|
0 commit comments