code standards

corrections toward code standards.
pull/63/head
noud 2012-11-14 17:16:36 +01:00
parent b84bc50c56
commit ea0ab59e4f
8 changed files with 56 additions and 58 deletions

View File

@ -64,7 +64,6 @@ class AppController extends Controller {
} }
public function beforeFilter() { public function beforeFilter() {
// user must accept terms // user must accept terms
if (!$this->Auth->user('termsaccepted') && ($this->request->here != '/users/terms') && ($this->request->here != '/users/logout') && ($this->request->here != '/users/login')) { if (!$this->Auth->user('termsaccepted') && ($this->request->here != '/users/terms') && ($this->request->here != '/users/logout') && ($this->request->here != '/users/login')) {
$this->redirect(array('controller' => 'users', 'action' => 'terms')); $this->redirect(array('controller' => 'users', 'action' => 'terms'));
@ -431,7 +430,9 @@ class AppController extends Controller {
} }
} }
// CakePHP returns false if filesize is 0 at lib/cake/Utility/File.php:384 /**
* CakePHP returns false if filesize is 0 at lib/cake/Utility/File.php:384
*/
public function checkEmpty($fileP = '/var/www/cydefsig/app/files/test') { public function checkEmpty($fileP = '/var/www/cydefsig/app/files/test') {
// Check if there were problems with the file upload // Check if there were problems with the file upload
// only keep the last part of the filename, this should prevent directory attacks // only keep the last part of the filename, this should prevent directory attacks

View File

@ -80,16 +80,16 @@ class EventsController extends AppController {
} }
} }
// // do not show cluster outside server //// do not show cluster outside server
// if ('true' == Configure::read('CyDefSIG.private')) { //if ('true' == Configure::read('CyDefSIG.private')) {
// if ($this->_isRest()) { // if ($this->_isRest()) {
// $this->paginate = Set::merge($this->paginate,array( // $this->paginate = Set::merge($this->paginate,array(
// 'conditions' => // 'conditions' =>
// array(array('Event.cluster !=' => true)), // array(array('Event.cluster !=' => true)),
// //array("AND" => array(array('Event.private !=' => 2))), // //array("AND" => array(array('Event.private !=' => 2))),
// )); // ));
// } // }
// } //}
} }
public function isAuthorized($user) { public function isAuthorized($user) {

View File

@ -191,7 +191,7 @@ class ServersController extends AppController {
} }
if (is_array($event['Event']['Attribute']) && !isset($event['Event']['Attribute']['id'])) { if (is_array($event['Event']['Attribute']) && !isset($event['Event']['Attribute']['id'])) {
$toRemove = array(); $toRemove = array();
$size = sizeof($event['Event']['Attribute']); $size = count($event['Event']['Attribute']);
for ($i = 0; $i < $size; $i++) { for ($i = 0; $i < $size; $i++) {
switch($event['Event']['Attribute'][$i]['distribution']) { switch($event['Event']['Attribute'][$i]['distribution']) {
case 'Org': case 'Org':

View File

@ -775,7 +775,7 @@ class Attribute extends AppModel {
$this->create(); $this->create();
$this->data['Attribute']['event_id'] = $eventId; $this->data['Attribute']['event_id'] = $eventId;
if ($malware) { if ($malware) {
$md5 = !$tmpfile->size() ? md5_file($fileP) : $tmpfile->md5() ; $md5 = !$tmpfile->size() ? md5_file($fileP) : $tmpfile->md5();
$this->data['Attribute']['category'] = $category ? $category : "Payload delivery"; $this->data['Attribute']['category'] = $category ? $category : "Payload delivery";
$this->data['Attribute']['type'] = "malware-sample"; $this->data['Attribute']['type'] = "malware-sample";
$this->data['Attribute']['value'] = $fullFileName ? $fullFileName . '|' . $md5 : $filename . '|' . $md5; // TODO gives problems with bigger files $this->data['Attribute']['value'] = $fullFileName ? $fullFileName . '|' . $md5 : $filename . '|' . $md5; // TODO gives problems with bigger files

View File

@ -548,7 +548,7 @@ class Event extends AppModel {
$response = $HttpSocket->get($uri, $data = '', $request); $response = $HttpSocket->get($uri, $data = '', $request);
if ($response->isOk()) { if ($response->isOk()) {
//debug($response->body); //debug($response->body);
$xml = Xml::build($response->body); $xml = Xml::build($response->body);
$eventArray = Xml::toArray($xml); $eventArray = Xml::toArray($xml);
$eventIds = array(); $eventIds = array();

View File

@ -18,9 +18,6 @@ if ('true' == Configure::read('CyDefSIG.sync')) {
echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => 'All', echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => 'All',
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv')) 'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv'))
)); ));
// echo $this->Form->input('sharing', array('label' => 'Distribution',
// 'before' => $this->Html->div('forminfo', isset($attrDescriptions['sharing']['formdesc']) ? $attrDescriptions['sharing']['formdesc'] : $attrDescriptions['sharing']['desc']),
// ));
} else { } else {
echo $this->Form->input('private', array( echo $this->Form->input('private', array(
'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']), 'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']),