mirror of https://github.com/MISP/MISP
fix: [CS] Updated recent changes
parent
a60b24a14a
commit
b407aba746
|
@ -535,7 +535,8 @@ class AppController extends Controller
|
|||
return $this->Auth->user('org_id');
|
||||
}
|
||||
|
||||
protected function _getApiAuthUser($key, &$exception) {
|
||||
protected function _getApiAuthUser($key, &$exception)
|
||||
{
|
||||
if (strlen($key) == 40) {
|
||||
// check if the key is valid -> search for users based on key
|
||||
$user = $this->checkAuthUser($key);
|
||||
|
|
|
@ -2722,7 +2722,7 @@ class EventsController extends AppController
|
|||
);
|
||||
$list[] = $attribute['Attribute']['id'];
|
||||
}
|
||||
} else if (!empty($filters['eventid']) && $filters['eventid'] !== 'all') {
|
||||
} elseif (!empty($filters['eventid']) && $filters['eventid'] !== 'all') {
|
||||
$events = $filters['eventid'];
|
||||
}
|
||||
$final = array();
|
||||
|
@ -3006,7 +3006,8 @@ class EventsController extends AppController
|
|||
// the last 4 fields accept the following operators:
|
||||
// && - you can use && between two search values to put a logical OR between them. for value, 1.1.1.1&&2.2.2.2 would find attributes with the value being either of the two.
|
||||
// ! - you can negate a search term. For example: google.com&&!mail would search for all attributes with value google.com but not ones that include mail. www.google.com would get returned, mail.google.com wouldn't.
|
||||
public function restSearch($returnFormat = 'json', $value = false, $type = false, $category = false, $org = false, $tags = false, $searchall = false, $from = false, $to = false, $last = false, $eventid = false, $withAttachments = false, $metadata = false, $uuid = false, $publish_timestamp = false, $timestamp = false, $published = false, $enforceWarninglist = false, $sgReferenceOnly = false) {
|
||||
public function restSearch($returnFormat = 'json', $value = false, $type = false, $category = false, $org = false, $tags = false, $searchall = false, $from = false, $to = false, $last = false, $eventid = false, $withAttachments = false, $metadata = false, $uuid = false, $publish_timestamp = false, $timestamp = false, $published = false, $enforceWarninglist = false, $sgReferenceOnly = false)
|
||||
{
|
||||
$paramArray = array('value', 'type', 'category', 'org', 'tag', 'tags', 'searchall', 'from', 'to', 'last', 'eventid', 'withAttachments', 'metadata', 'uuid', 'published', 'publish_timestamp', 'timestamp', 'enforceWarninglist', 'sgReferenceOnly');
|
||||
$filterData = array(
|
||||
'request' => $this->request,
|
||||
|
|
|
@ -1580,7 +1580,8 @@ class ServersController extends AppController
|
|||
return $this->RestResponse->viewData(array('uuid' => Configure::read('MISP.uuid')), $this->response->type());
|
||||
}
|
||||
|
||||
public function rest() {
|
||||
public function rest()
|
||||
{
|
||||
if ($this->request->is('post')) {
|
||||
$request = $this->request->data;
|
||||
if (!empty($request['Server'])) {
|
||||
|
@ -1600,7 +1601,8 @@ class ServersController extends AppController
|
|||
$this->set('header', $header);
|
||||
}
|
||||
|
||||
private function __doRestQuery($request) {
|
||||
private function __doRestQuery($request)
|
||||
{
|
||||
App::uses('SyncTool', 'Tools');
|
||||
$params = array(
|
||||
|
||||
|
@ -1636,7 +1638,7 @@ class ServersController extends AppController
|
|||
$request['method'] === 'GET'
|
||||
) {
|
||||
$response = $HttpSocket->get($url, false, array('header' => $request['header']));
|
||||
} else if (
|
||||
} elseif (
|
||||
!empty($request['method']) &&
|
||||
$request['method'] === 'POST' &&
|
||||
!empty($request['body'])
|
||||
|
|
|
@ -1194,7 +1194,8 @@ class AppModel extends Model
|
|||
return $version_array;
|
||||
}
|
||||
|
||||
public function validateAuthkey($value) {
|
||||
public function validateAuthkey($value)
|
||||
{
|
||||
if (empty($value['authkey'])) {
|
||||
return 'Empty authkey found. Make sure you set the 40 character long authkey.';
|
||||
}
|
||||
|
@ -1458,7 +1459,8 @@ class AppModel extends Model
|
|||
$this->elasticSearchClient = $client;
|
||||
}
|
||||
|
||||
public function getS3Client() {
|
||||
public function getS3Client()
|
||||
{
|
||||
if (!$this->s3Client) {
|
||||
$this->s3Client = $this->loadS3Client();
|
||||
}
|
||||
|
@ -1466,14 +1468,16 @@ class AppModel extends Model
|
|||
return $this->s3Client;
|
||||
}
|
||||
|
||||
public function loadS3Client() {
|
||||
public function loadS3Client()
|
||||
{
|
||||
App::uses('AWSS3Client', 'Tools');
|
||||
$client = new AWSS3Client();
|
||||
$client->initTool();
|
||||
return $client;
|
||||
}
|
||||
|
||||
public function attachmentDirIsS3() {
|
||||
public function attachmentDirIsS3()
|
||||
{
|
||||
// Naive way to detect if we're working in S3
|
||||
return substr(Configure::read('MISP.attachments_dir'), 0, 2) === "s3";
|
||||
}
|
||||
|
@ -1681,7 +1685,6 @@ class AppModel extends Model
|
|||
} else {
|
||||
$temp[] = array($key . ' LIKE' => $f);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
foreach ($keys as $key) {
|
||||
|
@ -1690,7 +1693,6 @@ class AppModel extends Model
|
|||
} else {
|
||||
$temp['OR'][$key][] = $f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -667,8 +667,7 @@ class Attribute extends AppModel
|
|||
// We're working in S3
|
||||
$s3 = $this->getS3Client();
|
||||
$s3->delete($this->data['Attribute']['event_id'] . DS . $this->data['Attribute']['id']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Standard delete
|
||||
$filepath = $attachments_dir . DS . $this->data['Attribute']['event_id'] . DS . $this->data['Attribute']['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -2066,7 +2065,8 @@ class Attribute extends AppModel
|
|||
return $rules;
|
||||
}
|
||||
|
||||
public function set_filter_tags(&$params, $conditions, $options) {
|
||||
public function set_filter_tags(&$params, $conditions, $options)
|
||||
{
|
||||
if (empty($params['tags'])) {
|
||||
return $conditions;
|
||||
}
|
||||
|
@ -2873,11 +2873,11 @@ class Attribute extends AppModel
|
|||
}
|
||||
$results = $this->find('all', $params);
|
||||
if (!$loop) {
|
||||
if (!empty($params['limit']) && count($results) < $params['limit']) {
|
||||
$continue = false;
|
||||
}
|
||||
$break = true;
|
||||
}
|
||||
if (!empty($params['limit']) && count($results) < $params['limit']) {
|
||||
$continue = false;
|
||||
}
|
||||
$break = true;
|
||||
}
|
||||
// return false if we're paginating
|
||||
if (isset($options['limit']) && empty($results)) {
|
||||
return array();
|
||||
|
|
|
@ -913,7 +913,8 @@ class Event extends AppModel
|
|||
return 'Success';
|
||||
}
|
||||
|
||||
private function __prepareForPushToServer($event, $server) {
|
||||
private function __prepareForPushToServer($event, $server)
|
||||
{
|
||||
if ($event['Event']['distribution'] == 4) {
|
||||
if (!empty($event['SharingGroup']['SharingGroupServer'])) {
|
||||
$found = false;
|
||||
|
@ -965,6 +966,7 @@ class Event extends AppModel
|
|||
}
|
||||
return $jsonArray['name'];
|
||||
}
|
||||
// no break
|
||||
case '302': // Found
|
||||
$newLocation = $response->headers['Location'];
|
||||
$newTextBody = $response->body();
|
||||
|
@ -984,7 +986,9 @@ class Event extends AppModel
|
|||
public function restfulEventToServer($event, $server, $urlPath, &$newLocation, &$newTextBody, $HttpSocket = null)
|
||||
{
|
||||
$event = $this->__prepareForPushToServer($event, $server);
|
||||
if (is_numeric($event)) return $event;
|
||||
if (is_numeric($event)) {
|
||||
return $event;
|
||||
}
|
||||
$url = $server['Server']['url'];
|
||||
$HttpSocket = $this->setupHttpSocket($server, $HttpSocket);
|
||||
$request = $this->setupSyncRequest($server);
|
||||
|
@ -1028,7 +1032,8 @@ class Event extends AppModel
|
|||
return $data;
|
||||
}
|
||||
|
||||
private function __prepareAttributesForSync($data, $server) {
|
||||
private function __prepareAttributesForSync($data, $server)
|
||||
{
|
||||
// prepare attribute for sync
|
||||
if (!empty($data['Attribute'])) {
|
||||
foreach ($data['Attribute'] as $key => $attribute) {
|
||||
|
@ -1044,7 +1049,8 @@ class Event extends AppModel
|
|||
return $data;
|
||||
}
|
||||
|
||||
private function __prepareObjectsForSync($data, $server) {
|
||||
private function __prepareObjectsForSync($data, $server)
|
||||
{
|
||||
// prepare Object for sync
|
||||
if (!empty($data['Object'])) {
|
||||
foreach ($data['Object'] as $key => $object) {
|
||||
|
@ -1998,7 +2004,8 @@ class Event extends AppModel
|
|||
return $conditions;
|
||||
}
|
||||
|
||||
public function set_filter_published(&$params, $conditions, $options) {
|
||||
public function set_filter_published(&$params, $conditions, $options)
|
||||
{
|
||||
if (isset($params['published'])) {
|
||||
$conditions['AND']['Event.published'] = $params['published'];
|
||||
}
|
||||
|
@ -2044,7 +2051,7 @@ class Event extends AppModel
|
|||
{
|
||||
if ($options['filter'] == 'from') {
|
||||
$conditions['AND']['Event.date >='] = $params['from'];
|
||||
} else if ($options['filter'] == 'to') {
|
||||
} elseif ($options['filter'] == 'to') {
|
||||
$conditions['AND']['Event.date <='] = $params['to'];
|
||||
} else {
|
||||
$filters = array(
|
||||
|
@ -2120,7 +2127,8 @@ class Event extends AppModel
|
|||
return $attributes;
|
||||
}
|
||||
|
||||
private function __appendIncludesCSV($params, $includeContext) {
|
||||
private function __appendIncludesCSV($params, $includeContext)
|
||||
{
|
||||
if ($includeContext) {
|
||||
$params['contain'] = array(
|
||||
'Event' => array(
|
||||
|
@ -2517,7 +2525,8 @@ class Event extends AppModel
|
|||
return $result;
|
||||
}
|
||||
|
||||
private function __buildContactEventEmailBody($user, $message, $event, $targetUser, $id) {
|
||||
private function __buildContactEventEmailBody($user, $message, $event, $targetUser, $id)
|
||||
{
|
||||
// The mail body, h() is NOT needed as we are sending plain-text mails.
|
||||
$body = "";
|
||||
$body .= "Hello, \n";
|
||||
|
@ -3342,7 +3351,8 @@ class Event extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
private function __getPrioWorkerIfPossible() {
|
||||
private function __getPrioWorkerIfPossible()
|
||||
{
|
||||
$this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
|
||||
$workers = $this->ResqueStatus->getWorkers();
|
||||
$workerType = 'default';
|
||||
|
|
|
@ -4050,7 +4050,7 @@ class Server extends AppModel
|
|||
return APP . 'files';
|
||||
}
|
||||
|
||||
public function getDefaultTmp_dir()
|
||||
public function getDefaultTmp_dir()
|
||||
{
|
||||
return sys_get_temp_dir();
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ class Tag extends AppModel
|
|||
$ids = array();
|
||||
foreach ($array as $a) {
|
||||
if (is_numeric($a)) {
|
||||
$conditions['OR'][] = array('id' => $a);
|
||||
$conditions['OR'][] = array('id' => $a);
|
||||
} else {
|
||||
$conditions['OR'][] = array('LOWER(name) like' => strtolower($a));
|
||||
}
|
||||
|
|
|
@ -529,7 +529,8 @@ class User extends AppModel
|
|||
return $results;
|
||||
}
|
||||
|
||||
private function testSmimeCertificate($certif_public) {
|
||||
private function testSmimeCertificate($certif_public)
|
||||
{
|
||||
$result = array();
|
||||
try {
|
||||
App::uses('Folder', 'Utility');
|
||||
|
|
Loading…
Reference in New Issue