mirror of https://github.com/MISP/MISP
Merge branch '2.4' of github.com:MISP/MISP into revisedUpdateProcess
commit
a95aa1f5a2
|
@ -981,14 +981,14 @@ class TagsController extends AppController
|
|||
$date = new DateTime();
|
||||
$tempObject[$objectType]['timestamp'] = $date->getTimestamp();
|
||||
$this->$objectType->save($tempObject);
|
||||
if ($objectType === 'Attribute') {
|
||||
$this->$objectType->Event->unpublishEvent($object['Event']['id']);
|
||||
} else if ($objectType === 'Event') {
|
||||
$this->Event->unpublishEvent($object['Event']['id']);
|
||||
}
|
||||
if($local) {
|
||||
$message = 'Local tag ' . $existingTag['Tag']['name'] . '(' . $existingTag['Tag']['id'] . ') successfully attached to ' . $objectType . '(' . $object[$objectType]['id'] . ').';
|
||||
} else {
|
||||
if ($objectType === 'Attribute') {
|
||||
$this->$objectType->Event->unpublishEvent($object['Event']['id']);
|
||||
} else if ($objectType === 'Event') {
|
||||
$this->Event->unpublishEvent($object['Event']['id']);
|
||||
}
|
||||
$message = 'Global tag ' . $existingTag['Tag']['name'] . '(' . $existingTag['Tag']['id'] . ') successfully attached to ' . $objectType . '(' . $object[$objectType]['id'] . ').';
|
||||
}
|
||||
return $this->RestResponse->saveSuccessResponse('Tags', 'attachTagToObject', false, $this->response->type(), $message);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c4a51509c554a0762e8b4d9b3985fe042b445fe7
|
||||
Subproject commit d2e1681eb8ec75e6c2819fa113834843fed6995a
|
|
@ -2535,4 +2535,21 @@ class AppModel extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param Exception $exception
|
||||
* @param int $type
|
||||
* @return bool
|
||||
*/
|
||||
protected function logException($message, Exception $exception, $type = LOG_ERR)
|
||||
{
|
||||
$message = sprintf("%s\n[%s] %s",
|
||||
$message,
|
||||
get_class($exception),
|
||||
$exception->getMessage()
|
||||
);
|
||||
$message .= "\nStack Trace:\n" . $exception->getTraceAsString();
|
||||
return $this->log($message, $type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ class Feed extends AppModel
|
|||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not add event '$uuid' from feed {$feed['Feed']['id']}.", $e));
|
||||
$this->logException("Could not add event '$uuid' from feed {$feed['Feed']['id']}.", $e);
|
||||
$results['add']['fail'] = array('uuid' => $uuid, 'reason' => $e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ class Feed extends AppModel
|
|||
$results['edit']['success'] = $uuid;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not edit event '$uuid' from feed {$feed['Feed']['id']}.", $e));
|
||||
$this->logException("Could not edit event '$uuid' from feed {$feed['Feed']['id']}.", $e);
|
||||
$results['edit']['fail'] = array('uuid' => $uuid, 'reason' => $e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -780,7 +780,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$actions = $this->getNewEventUuids($this->data, $HttpSocket);
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not get new event uuids for feed $feedId.", $e));
|
||||
$this->logException("Could not get new event uuids for feed $feedId.", $e);
|
||||
$this->jobProgress($jobId, 'Could not fetch event manifest. See log for more details.');
|
||||
return false;
|
||||
}
|
||||
|
@ -798,7 +798,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$temp = $this->getFreetextFeed($this->data, $HttpSocket, $this->data['Feed']['source_format'], 'all');
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not get freetext feed $feedId", $e));
|
||||
$this->logException("Could not get freetext feed $feedId", $e);
|
||||
$this->jobProgress($jobId, 'Could not fetch freetext feed. See log for more details.');
|
||||
return false;
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$result = $this->saveFreetextFeedData($this->data, $data, $user);
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not save freetext feed data for feed $feedId.", $e));
|
||||
$this->logException("Could not save freetext feed data for feed $feedId.", $e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1037,14 +1037,15 @@ class Feed extends AppModel
|
|||
try {
|
||||
$values = $this->getFreetextFeed($feed, $HttpSocket, $feed['Feed']['source_format'], 'all');
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not get freetext feed $feedId", $e));
|
||||
$this->logException("Could not get freetext feed $feedId", $e);
|
||||
$this->jobProgress($jobId, 'Could not fetch freetext feed. See log for more details.');
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($values as $k => $value) {
|
||||
$redis->sAdd('misp:feed_cache:' . $feedId, md5($value['value']));
|
||||
$redis->sAdd('misp:feed_cache:combined', md5($value['value']));
|
||||
$md5Value = md5($value['value']);
|
||||
$redis->sAdd('misp:feed_cache:' . $feedId, $md5Value);
|
||||
$redis->sAdd('misp:feed_cache:combined', $md5Value);
|
||||
if ($k % 1000 == 0) {
|
||||
$this->jobProgress($jobId, "Feed $feedId: $k/" . count($values) . " values cached.");
|
||||
}
|
||||
|
@ -1060,7 +1061,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$manifest = $this->getManifest($feed, $HttpSocket);
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not get manifest for feed $feedId.", $e));
|
||||
$this->logException("Could not get manifest for feed $feedId.", $e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1071,7 +1072,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$event = $this->downloadAndParseEventFromFeed($feed, $uuid, $HttpSocket);
|
||||
} catch (Exception $e) {
|
||||
CakeLog::error($this->exceptionAsMessage("Could not get and parse event '$uuid' for feed $feedId.", $e));
|
||||
$this->logException("Could not get and parse event '$uuid' for feed $feedId.", $e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1112,7 +1113,7 @@ class Feed extends AppModel
|
|||
try {
|
||||
$cache = $this->getCache($feed, $HttpSocket);
|
||||
} catch (Exception $e) {
|
||||
CakeLog::notice($this->exceptionAsMessage("Could not get cache file for $feedId.", $e));
|
||||
$this->logException("Could not get cache file for $feedId.", $e, LOG_NOTICE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1625,22 +1626,6 @@ class Feed extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param Exception $exception
|
||||
* @return string
|
||||
*/
|
||||
private function exceptionAsMessage($message, $exception)
|
||||
{
|
||||
$message = sprintf("%s\n[%s] %s",
|
||||
$message,
|
||||
get_class($exception),
|
||||
$exception->getMessage()
|
||||
);
|
||||
$message .= "\nStack Trace:\n" . $exception->getTraceAsString();
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove all events tied to a feed. Returns int on success, error message
|
||||
* as string on failure
|
||||
|
|
|
@ -1202,10 +1202,15 @@ function submitPopoverForm(context_id, referer, update_context_id) {
|
|||
$('#sightingsListAllToggle').addClass('btn-primary');
|
||||
}
|
||||
if (context == 'event' && (referer == 'add' || referer == 'massEdit' || referer == 'replaceAttributes' || referer == 'addObjectReference')) eventUnpublish();
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
showMessage('fail', textStatus + ": " + errorThrown);
|
||||
},
|
||||
complete: function () {
|
||||
$(".loading").hide();
|
||||
},
|
||||
type:"post",
|
||||
url:url
|
||||
type: "post",
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue