chg: [MISP connector] added bulk org pull
parent
be64a186e0
commit
d3f08205fb
|
@ -907,6 +907,12 @@ class MispConnector extends CommonConnectorTools
|
|||
'reload_url' => '/localTools/action/' . h($params['connection']['id']) . '/organisationsAction',
|
||||
'popover_url' => '/localTools/action/' . h($params['connection']['id']) . '/fetchSelectedOrganisationsAction'
|
||||
],
|
||||
[
|
||||
'text' => __('Fetch all organisations'),
|
||||
'html' => '<i class="fas fa-download"></i> ',
|
||||
'reload_url' => '/localTools/action/' . h($params['connection']['id']) . '/organisationsAction',
|
||||
'popover_url' => '/localTools/action/' . h($params['connection']['id']) . '/fetchSelectedOrganisationsAction?ids=all'
|
||||
],
|
||||
[
|
||||
'text' => __('Push organisations'),
|
||||
'html' => '<i class="fas fa-upload"></i> ',
|
||||
|
@ -1190,16 +1196,34 @@ class MispConnector extends CommonConnectorTools
|
|||
return [
|
||||
'data' => [
|
||||
'title' => __('Fetch organisations'),
|
||||
'description' => __('Fetch and create/update the selected {0} organisations from MISP?', count($ids)),
|
||||
'description' => is_array($ids) ?
|
||||
__('Fetch and create/update the selected {0} organisations from MISP?', count($ids)) :
|
||||
__('Fetch and create/update ALL organisations from MISP?'),
|
||||
'submit' => [
|
||||
'action' => $params['request']->getParam('action')
|
||||
],
|
||||
'url' => ['controller' => 'localTools', 'action' => 'action', $params['connection']['id'], 'fetchSelectedOrganisationsAction']
|
||||
'url' => is_array($ids) ?
|
||||
['controller' => 'localTools', 'action' => 'action', $params['connection']['id'], 'fetchSelectedOrganisationsAction'] :
|
||||
['controller' => 'localTools', 'action' => 'action', $params['connection']['id'], 'fetchSelectedOrganisationsAction?ids=all']
|
||||
]
|
||||
];
|
||||
} elseif ($params['request']->is(['post'])) {
|
||||
$successes = 0;
|
||||
$errors = 0;
|
||||
if (!is_array($ids) && $ids === 'all') {
|
||||
$response = $this->getData('/organisations/index/scope:all', $params);
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$orgs = $response->getJson();
|
||||
foreach ($orgs as $org) {
|
||||
$result = $this->captureOrganisation($org['Organisation']);
|
||||
if ($result) {
|
||||
$successes++;
|
||||
} else {
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($ids as $id) {
|
||||
$response = $this->getData('/organisations/view/' . $id, $params);
|
||||
$result = $this->captureOrganisation($response->getJson()['Organisation']);
|
||||
|
@ -1209,6 +1233,7 @@ class MispConnector extends CommonConnectorTools
|
|||
$errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($successes) {
|
||||
return ['success' => 1, 'message' => __('The fetching of organisations has succeeded. {0} organisations created/modified and {1} organisations could not be created/modified.', $successes, $errors)];
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue