fix: [restSearch] Fixed variables & indent

pull/3766/head
chrisr3d 2018-09-25 12:10:39 +02:00
parent 933af46dfb
commit 8a4911d18c
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 28 additions and 28 deletions

View File

@ -2,52 +2,52 @@
class StixExport
{
private $__tmpDir = APP . 'files' . DS . 'scripts' . DS;
private $end_of_cmd = ' xml 2>' . APP . 'tmp/logs/exec-errors.log';
private $__tmpDir = APP . 'files/scripts/';
private $end_of_cmd = ' 2>' . APP . 'tmp/logs/exec-errors.log';
public function handler($data, $options = array())
{
$randomFileName = $this->generateRandomFileName();
$tmpDir = $this->__tmpDir . 'tmp/';
App::uses('JSONConverterTool', 'Tools');
$converter = new JSONConverterTool();
$event = $converter->convert($data);
$tempFile = new File($tmpDir . $randomFileName, true, 0644);
$tempFile->write($event);
unset($event);
$scriptFile = $this->__tmpDir . 'misp2stix.py';
$result = shell_exec('python3 ' . $scriptFile . ' ' . $randomFileName . ' xml ' . $this->baseurl . ' ' . $this->org . $this->end_of_cmd);
$decoded = json_decode($result, true);
$tempFile->close();
$tempFile->delete();
App::uses('JSONConverterTool', 'Tools');
$converter = new JSONConverterTool();
$event = $converter->convert($data);
$tempFile = new File($tmpDir . $randomFileName, true, 0644);
$tempFile->write($event);
unset($event);
$scriptFile = $this->__tmpDir . 'misp2stix.py';
$result = shell_exec('python3 ' . $scriptFile . ' ' . $randomFileName . ' xml ' . $this->baseurl . ' ' . $this->org . $this->end_of_cmd);
$decoded = json_decode($result, true);
$tempFile->close();
$tempFile->delete();
if (!isset($decoded['success']) || !$decoded['success']) {
return '';
}
$file = new File($tmpDir . $randomFileName . '.out');
$stix_event = $file->read();
$file->close();
$file->delete();
return $stix_event;
return '';
}
$file = new File($tmpDir . $randomFileName . '.out');
$stix_event = $file->read();
$file->close();
$file->delete();
return $stix_event;
}
public function header($options = array())
{
$this->baseurl = escapeshellarg(Configure::read('MISP.baseurl'));
$this->org = escapeshellarg(Configure::read('MISP.org'));
$framing_file = $this->__tmpDir . 'misp_framing.py ';
$framing_cmd = 'python3 ' . $framing_file . 'stix ' . $this->baseurl . ' ' . $this->org . $this->end_of_cmd;
$this->framing = json_decode(shell_exec($framing_cmd), true);
return $this->framing['header'];
$this->baseurl = escapeshellarg(Configure::read('MISP.baseurl'));
$this->org = escapeshellarg(Configure::read('MISP.org'));
$framing_file = $this->__tmpDir . 'misp_framing.py ';
$framing_cmd = 'python3 ' . $framing_file . 'stix ' . $this->baseurl . ' ' . $this->org . ' xml' . $this->end_of_cmd;
$this->framing = json_decode(shell_exec($framing_cmd), true);
return $this->framing['header'];
}
public function footer($options = array())
{
return $this->framing['footer'];
return $this->framing['footer'];
}
public function separator($options = array())
{
return $this->framing['separator'];
return $this->framing['separator'];
}
public function generateRandomFileName()