chg: [wip] local tools integration
parent
551ca0d83f
commit
2e9b306f46
|
@ -205,6 +205,9 @@ class LocalToolsController extends AppController
|
|||
{
|
||||
$this->loadModel('Broods');
|
||||
$tools = $this->Broods->queryLocalTools($id);
|
||||
foreach ($tools as $k => $tool) {
|
||||
$tools[$k]['local_tools'] = $this->LocalTools->appendLocalToolConnections($id, $tool);
|
||||
}
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->RestResponse->viewData($tools, 'json');
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ class CommonConnectorTools
|
|||
'created' => time(),
|
||||
'modified' => time()
|
||||
];
|
||||
debug($entry);
|
||||
$data = $remoteToolConnections->patchEntity($data, $entry);
|
||||
$remoteToolConnections->save($data);
|
||||
} else {
|
||||
|
|
|
@ -579,6 +579,12 @@ class MispConnector extends CommonConnectorTools
|
|||
|
||||
public function finaliseConnection(array $params): bool
|
||||
{
|
||||
$params['sync_connection'] = $this->addServer([
|
||||
'authkey' => $params['remote_tool']['authkey'],
|
||||
'url' => $params['remote_tool']['url'],
|
||||
'name' => $params['remote_tool']['name'],
|
||||
'remote_org_id' => $params['misp_organisation']['id']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,4 +223,17 @@ class LocalToolsTable extends AppTable
|
|||
//'message' =>
|
||||
];
|
||||
}
|
||||
|
||||
public function appendLocalToolConnections(int $brood_id, array $tool): array
|
||||
{
|
||||
$remoteToolConnections = \Cake\ORM\TableRegistry::getTableLocator()->get('RemoteToolConnections');
|
||||
$connections = $remoteToolConnections->find()->where(['remote_tool_id' => $tool['id'], 'brood_id' => $brood_id])->toArray();
|
||||
$local_tools = [];
|
||||
foreach ($connections as $k => $connection) {
|
||||
$temp = $this->find()->where(['id' => $connection['local_tool_id']])->select(['id', 'name'])->enableHydration(false)->first();
|
||||
$temp['status'] = $connection['status'];
|
||||
$local_tools[] = $temp;
|
||||
}
|
||||
return $local_tools;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,11 @@ echo $this->element('genericElements/IndexTable/index_table', [
|
|||
[
|
||||
'name' => __('Description'),
|
||||
'data_path' => 'description',
|
||||
],
|
||||
[
|
||||
'name' => __('Connected Local Tools'),
|
||||
'data_path' => 'local_tool',
|
||||
'element' => 'local_tools_status'
|
||||
]
|
||||
],
|
||||
'title' => __('Local tools made available by the remote Cerebrate'),
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
$tools = $this->Hash->extract($row, 'local_tools');
|
||||
$output = [];
|
||||
foreach ($tools as $tool) {
|
||||
$output[] = sprintf(
|
||||
'<a href="/localTools/view/%s">%s</a>: %s',
|
||||
h($tool['id']),
|
||||
h($tool['name']),
|
||||
h($tool['status'])
|
||||
);
|
||||
}
|
||||
echo implode('<br />', $output);
|
||||
?>
|
Loading…
Reference in New Issue