mirror of https://github.com/MISP/MISP
commit
9ca82a568e
|
@ -1254,10 +1254,6 @@ class EventsController extends AppController
|
|||
$warningTagConflicts = array();
|
||||
$filters = $this->_harvestParameters($filterData, $exception);
|
||||
|
||||
$this->loadModel('GalaxyCluster');
|
||||
if (!$this->_isRest()) {
|
||||
//$attack = $this->GalaxyCluster->Galaxy->constructAttackReport($event);
|
||||
}
|
||||
$emptyEvent = (empty($event['Object']) && empty($event['Attribute']));
|
||||
$this->set('emptyEvent', $emptyEvent);
|
||||
$attributeCount = isset($event['Attribute']) ? count($event['Attribute']) : 0;
|
||||
|
@ -1587,32 +1583,31 @@ class EventsController extends AppController
|
|||
$conditions['includeServerCorrelations'] = $this->params['named']['includeServerCorrelations'];
|
||||
}
|
||||
$results = $this->Event->fetchEvent($this->Auth->user(), $conditions);
|
||||
if (!empty($this->params['named']['includeGranularCorrelations'])) {
|
||||
foreach ($results as $k => $event) {
|
||||
if (!empty($event['RelatedAttribute'])) {
|
||||
foreach ($event['RelatedAttribute'] as $attribute_id => $relation) {
|
||||
foreach ($event['Attribute'] as $k2 => $attribute) {
|
||||
if ((int)$attribute['id'] == $attribute_id) {
|
||||
$results[$k]['Attribute'][$k2]['RelatedAttribute'][] = $relation;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
foreach ($event['Object'] as $k2 => $object) {
|
||||
foreach ($object['Attribute'] as $k3 => $attribute) {
|
||||
if ((int)$attribute['id'] == $attribute_id) {
|
||||
$results[$k]['Object'][$k2]['Attribute'][$k3]['RelatedAttribute'][] = $relation;
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
if (empty($results)) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
$event = $results[0];
|
||||
|
||||
// Attach related attributes to proper attribute
|
||||
if (!empty($this->params['named']['includeGranularCorrelations']) && !empty($event['RelatedAttribute'])) {
|
||||
foreach ($event['RelatedAttribute'] as $attribute_id => $relation) {
|
||||
foreach ($event['Attribute'] as $k2 => $attribute) {
|
||||
if ((int)$attribute['id'] == $attribute_id) {
|
||||
$event['Attribute'][$k2]['RelatedAttribute'][] = $relation;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
foreach ($event['Object'] as $k2 => $object) {
|
||||
foreach ($object['Attribute'] as $k3 => $attribute) {
|
||||
if ((int)$attribute['id'] == $attribute_id) {
|
||||
$event['Object'][$k2]['Attribute'][$k3]['RelatedAttribute'][] = $relation;
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($results)) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
$event = $results[0];
|
||||
|
||||
$this->Event->id = $event['Event']['id'];
|
||||
if (isset($this->params['named']['searchFor']) && $this->params['named']['searchFor'] !== '') {
|
||||
$this->__applyQueryString($event, $this->params['named']['searchFor']);
|
||||
|
@ -1626,11 +1621,11 @@ class EventsController extends AppController
|
|||
|
||||
if ($this->_isRest()) {
|
||||
$this->set('event', $event);
|
||||
}
|
||||
$this->set('deleted', isset($deleted) ? ($deleted == 2 ? 0 : 1) : 0);
|
||||
$this->set('includeRelatedTags', (!empty($this->params['named']['includeRelatedTags'])) ? 1 : 0);
|
||||
$this->set('includeDecayScore', (!empty($this->params['named']['includeDecayScore'])) ? 1 : 0);
|
||||
if (!$this->_isRest()) {
|
||||
} else {
|
||||
$this->set('deleted', isset($deleted) ? ($deleted == 2 ? 0 : 1) : 0);
|
||||
$this->set('includeRelatedTags', (!empty($this->params['named']['includeRelatedTags'])) ? 1 : 0);
|
||||
$this->set('includeDecayScore', (!empty($this->params['named']['includeDecayScore'])) ? 1 : 0);
|
||||
|
||||
if ($this->_isSiteAdmin() && $event['Event']['orgc_id'] !== $this->Auth->user('org_id')) {
|
||||
$this->Flash->info(__('You are currently logged in as a site administrator and about to edit an event not belonging to your organisation. This goes against the sharing model of MISP. Use a normal user account for day to day work.'));
|
||||
}
|
||||
|
|
|
@ -5635,84 +5635,84 @@ class Event extends AppModel
|
|||
|
||||
public function getSightingData(array $event)
|
||||
{
|
||||
$this->Sighting = ClassRegistry::init('Sighting');
|
||||
if (!empty($event['Sighting'])) {
|
||||
$sightingsData = array();
|
||||
$sparklineData = array();
|
||||
$startDates = array();
|
||||
$range = $this->Sighting->getMaximumRange();
|
||||
foreach ($event['Sighting'] as $sighting) {
|
||||
$type = $this->Sighting->type[$sighting['type']];
|
||||
if (!isset($sightingsData[$sighting['attribute_id']][$type])) {
|
||||
$sightingsData[$sighting['attribute_id']][$type] = array('count' => 0);
|
||||
}
|
||||
$sightingsData[$sighting['attribute_id']][$type]['count']++;
|
||||
$orgName = isset($sighting['Organisation']['name']) ? $sighting['Organisation']['name'] : 'Others';
|
||||
if ($sighting['type'] == '0' && (!isset($startDates[$sighting['attribute_id']]) || $startDates[$sighting['attribute_id']] > $sighting['date_sighting'])) {
|
||||
if ($sighting['date_sighting'] >= $range) {
|
||||
$startDates[$sighting['attribute_id']] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
if ($sighting['type'] == '0' && (!isset($startDates['event']) || $startDates['event'] > $sighting['date_sighting'])) {
|
||||
if ($sighting['date_sighting'] >= $range) {
|
||||
$startDates['event'] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
if (!isset($sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName])) {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName] = array('count' => 1, 'date' => $sighting['date_sighting']);
|
||||
} else {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['count']++;
|
||||
if ($sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['date'] < $sighting['date_sighting']) {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['date'] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
if ($sighting['type'] !== '0') {
|
||||
continue;
|
||||
}
|
||||
$date = date("Y-m-d", $sighting['date_sighting']);
|
||||
if (!isset($sparklineData[$sighting['attribute_id']][$date])) {
|
||||
$sparklineData[$sighting['attribute_id']][$date] = 1;
|
||||
} else {
|
||||
$sparklineData[$sighting['attribute_id']][$date]++;
|
||||
}
|
||||
if (!isset($sparklineData['event'][$date])) {
|
||||
$sparklineData['event'][$date] = 1;
|
||||
} else {
|
||||
$sparklineData['event'][$date]++;
|
||||
}
|
||||
}
|
||||
$csv = array();
|
||||
$today = strtotime(date('Y-m-d', time()));
|
||||
foreach ($startDates as $k => $v) {
|
||||
$startDates[$k] = date('Y-m-d', $v);
|
||||
}
|
||||
foreach ($sparklineData as $aid => $data) {
|
||||
if (!isset($startDates[$aid])) {
|
||||
continue;
|
||||
}
|
||||
$startDate = $startDates[$aid];
|
||||
if (strtotime($startDate) < $range) {
|
||||
$startDate = date('Y-m-d');
|
||||
}
|
||||
$startDate = date('Y-m-d', strtotime("-3 days", strtotime($startDate)));
|
||||
$sighting = $data;
|
||||
for ($date = $startDate; strtotime($date) <= $today; $date = date('Y-m-d', strtotime("+1 day", strtotime($date)))) {
|
||||
if (!isset($csv[$aid])) {
|
||||
$csv[$aid] = 'Date,Close\n';
|
||||
}
|
||||
if (isset($sighting[$date])) {
|
||||
$csv[$aid] .= $date . ',' . $sighting[$date] . '\n';
|
||||
} else {
|
||||
$csv[$aid] .= $date . ',0\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'data' => $sightingsData,
|
||||
'csv' => $csv
|
||||
);
|
||||
if (empty($event['Sighting'])) {
|
||||
return ['data' => [], 'csv' => []];
|
||||
}
|
||||
return array('data' => array(), 'csv' => array());
|
||||
|
||||
$this->Sighting = ClassRegistry::init('Sighting');
|
||||
|
||||
$sightingsData = array();
|
||||
$sparklineData = array();
|
||||
$startDates = array();
|
||||
$range = $this->Sighting->getMaximumRange();
|
||||
foreach ($event['Sighting'] as $sighting) {
|
||||
$type = $this->Sighting->type[$sighting['type']];
|
||||
if (!isset($sightingsData[$sighting['attribute_id']][$type])) {
|
||||
$sightingsData[$sighting['attribute_id']][$type] = array('count' => 0);
|
||||
}
|
||||
$sightingsData[$sighting['attribute_id']][$type]['count']++;
|
||||
$orgName = isset($sighting['Organisation']['name']) ? $sighting['Organisation']['name'] : 'Others';
|
||||
if (!isset($sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName])) {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName] = array('count' => 1, 'date' => $sighting['date_sighting']);
|
||||
} else {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['count']++;
|
||||
if ($sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['date'] < $sighting['date_sighting']) {
|
||||
$sightingsData[$sighting['attribute_id']][$type]['orgs'][$orgName]['date'] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
if ($sighting['type'] !== '0') {
|
||||
continue;
|
||||
}
|
||||
if (!isset($startDates[$sighting['attribute_id']]) || $startDates[$sighting['attribute_id']] > $sighting['date_sighting']) {
|
||||
if ($sighting['date_sighting'] >= $range) {
|
||||
$startDates[$sighting['attribute_id']] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
if (!isset($startDates['event']) || $startDates['event'] > $sighting['date_sighting']) {
|
||||
if ($sighting['date_sighting'] >= $range) {
|
||||
$startDates['event'] = $sighting['date_sighting'];
|
||||
}
|
||||
}
|
||||
$date = date("Y-m-d", $sighting['date_sighting']);
|
||||
if (!isset($sparklineData[$sighting['attribute_id']][$date])) {
|
||||
$sparklineData[$sighting['attribute_id']][$date] = 1;
|
||||
} else {
|
||||
$sparklineData[$sighting['attribute_id']][$date]++;
|
||||
}
|
||||
if (!isset($sparklineData['event'][$date])) {
|
||||
$sparklineData['event'][$date] = 1;
|
||||
} else {
|
||||
$sparklineData['event'][$date]++;
|
||||
}
|
||||
}
|
||||
$csv = array();
|
||||
$today = strtotime(date('Y-m-d', time()));
|
||||
foreach ($startDates as $k => $v) {
|
||||
$startDates[$k] = date('Y-m-d', $v);
|
||||
}
|
||||
foreach ($sparklineData as $aid => $data) {
|
||||
if (!isset($startDates[$aid])) {
|
||||
continue;
|
||||
}
|
||||
$startDate = $startDates[$aid];
|
||||
if (strtotime($startDate) < $range) {
|
||||
$startDate = date('Y-m-d');
|
||||
}
|
||||
$startDate = date('Y-m-d', strtotime("-3 days", strtotime($startDate)));
|
||||
$sighting = $data;
|
||||
$csv[$aid] = 'Date,Close\n';
|
||||
for ($date = $startDate; strtotime($date) <= $today; $date = date('Y-m-d', strtotime("+1 day", strtotime($date)))) {
|
||||
if (isset($sighting[$date])) {
|
||||
$csv[$aid] .= $date . ',' . $sighting[$date] . '\n';
|
||||
} else {
|
||||
$csv[$aid] .= $date . ',0\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'data' => $sightingsData,
|
||||
'csv' => $csv
|
||||
);
|
||||
}
|
||||
|
||||
public function cacheSgids($user, $useCache = false)
|
||||
|
|
Loading…
Reference in New Issue