Merge branch 'hotfix-2.2.32' into develop

pull/274/head
iglocska 2014-06-24 13:44:22 +02:00
commit 6ac105e132
1 changed files with 20 additions and 24 deletions

View File

@ -43,22 +43,22 @@ class EventShell extends AppShell
$id = $this->args[2]; $id = $this->args[2];
$this->Job->id = $id; $this->Job->id = $id;
$eventIds = $this->Event->fetchEventIds($org, $isSiteAdmin); $eventIds = $this->Event->fetchEventIds($org, $isSiteAdmin);
$results = array(); $result = array();
$eventCount = count($eventIds); $eventCount = count($eventIds);
$dir = new Folder(APP . DS . '/tmp/cached_exports/xml');
if ($isSiteAdmin) {
$file = new File($dir->pwd() . DS . 'misp.xml' . '.ADMIN.xml');
} else {
$file = new File($dir->pwd() . DS . 'misp.xml' . '.' . $org . '.xml');
}
$file->write('<?xml version="1.0" encoding="UTF-8"?><response>');
foreach ($eventIds as $k => $eventId) { foreach ($eventIds as $k => $eventId) {
$temp = $this->Event->fetchEvent($eventId['Event']['id'], null, $org, $isSiteAdmin, $this->Job->id); $temp = $this->Event->fetchEvent($eventId['Event']['id'], null, $org, $isSiteAdmin, $this->Job->id);
$results[$k] = $temp[0]; $result = $temp[0];
$this->Job->saveField('progress', ($k+1) / $eventCount * 80);
}
// Whitelist check
$results = $this->Whitelist->removeWhitelistedFromArray($results, false);
foreach ($results as $k => $result) {
$result['Event']['Attribute'] = $result['Attribute']; $result['Event']['Attribute'] = $result['Attribute'];
$result['Event']['ShadowAttribute'] = $result['ShadowAttribute']; $result['Event']['ShadowAttribute'] = $result['ShadowAttribute'];
$result['Event']['RelatedEvent'] = $result['RelatedEvent']; $result['Event']['RelatedEvent'] = $result['RelatedEvent'];
// //
// cleanup the array from things we do not want to expose // cleanup the array from things we do not want to expose
// //
@ -80,7 +80,7 @@ class EventShell extends AppShell
foreach($result['Event']['ShadowAttribute'] as $key => $value) { foreach($result['Event']['ShadowAttribute'] as $key => $value) {
$result['Event']['ShadowAttribute'][$key]['value'] = preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $result['Event']['ShadowAttribute'][$key]['value']); $result['Event']['ShadowAttribute'][$key]['value'] = preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $result['Event']['ShadowAttribute'][$key]['value']);
} }
if (isset($result['Event']['RelatedEvent'])) { if (isset($result['Event']['RelatedEvent'])) {
foreach ($result['Event']['RelatedEvent'] as $key => $value) { foreach ($result['Event']['RelatedEvent'] as $key => $value) {
unset($result['Event']['RelatedEvent'][$key]['user_id']); unset($result['Event']['RelatedEvent'][$key]['user_id']);
@ -90,21 +90,17 @@ class EventShell extends AppShell
} }
} }
} }
$xmlArray['response']['Event'][] = $result['Event'];
if ($k % 20 == 0) { $xmlArray['Event'] = $result['Event'];
$this->Job->saveField('progress', (($k+1) / $eventCount * 10) + 79); $xmlObject = Xml::fromArray($xmlArray, array('format' => 'tags'));
}
$string = $xmlObject->asXML();
$string = preg_replace('/<\?xml.+\?>/', '', $string);
$file->append($string);
$this->Job->saveField('progress', ($k+1) / $eventCount * 100);
} }
$xmlObject = Xml::fromArray($xmlArray, array('format' => 'tags')); $file->append('</response>');
$dir = new Folder(APP . DS . '/tmp/cached_exports/xml');
if ($isSiteAdmin) {
$file = new File($dir->pwd() . DS . 'misp.xml' . '.ADMIN.xml');
} else {
$file = new File($dir->pwd() . DS . 'misp.xml' . '.' . $org . '.xml');
}
$file->write($xmlObject->asXML());
$file->close(); $file->close();
$this->Job->saveField('progress', '100');
} }
public function cachehids() { public function cachehids() {