|
30 | 30 | camForm.on('variables-restored', function () { |
31 | 31 | $scope.context = camForm.variableManager.variableValue('PROCESS_CONTEXT'); |
32 | 32 | $scope.targets = JSON.parse(camForm.variableManager.variableValue('PROCESS_TARGETS')); |
33 | | - $scope.portScannerResult = JSON.parse(camForm.variableManager.variableValue('PROCESS_FINDINGS')); |
| 33 | + const portScannerResult = JSON.parse(camForm.variableManager.variableValue('PROCESS_FINDINGS')); |
34 | 34 | $scope.portScannerId = camForm.variableManager.variableValue('PROCESS_SCANNER_ID'); |
35 | 35 |
|
36 | 36 | $scope.firstTarget = $scope.targets[0]; |
37 | 37 | $scope.otherTargetsLength = $scope.targets.length - 1; |
38 | 38 |
|
39 | | - $scope.groupedResults = $scope.portScannerResult.reduce( |
40 | | - function (carry, item) { |
41 | | - if (!carry.hasOwnProperty(item.attributes.hostname)) { |
42 | | - carry[item.attributes.hostname] = []; |
43 | | - } |
44 | | - carry[item.attributes.hostname].push(item); |
45 | | - return carry; |
46 | | - }, |
47 | | - {} |
| 39 | + const openPorts = portScannerResult.filter((finding) => finding.category === 'Open Port'); |
| 40 | + const hosts = portScannerResult.filter((finding) => finding.category === 'Host'); |
| 41 | + |
| 42 | + for(const host of hosts){ |
| 43 | + $scope.groupedResults[host.attributes.hostname] = []; |
| 44 | + } |
| 45 | + |
| 46 | + $scope.groupedResults = openPorts.reduce( |
| 47 | + function (carry, item) { |
| 48 | + if (!carry.hasOwnProperty(item.attributes.hostname)) { |
| 49 | + carry[item.attributes.hostname] = []; |
| 50 | + } |
| 51 | + carry[item.attributes.hostname].push(item); |
| 52 | + return carry; |
| 53 | + }, |
| 54 | + {} |
48 | 55 | ); |
49 | 56 | }); |
50 | 57 | </script> |
|
79 | 86 | </p> |
80 | 87 | </div> |
81 | 88 |
|
82 | | - <div class="well well-sm" style="color: inherit;" ng-repeat="(address, host) in groupedResults"> |
| 89 | + <div class="well well-sm" style="color: inherit;" ng-repeat="(address, ports) in groupedResults"> |
83 | 90 | <strong>Results for Host: {{ address }}</strong> |
84 | | - <table class="table table-striped"> |
| 91 | + <span class="table table-striped" ng-if="ports.length === 0"> |
| 92 | + No ports identified for this host. |
| 93 | + </span> |
| 94 | + <table class="table table-striped" ng-if="ports.length > 0"> |
85 | 95 | <tr> |
86 | 96 | <th>Host:</th> |
87 | 97 | <th>Port:</th> |
88 | 98 | <th>Name:</th> |
89 | 99 | <th>Protocol:</th> |
90 | 100 | <th>State:</th> |
91 | 101 | </tr> |
92 | | - <tr class="danger" ng-repeat="port in host"> |
| 102 | + <tr class="danger" ng-repeat="port in ports"> |
93 | 103 | <td>{{ address }} ({{ port.attributes.ip_address }})</td></td> |
94 | 104 | <td>{{ (port.category === 'Open Port' || port.category === 'Http Header') ? port.attributes.port : '' }}</td> |
95 | 105 | <td>{{ (port.category === 'Open Port' && !port.name) ? port.attributes.service : port.name}}</td> |
|
0 commit comments