mirror of https://github.com/MISP/MISP
chg: [galaxyClusters] Improved logging and error reporting
parent
ad81a03813
commit
95cbfa2878
|
@ -279,10 +279,10 @@ class Galaxy extends AppModel
|
|||
$saveResult = $this->GalaxyCluster->captureClusters($user, $existingGalaxy, $clusters, $forceUpdate=$forceUpdate, $orgId=$user['org_id']);
|
||||
$results['imported'] += $saveResult['imported'];
|
||||
$results['ignored'] += $saveResult['ignored'];
|
||||
$results['failed'] += $saveResult['failed'];
|
||||
$results['errors'] = array_merge($results['errors'], $saveResult['errors']);
|
||||
}
|
||||
$results['success'] = $results['imported'] > 0;
|
||||
debug($results);
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,21 +220,18 @@ class GalaxyCluster extends AppModel
|
|||
|
||||
public function captureClusters($user, $galaxy, $clusters, $forceUpdate=false, $orgId=0)
|
||||
{
|
||||
$importResult = array('success' => false, 'imported' => 0, 'ignored' => 0, 'errors' => array());
|
||||
$importResult = array('success' => false, 'imported' => 0, 'ignored' => 0, 'failed' => 0,'errors' => array());
|
||||
foreach ($clusters as $k => $cluster) {
|
||||
$cluster['GalaxyCluster']['galaxy_id'] = $galaxy['Galaxy']['id'];
|
||||
$saveResult = $this->captureCluster($user, $cluster, $fromPull=true, $orgId=$orgId);
|
||||
if ($saveResult) {
|
||||
$importResult['imported'] += 1;
|
||||
} else {
|
||||
$importResult['ignored'] += 1;
|
||||
}
|
||||
$importResult['imported'] += $saveResult['imported'];
|
||||
$importResult['ignored'] += $saveResult['ignored'];
|
||||
$importResult['failed'] += $saveResult['failed'];
|
||||
$importResult['errors'] = array_merge($importResult['errors'], $saveResult['errors']);
|
||||
}
|
||||
if ($importResult['imported'] > 0) {
|
||||
$importResult['success'] = true;
|
||||
}
|
||||
$importResult['errors'] = array_merge($importResult['errors'], $saveResult['errors']);
|
||||
debug($importResult);
|
||||
return $importResult;
|
||||
}
|
||||
|
||||
|
@ -287,7 +284,7 @@ class GalaxyCluster extends AppModel
|
|||
} else {
|
||||
$orgc = array('Orgc' => array('uuid' => $cluster['GalaxyCluster']['Orgc']['uuid']));
|
||||
}
|
||||
if ($this->OrgBlacklist->hasAny(array('OrgBlacklist.org_uuid' => $orgc['Orgc']['uuid']))) {
|
||||
if ($cluster['GalaxyCluster']['orgc_id'] != 0 && $this->OrgBlacklist->hasAny(array('OrgBlacklist.org_uuid' => $orgc['Orgc']['uuid']))) {
|
||||
$results['failed']++; // Organisation blacklisted
|
||||
return $results;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class GalaxyClusterRelationTag extends AppModel
|
|||
$saveResult = $this->save(array('galaxy_cluster_relation_id' => $galaxyClusterRelationId, 'tag_id' => $tagId));
|
||||
$allSaved = $allSaved && $saveResult;
|
||||
if (!$saveResult) {
|
||||
debug($saveResult);
|
||||
$this->Log->createLogEntry($user, 'attachTags', 'GalaxyClusterRelationTag', 0, __('Could not attach tag %s', $tagName), __('relation (%s)', $galaxyClusterRelationId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class Log extends AppModel
|
|||
'acceptRegistrations',
|
||||
'add',
|
||||
'admin_email',
|
||||
'attachTags',
|
||||
'auth',
|
||||
'auth_fail',
|
||||
'blacklisted',
|
||||
|
|
Loading…
Reference in New Issue