Merge branch 'develop' of https://github.com/MISP/MISP into develop

pull/217/head
iglocska 2013-07-17 12:05:13 +02:00
commit 1e2dd15842
4 changed files with 14 additions and 19 deletions

View File

@ -202,25 +202,25 @@ class ServersController extends AppController {
if (null != $event) {
// we have an Event array
if (!isset($event['Event']['distribution'])) { // version 1
$event['Event']['distribution'] = 1;
$event['Event']['distribution'] = '1';
}
// Distribution
switch($event['Event']['distribution']) {
case 1:
case 'This community only': // backwards compatibility
// if community only, downgrade to org only after pull
$event['Event']['distribution'] = 0;
$event['Event']['distribution'] = '0';
break;
case 2:
case 'Connected communities': // backwards compatibility
// if connected communities downgrade to community only
$event['Event']['distribution'] = 1;
$event['Event']['distribution'] = '1';
break;
case 'All communities': // backwards compatibility
$event['Event']['distribution'] = 3;
$event['Event']['distribution'] = '3';
break;
case 'Your organisation only': // backwards compatibility
$event['Event']['distribution'] = 0;
$event['Event']['distribution'] = '0';
break;
}
@ -232,7 +232,6 @@ class ServersController extends AppController {
}
if (is_array($event['Event']['Attribute'])) {
$toRemove = array();
$size = is_array($event['Event']['Attribute']) ? count($event['Event']['Attribute']) : 0;
for ($i = 0; $i < $size; $i++) {
if (!isset($event['Event']['Attribute'][$i]['distribution'])) { // version 1
@ -242,24 +241,21 @@ class ServersController extends AppController {
case 1:
case 'This community only': // backwards compatibility
// if community only, downgrade to org only after pull
$event['Event']['Attribute'][$i]['distribution'] = 0;
$event['Event']['Attribute'][$i]['distribution'] = '0';
break;
case 2:
case 'Connected communities': // backwards compatibility
// if connected communities downgrade to community only
$event['Event']['Attribute'][$i]['distribution'] = 1;
$event['Event']['Attribute'][$i]['distribution'] = '1';
break;
case 'All communities': // backwards compatibility
$event['Event']['Attribute'][$i]['distribution'] = 3;
$event['Event']['Attribute'][$i]['distribution'] = '3';
break;
case 'Your organisation only': // backwards compatibility
$event['Event']['Attribute'][$i]['distribution'] = 0;
$event['Event']['Attribute'][$i]['distribution'] = '0';
break;
}
}
foreach ($toRemove as $thisRemove) {
unset($event['Event']['Attribute'][$thisRemove]);
}
$event['Event']['Attribute'] = array_values($event['Event']['Attribute']);
} else {
unset($event['Event']['Attribute']);

View File

@ -284,14 +284,13 @@ class Attribute extends AppModel {
),
),
'distribution' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Options : Your organisation only, This community only, Connected communities, All communities',
'rule' => array('inList', array('0', '1', '2', '3')),
'message' => 'Options : Your organisation only, This community only, Connected communities, All communities',
//'allowEmpty' => false,
'required' => true,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
)),
),
);
public function __construct($id = false, $table = null, $ds = null) {
@ -605,7 +604,8 @@ class Attribute extends AppModel {
}
break;
case 'url':
if (preg_match('#^(http|ftp)(s)?\:\/\/((([a-z|0-9|\-]{1,25})(\.)?){2,7})($|/.*$)#i', $value) && !preg_match("#\n#", $value)) {
// no newline
if (!preg_match("#\n#", $value)) {
$returnValue = true;
}
break;

View File

@ -631,7 +631,6 @@ class Event extends AppModel {
)
);
$uri = $url . '/events/' . $eventId;
// LATER validate HTTPS SSL certificate
$response = $HttpSocket->get($uri, $data = '', $request);
if ($response->isOk()) {
$xmlArray = Xml::toArray(Xml::build($response->body));

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB