mirror of https://github.com/MISP/MISP
Fixed deprecated errors
Removed cause of deprecated errors (Pass by reference)pull/63/head
parent
a17eaa69ad
commit
879154eab2
|
@ -14,7 +14,7 @@ class AttributesController extends AppController {
|
|||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events
|
||||
);
|
||||
|
||||
public $helpers = array('Js' => array('Jquery'));
|
||||
|
@ -156,7 +156,7 @@ class AttributesController extends AppController {
|
|||
// make array from value field
|
||||
$attributes = explode("\n", $this->request->data['Attribute']['value']);
|
||||
|
||||
$fails = ""; // will be used to keep a list of the lines that failed or succeeded
|
||||
$fails = ""; // will be used to keep a list of the lines that failed or succeeded
|
||||
$successes = "";
|
||||
foreach ($attributes as $key => $attribute) {
|
||||
$attribute = trim($attribute);
|
||||
|
@ -164,9 +164,9 @@ class AttributesController extends AppController {
|
|||
continue; // don't do anything for empty lines
|
||||
|
||||
$this->Attribute->create();
|
||||
$this->request->data['Attribute']['value'] = $attribute; // set the value as the content of the single line
|
||||
$this->request->data['Attribute']['value'] = $attribute; // set the value as the content of the single line
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$this->request->data = $this->Attribute->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Attribute->massageData($this->request->data);
|
||||
}
|
||||
if ($this->Attribute->save($this->request->data)) {
|
||||
$successes .= " " . ($key + 1);
|
||||
|
@ -214,7 +214,7 @@ class AttributesController extends AppController {
|
|||
$this->Attribute->create();
|
||||
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$this->request->data = $this->Attribute->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Attribute->massageData($this->request->data);
|
||||
}
|
||||
|
||||
if ("i" == Configure::read('CyDefSIG.rest')) {
|
||||
|
@ -297,10 +297,10 @@ class AttributesController extends AppController {
|
|||
$this->viewClass = 'Media';
|
||||
$params = array(
|
||||
'id' => $file->path,
|
||||
'name' => $filename,
|
||||
'name' => $filename,
|
||||
'extension' => $fileExt,
|
||||
'download' => true,
|
||||
'path' => DS
|
||||
'download' => true,
|
||||
'path' => DS
|
||||
);
|
||||
$this->set($params);
|
||||
}
|
||||
|
@ -348,11 +348,11 @@ class AttributesController extends AppController {
|
|||
$this->request->data['Attribute']['uuid'] = String::uuid();
|
||||
$this->request->data['Attribute']['batch_import'] = 0;
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$this->request->data = $this->Attribute->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Attribute->massageData($this->request->data);
|
||||
}
|
||||
|
||||
if ($this->Attribute->save($this->request->data)) {
|
||||
// attribute saved correctly in the db
|
||||
// attribute saved correctly in the db
|
||||
} else {
|
||||
$this->Session->setFlash(__('The attribute could not be saved. Did you already upload this file?'));
|
||||
$this->redirect(array('controller' => 'events', 'action' => 'view', $this->request->data['Attribute']['event_id']));
|
||||
|
@ -364,7 +364,7 @@ class AttributesController extends AppController {
|
|||
$rootDir = APP . DS . "files" . DS . $this->request->data['Attribute']['event_id'];
|
||||
$dir = new Folder($rootDir, true);
|
||||
// move the file to the correct location
|
||||
$destpath = $rootDir . DS . $this->Attribute->id; // id of the new attribute in the database
|
||||
$destpath = $rootDir . DS . $this->Attribute->id; // id of the new attribute in the database
|
||||
$file = new File ($destpath);
|
||||
$zipfile = new File ($destpath . '.zip');
|
||||
$fileInZip = new File($rootDir . DS . $filename); // FIXME do sanitization of the filename
|
||||
|
@ -390,7 +390,7 @@ class AttributesController extends AppController {
|
|||
$execOutput = array();
|
||||
rename($file->path, $fileInZip->path); // TODO check if no workaround exists for the current filtering mechanisms
|
||||
exec("zip -j -P infected " . $zipfile->path . ' "' . addslashes($fileInZip->path) . '"', $execOutput, $execRetval);
|
||||
if ($execRetval != 0) { // not EXIT_SUCCESS
|
||||
if ($execRetval != 0) { // not EXIT_SUCCESS
|
||||
$this->Session->setFlash(__('Problem with zipping the attachment. Please report to administrator. ' . $execOutput, true), 'default', array(), 'error');
|
||||
// remove the entry from the database
|
||||
$this->Attribute->delete();
|
||||
|
@ -398,7 +398,7 @@ class AttributesController extends AppController {
|
|||
$file->delete();
|
||||
$this->redirect(array('controller' => 'events', 'action' => 'view', $this->request->data['Attribute']['event_id']));
|
||||
};
|
||||
$fileInZip->delete(); // delete the original not-zipped-file
|
||||
$fileInZip->delete(); // delete the original not-zipped-file
|
||||
rename($zipfile->path, $file->path); // rename the .zip to .nothing
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ class AttributesController extends AppController {
|
|||
|
||||
if ($this->request->is('post') || $this->request->is('put')) {
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$this->request->data = $this->Attribute->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Attribute->massageData($this->request->data);
|
||||
}
|
||||
|
||||
// reposition to get the attribute.id with given uuid
|
||||
|
@ -536,7 +536,7 @@ class AttributesController extends AppController {
|
|||
$this->set('types', $types);
|
||||
// combobox for categories
|
||||
$categories = $this->Attribute->validate['category']['rule'][1];
|
||||
array_pop(&$categories); // remove that last empty/space option
|
||||
array_pop($categories); // remove that last empty/space option
|
||||
$categories = $this->_arrayToValuesIndexArray($categories);
|
||||
$this->set('categories', $categories);
|
||||
// combobox for distribution
|
||||
|
@ -651,7 +651,7 @@ class AttributesController extends AppController {
|
|||
$this->Attribute->recursive = 0;
|
||||
$this->paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 attributes?
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 attributes?
|
||||
'conditions' => $conditions
|
||||
);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class EventsController extends AppController {
|
|||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events
|
||||
'order' => array(
|
||||
'Event.id' => 'DESC'
|
||||
)
|
||||
|
@ -239,7 +239,7 @@ class EventsController extends AppController {
|
|||
$relatedEvents[] = array('Event' => array('id' => $key, 'date' => $relatedEventsDate));
|
||||
}
|
||||
}
|
||||
usort($relatedEvents, array(&$this, 'compareRelatedEvents'));
|
||||
usort($relatedEvents, array($this, 'compareRelatedEvents'));
|
||||
}
|
||||
} else {
|
||||
$fields = array('Attribute.id', 'Attribute.event_id', 'Attribute.uuid');
|
||||
|
@ -343,7 +343,7 @@ class EventsController extends AppController {
|
|||
// Distribution, reporter for the events pushed will be the owner of the authentication key
|
||||
$this->request->data['Event']['user_id'] = $this->Auth->user('id');
|
||||
}
|
||||
$this->request->data = $this->Event->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Event->massageData($this->request->data);
|
||||
}
|
||||
|
||||
if (!empty($this->data)) {
|
||||
|
@ -468,7 +468,7 @@ class EventsController extends AppController {
|
|||
}
|
||||
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$data = $this->Event->massageData(&$data);
|
||||
$data = $this->Event->massageData($data);
|
||||
}
|
||||
|
||||
if ("i" == Configure::read('CyDefSIG.baseurl')) {
|
||||
|
@ -600,7 +600,7 @@ class EventsController extends AppController {
|
|||
$this->request->data['Event']['published'] = 0;
|
||||
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
$this->request->data = $this->Event->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Event->massageData($this->request->data);
|
||||
}
|
||||
|
||||
if ($this->Event->save($this->request->data, true, $fieldList)) {
|
||||
|
@ -880,7 +880,7 @@ class EventsController extends AppController {
|
|||
}
|
||||
}
|
||||
$body .= "\n";
|
||||
$body .= $bodyTempOther; // append the 'other' attribute types to the bottom.
|
||||
$body .= $bodyTempOther; // append the 'other' attribute types to the bottom.
|
||||
|
||||
// sign the body
|
||||
require_once 'Crypt/GPG.php';
|
||||
|
@ -911,7 +911,7 @@ class EventsController extends AppController {
|
|||
$this->Email->bcc = Sanitize::clean($alertEmails);
|
||||
$this->Email->subject = "[" . Configure::read('CyDefSIG.name') . "] Event " . $id . " - " . $event['Event']['risk'] . " - TLP Amber";
|
||||
$this->Email->template = 'body';
|
||||
$this->Email->sendAs = 'text'; // both text or html
|
||||
$this->Email->sendAs = 'text'; // both text or html
|
||||
$this->set('body', Sanitize::clean($bodySigned));
|
||||
// send it
|
||||
$this->Email->send();
|
||||
|
@ -924,7 +924,7 @@ class EventsController extends AppController {
|
|||
// Build a list of the recipients that wish to receive encrypted mails.
|
||||
//
|
||||
$alertUsers = $this->User->find('all', array(
|
||||
'conditions' => array( 'User.autoalert' => 1,
|
||||
'conditions' => array('User.autoalert' => 1,
|
||||
'User.gpgkey !=' => ""),
|
||||
'recursive' => 0,
|
||||
)
|
||||
|
@ -936,7 +936,7 @@ class EventsController extends AppController {
|
|||
$this->Email->to = Sanitize::clean($user['User']['email']);
|
||||
$this->Email->subject = "[" . Configure::read('CyDefSIG.name') . "] Event " . $id . " - " . $event['Event']['risk'] . " - TLP Amber";
|
||||
$this->Email->template = 'body';
|
||||
$this->Email->sendAs = 'text'; // both text or html
|
||||
$this->Email->sendAs = 'text'; // both text or html
|
||||
|
||||
// import the key of the user into the keyring
|
||||
// this is not really necessary, but it enables us to find
|
||||
|
@ -1074,7 +1074,7 @@ class EventsController extends AppController {
|
|||
}
|
||||
}
|
||||
$body .= "\n";
|
||||
$body .= $bodyTempOther; // append the 'other' attribute types to the bottom.
|
||||
$body .= $bodyTempOther; // append the 'other' attribute types to the bottom.
|
||||
|
||||
// sign the body
|
||||
require_once 'Crypt/GPG.php';
|
||||
|
@ -1423,7 +1423,7 @@ class EventsController extends AppController {
|
|||
$execRetval = '';
|
||||
exec("unzip " . $zipfile->path . ' -d "' . addslashes($rootDir) . '"', $execOutput, $execRetval);
|
||||
$execOutput = array();
|
||||
if ($execRetval != 0) { // not EXIT_SUCCESS
|
||||
if ($execRetval != 0) { // not EXIT_SUCCESS
|
||||
// do some?
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class RegexController extends AppController {
|
|||
$this->loadModel('Attribute');
|
||||
$attributes = $this->Attribute->find('all', array('recursive' => 0));
|
||||
foreach ($attributes as $attribute) {
|
||||
$result = $this->replaceSpecific(&$attribute['Attribute']['value']);
|
||||
$result = $this->replaceSpecific($attribute['Attribute']['value']);
|
||||
if (!$result) {
|
||||
$deletableAttributes[] = $attribute['Attribute']['id'];
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ class RegexController extends AppController {
|
|||
$this->loadModel('Event');
|
||||
$events = $this->Event->find('all', array('recursive' => 0));
|
||||
foreach ($events as $event) {
|
||||
$result = $this->replaceSpecific(&$event['Event']['info']);
|
||||
$result = $this->replaceSpecific($event['Event']['info']);
|
||||
if (!$result) {
|
||||
$deletableEvents[] = $event['Event']['id'];
|
||||
} else {
|
||||
|
|
|
@ -85,7 +85,7 @@ class RolesController extends AppController {
|
|||
public function admin_add() {
|
||||
if ($this->request->is('post')) {
|
||||
$this->Role->create();
|
||||
$this->request->data = $this->Role->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Role->massageData($this->request->data);
|
||||
if ($this->Role->save($this->request->data)) {
|
||||
$this->saveAcl($this->Role, $this->data['Role']['perm_add'], $this->data['Role']['perm_modify'], $this->data['Role']['perm_publish']); // save to ACL as well
|
||||
$this->Session->setFlash(__('The role has been saved'));
|
||||
|
@ -113,7 +113,7 @@ class RolesController extends AppController {
|
|||
}
|
||||
if ($this->request->is('post') || $this->request->is('put')) {
|
||||
$fields = array();
|
||||
$this->request->data = $this->Role->massageData(&$this->request->data);
|
||||
$this->request->data = $this->Role->massageData($this->request->data);
|
||||
if ($this->Role->save($this->request->data, true, $fields)) {
|
||||
$this->saveAcl($this->Role, $this->data['Role']['perm_add'], $this->data['Role']['perm_modify'], $this->data['Role']['perm_publish']); // save to ACL as well
|
||||
$this->Session->setFlash(__('The role has been saved'));
|
||||
|
|
|
@ -32,7 +32,7 @@ class RegexBehavior extends ModelBehavior {
|
|||
public function beforeValidate(Model $Model, $options = array()) {
|
||||
$returnValue = true;
|
||||
// process some..
|
||||
$returnValue = $this->regexStringFields(&$Model);
|
||||
$returnValue = $this->regexStringFields($Model);
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ class RegexBehavior extends ModelBehavior {
|
|||
*/
|
||||
public function regexStringFields(Model $Model) {
|
||||
$returnValue = true;
|
||||
foreach ($Model->data[$Model->name] as $key => &$field) {
|
||||
foreach ($Model->data[$Model->name] as $key => $field) {
|
||||
if (in_array($key, $this->settings[$Model->alias]['fields']) && is_string($field)) {
|
||||
$returnValue = $this->replaceWindowsSpecific($Model, &$field);
|
||||
$returnValue = $this->replaceWindowsSpecific($Model, $field);
|
||||
//if (!$returnValue) {
|
||||
// $Model->blacklistErrors[] = array($key, $field);
|
||||
//}
|
||||
|
|
|
@ -236,7 +236,7 @@ class Event extends AppModel {
|
|||
// 'fields' => '',
|
||||
// 'order' => ''
|
||||
//)
|
||||
'User' => array(
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'conditions' => '',
|
||||
|
@ -256,7 +256,7 @@ class Event extends AppModel {
|
|||
'Attribute' => array(
|
||||
'className' => 'Attribute',
|
||||
'foreignKey' => 'event_id',
|
||||
'dependent' => true, // cascade deletes
|
||||
'dependent' => true, // cascade deletes
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => array('Attribute.category ASC', 'Attribute.type ASC'),
|
||||
|
@ -270,7 +270,7 @@ class Event extends AppModel {
|
|||
|
||||
public function beforeDelete($cascade = true) {
|
||||
// delete event from the disk
|
||||
$this->read(); // first read the event from the db
|
||||
$this->read(); // first read the event from the db
|
||||
// FIXME secure this filesystem access/delete by not allowing to change directories or go outside of the directory container.
|
||||
// only delete the file if it exists
|
||||
$filepath = APP . "files" . DS . $this->data['Event']['id'];
|
||||
|
@ -358,7 +358,7 @@ class Event extends AppModel {
|
|||
$relatedEventIds = Array();
|
||||
foreach ($this->data['Attribute'] as &$attribute) {
|
||||
if ($attribute['type'] == 'other') {
|
||||
continue; // sigs of type 'other' should not be matched against the others
|
||||
continue; // sigs of type 'other' should not be matched against the others
|
||||
}
|
||||
$conditions = array('Attribute.value =' => $attribute['value'], 'Attribute.type =' => $attribute['type']);
|
||||
$similarAttributes = $this->Attribute->find('all',array('conditions' => $conditions));
|
||||
|
@ -409,10 +409,10 @@ class Event extends AppModel {
|
|||
|
||||
public function uploadEventToServer($event, $server, $HttpSocket = null) {
|
||||
$newLocation = $newTextBody = '';
|
||||
$result = $this->restfullEventToServer($event, $server, null, $HttpSocket, &$newLocation, &$newTextBody);
|
||||
$result = $this->restfullEventToServer($event, $server, null, $HttpSocket, $newLocation, $newTextBody);
|
||||
if (strlen($newLocation) || $result) { // HTTP/1.1 302 Found and Location: http://<newLocation>
|
||||
if (strlen($newLocation)) { // HTTP/1.1 302 Found and Location: http://<newLocation>
|
||||
$result = $this->restfullEventToServer($event, $server, $newLocation, $HttpSocket, &$newLocation, &$newTextBody);
|
||||
$result = $this->restfullEventToServer($event, $server, $newLocation, $HttpSocket, $newLocation, $newTextBody);
|
||||
}
|
||||
try { // TODO Xml::build() does not throw the XmlException
|
||||
$xml = Xml::build($newTextBody);
|
||||
|
@ -464,7 +464,7 @@ class Event extends AppModel {
|
|||
*
|
||||
* @return bool true if success, false or error message if failed
|
||||
*/
|
||||
public function restfullEventToServer($event, $server, $urlPath, $HttpSocket = null, $newLocation, $newTextBody) {
|
||||
public function restfullEventToServer($event, $server, $urlPath, $newLocation, $newTextBody, $HttpSocket = null) {
|
||||
if (true == $event['Event']['private']) { // never upload private events
|
||||
return "Event is private and non exportable";
|
||||
}
|
||||
|
@ -573,7 +573,6 @@ class Event extends AppModel {
|
|||
$newTextBody = $response->body();
|
||||
return true;
|
||||
//return isset($urlPath) ? $response->body() : $response->headers['Location'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue