Merge branch 'hotfix-2.3.38' into develop

pull/375/head
iglocska 2014-12-19 15:13:11 +01:00
commit 2768503168
13 changed files with 127 additions and 24 deletions

View File

@ -1 +1 @@
{"major":2, "minor":3, "hotfix":37}
{"major":2, "minor":3, "hotfix":38}

View File

@ -116,7 +116,7 @@ class AppController extends Controller {
// instead of using checkAction(), like we normally do from controllers when trying to find out about a permission flag, we can use getActions()
// getActions returns all the flags in a single SQL query
if ($this->Auth->user()) {
$this->_refreshAuth();
//$this->_refreshAuth();
$this->set('mispVersion', $this->mispVersion);
$role = $this->getActions();
$this->set('me', $this->Auth->user());

View File

@ -939,7 +939,7 @@ class AttributesController extends AppController {
// attachment will be deleted with the beforeDelete() function in the Model
if ($this->Attribute->delete()) {
// delete the attribute from remote servers
$this->__deleteAttributeFromServers($uuid);
//$this->__deleteAttributeFromServers($uuid);
// We have just deleted the attribute, let's also check if there are any shadow attributes that were attached to it and delete them
$this->loadModel('ShadowAttribute');
@ -1723,7 +1723,11 @@ class AttributesController extends AppController {
$this->__downloadAttachment($this->Attribute->data['Attribute']);
}
public function text($key='download', $type="", $tags='') {
public function text($key='download', $type='all', $tags=false, $eventId=false, $allowNonIDS=false) {
if ($eventId === 'null' || $eventId == '0' || $eventId === 'false') $eventId = false;
if ($allowNonIDS === 'null' || $allowNonIDS === '0' || $allowNonIDS === 'false') $allowNonIDS = false;
if ($type === 'null' || $type === '0' || $type === 'false') $type = 'all';
if ($tags === 'null' || $tags === '0' || $tags === 'false') $tags = false;
if ($key != 'download') {
// check if the key is valid -> search for users based on key
$user = $this->checkAuthUser($key);
@ -1738,7 +1742,7 @@ class AttributesController extends AppController {
$this->response->type('txt'); // set the content type
$this->header('Content-Disposition: download; filename="misp.' . $type . '.txt"');
$this->layout = 'text/default';
$attributes = $this->Attribute->text($this->_checkOrg(), $this->_isSiteAdmin(), $type, $tags);
$attributes = $this->Attribute->text($this->_checkOrg(), $this->_isSiteAdmin(), $type, $tags, $eventId, $allowNonIDS);
$this->loadModel('Whitelist');
$attributes = $this->Whitelist->removeWhitelistedFromArray($attributes, true);
$this->set('attributes', $attributes);

View File

@ -3041,4 +3041,87 @@ class EventsController extends AppController {
$this->set('_serialize', 'data');
}
}
}
public function exportChoice($id) {
$event = $this->Event->find('first' ,array(
'conditions' => array('id' => $id),
'recursive' => -1,
'fields' => array('distribution', 'orgc','id', 'published'),
));
if (empty($event) || (!$this->_isSiteAdmin() && $event['Event']['orgc'] != $this->Auth->user('org') && $event['Event']['distribution'] < 1)) throw new NotFoundException('Event not found or you are not authorised to view it.');
$exports = array(
'xml' => array(
'url' => '/events/xml/download/' . $id,
'text' => 'MISP XML (metadata + all attributes)',
'requiresPublished' => false,
'checkbox' => true,
'checkbox_text' => 'Encode Attachments',
'checkbox_set' => '/true'
),
'json' => array(
'url' => '/events/view/' . $id . 'json',
'text' => 'MISP JSON (metadata + all attributes)',
'requiresPublished' => false,
'checkbox' => false,
),
'openIOC' => array(
'url' => '/events/downloadOpenIOCEvent/' . $id,
'text' => 'OpenIOC (all indicators marked to IDS)',
'requiresPublished' => true,
'checkbox' => false,
),
'csv' => array(
'url' => '/events/csv/download/' . $id . '/1',
'text' => 'CSV',
'requiresPublished' => true,
'checkbox' => true,
'checkbox_text' => 'Include non-IDS marked attributes',
'checkbox_set' => '/1'
),
'stix_xml' => array(
'url' => '/events/stix/download/' . $id . '.xml',
'text' => 'STIX XML (metadata + all attributes)',
'requiresPublished' => true,
'checkbox' => true,
'checkbox_text' => 'Encode Attachments',
'checkbox_set' => '/true'
),
'stix_json' => array(
'url' => '/events/stix/download/' . $id . '.json',
'text' => 'STIX JSON (metadata + all attributes)',
'requiresPublished' => true,
'checkbox' => true,
'checkbox_text' => 'Encode Attachments',
'checkbox_set' => '/true'
),
'suricata' => array(
'url' => '/events/nids/suricata/download/' . $id,
'text' => 'Download Suricata rules',
'requiresPublished' => true,
'checkbox' => false,
),
'snort' => array(
'url' => '/events/nids/snort/download/' . $id,
'text' => 'Download Snort rules',
'requiresPublished' => true,
'checkbox' => false,
),
'text' => array(
'url' => 'http://192.168.56.11/attributes/text/download/all/false/' . $id,
'text' => 'Export all attribute values as a text file',
'requiresPublished' => true,
'checkbox' => true,
'checkbox_text' => 'Include non-IDS marked attributes',
'checkbox_set' => '/true'
),
);
if ($event['Event']['published'] == 0) {
foreach ($exports as $k => $export) {
if ($export['requiresPublished']) unset($exports[$k]);
}
}
$this->set('exports', $exports);
$this->set('id', $id);
$this->render('ajax/exportChoice');
}
}

View File

@ -1256,9 +1256,11 @@ class Attribute extends AppModel {
return $rules;
}
public function text($org, $isSiteAdmin, $type, $tags = '') {
public function text($org, $isSiteAdmin, $type, $tags = false, $eventId, $allowNonIDS) {
//restricting to non-private or same org if the user is not a site-admin.
$conditions['AND'] = array('Attribute.type' => $type, 'Attribute.to_ids =' => 1, 'Event.published =' => 1);
$conditions['AND'] = array();
if ($allowNonIDS === false) $conditions['AND'] = array('Attribute.to_ids =' => 1, 'Event.published =' => 1);
if ($type !== 'all') $conditions['AND']['Attribute.type'] = $type;
if (!$isSiteAdmin) {
$temp = array();
$distribution = array();
@ -1267,8 +1269,10 @@ class Attribute extends AppModel {
$conditions['OR'] = $temp;
}
// If we sent any tags along, load the associated tag names for each attribute
if ($tags !== '') {
if ($eventId !== false) {
$conditions['AND'][] = array('Event.id' => $eventId);
} elseif ($tags !== false) {
// If we sent any tags along, load the associated tag names for each attribute
$tag = ClassRegistry::init('Tag');
$args = $this->dissectArgs($tags);
$tagArray = $tag->fetchEventTagIds($args[0], $args[1]);

View File

@ -43,13 +43,7 @@
<li<?php echo $publishButtons; ?> class="publishButtons"><a href="#" onClick="publishPopup('<?php echo $event['Event']['id']; ?>', 'publish')">Publish (no email)</a></li>
<li <?php if ($menuItem === 'contact') echo 'class="active"';?>><a href="/events/contact/<?php echo $event['Event']['id'];?>">Contact Reporter</a></li>
<li><a href="/events/xml/download/<?php echo $event['Event']['id'];?>">Download as XML</a></li>
<li<?php echo $exportButtons; ?> class="exportButtons"><a href="/events/downloadOpenIOCEvent/<?php echo $event['Event']['id'];?>">Download as IOC</a></li>
<li<?php echo $exportButtons; ?> class="exportButtons"><a href="/events/csv/download/<?php echo $event['Event']['id'];?>/1">Download as CSV</a></li>
<li<?php echo $exportButtons; ?> class="exportButtons"><a href="/events/stix/download/<?php echo $event['Event']['id'];?>.xml">Download as STIX XML</a></li>
<li<?php echo $exportButtons; ?> class="exportButtons"><a href="/events/stix/download/<?php echo $event['Event']['id'];?>.json">Download as STIX JSON</a></li>
<li><a onClick="getPopup('<?php echo $event['Event']['id']; ?>', 'events', 'exportChoice');" style="cursor:pointer;">Download as...</a></li>
<li class="divider"></li>
<li><a href="/events/index">List Events</a></li>
<?php if ($isAclAdd): ?>

View File

@ -77,7 +77,20 @@ foreach ($sigTypes as $sigType) {
<p>To restrict the results by tags, use the usual syntax. Please be aware the colons (:) cannot be used in the tag search. Use semicolons instead (the search will automatically search for colons instead). To get ip-src values from events tagged tag1 but not tag2 use:</p>
<pre>
<?php
echo Configure::read('MISP.baseurl').'/attributes/text/download/ip-src/tag1&&!tag2';
echo Configure::read('MISP.baseurl').'/attributes/text/download/ip-src/tag1&&!tag2';
?>
</pre>
<p>As of version 2.3.38, it is possible to restrict the text exports on two additional flags. The first allows the user to restrict based on event ID, whilst the second is a boolean switch allowing non IDS flagged attributes to be exported. Additionally, choosing "all" in the type field will return all eligible attributes. </p>
<pre>
<?php
echo Configure::read('MISP.baseurl').'/attributes/text/download/[type]/[tags]/[event_id]/[ignore_to_ids_restriction]';
?>
</pre>
<p>For example, to retrieve all attributes for event #5, including non IDS marked attributes too, use the following line:</p>
<pre>
<?php
echo Configure::read('MISP.baseurl').'/attributes/text/download/all/null/5/true';
?>
</pre>

View File

@ -193,7 +193,6 @@
?>
</ul>
</div>
<div id="popover_form" class="ajax_popover_form"></div>
</div>
<?php
echo $this->element('side_menu', array('menuList' => 'event-collection', 'menuItem' => 'index'));

View File

@ -191,8 +191,6 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
<div id="pivots_div">
<?php if (sizeOf($allPivots) > 1) echo $this->element('pivot'); ?>
</div>
<div id="popover_form" class="ajax_popover_form"></div>
<div id="confirmation_box" class="confirmation_box"></div>
<div id="attribute_creation_div" style="display:none;">
<?php
echo $this->element('eventattributecreation');

View File

@ -30,6 +30,8 @@
<!--?php echo $scripts_for_layout; ?-->
</head>
<body>
<div id="popover_form" class="ajax_popover_form"></div>
<div id="confirmation_box" class="confirmation_box"></div>
<div id="gray_out" class="gray_out"></div>
<div id="container">
<?php echo $this->element('global_menu');

View File

@ -45,8 +45,6 @@
</dl>
<div id="templateElements">
</div>
<div id="popover_form" class="ajax_popover_form"></div>
<div id="confirmation_box" class="confirmation_box"></div>
</div>
<?php
echo $this->element('side_menu', array('menuList' => 'templates', 'menuItem' => 'view', 'mayModify' => $mayModify));

View File

@ -109,7 +109,6 @@ endforeach; ?>
?>
</ul>
</div>
<div id="popover_form" class="ajax_popover_form"></div>
</div>
<?php
echo $this->element('side_menu', array('menuList' => 'admin', 'menuItem' => 'indexUser'));

View File

@ -1298,3 +1298,12 @@ function changeFreetextImportExecute() {
}
});
}
function exportChoiceSelect(url, elementId, checkbox) {
if (checkbox == 1) {
if ($('#' + elementId + '_toggle').prop('checked')) {
url = url + $('#' + elementId + '_set').html();
}
}
document.location.href = url;
}