mirror of https://github.com/MISP/MISP
fix: [internal] Fix error code when fetching sightings
parent
59916f848a
commit
d2911274b5
|
@ -18,10 +18,15 @@ class HttpSocketHttpException extends Exception
|
|||
{
|
||||
$this->response = $response;
|
||||
$this->url = $url;
|
||||
|
||||
$message = "Remote server returns HTTP error code $response->code";
|
||||
if ($url) {
|
||||
$message .= " for URL $url";
|
||||
}
|
||||
if ($response->body) {
|
||||
$message .= ': ' . substr($response->body, 0, 100);
|
||||
}
|
||||
|
||||
parent::__construct($message, (int)$response->code);
|
||||
}
|
||||
|
||||
|
|
|
@ -1017,16 +1017,16 @@ class Sighting extends AppModel
|
|||
* @return TmpFileTool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function restSearch(array $user, $returnFormat, $filters)
|
||||
public function restSearch(array $user, $returnFormat, array $filters)
|
||||
{
|
||||
$allowedContext = array('event', 'attribute');
|
||||
// validate context
|
||||
if (isset($filters['context']) && !in_array($filters['context'], $allowedContext, true)) {
|
||||
throw new MethodNotAllowedException(__('Invalid context %s.', $filters['context']));
|
||||
throw new BadRequestException(__('Invalid context %s.', $filters['context']));
|
||||
}
|
||||
// ensure that an id or uuid is provided if context is set
|
||||
if (!empty($filters['context']) && !(isset($filters['id']) || isset($filters['uuid'])) ) {
|
||||
throw new MethodNotAllowedException(__('An ID or UUID must be provided if the context is set.'));
|
||||
throw new BadRequestException(__('An ID or UUID must be provided if the context is set.'));
|
||||
}
|
||||
|
||||
if (!isset($this->validFormats[$returnFormat][1])) {
|
||||
|
@ -1396,7 +1396,7 @@ class Sighting extends AppModel
|
|||
try {
|
||||
$sightings = $serverSync->fetchSightingsForEvents($chunk);
|
||||
} catch (Exception $e) {
|
||||
$this->logException("Failed downloading the sightings from {$serverSync->server()['Server']['name']}.", $e);
|
||||
$this->logException("Failed to download sightings from {$serverSync->server()['Server']['name']}.", $e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue