From 8a4911d18c7986411577aa45a514c2506d24efa1 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Tue, 25 Sep 2018 12:10:39 +0200 Subject: [PATCH] fix: [restSearch] Fixed variables & indent --- app/Lib/Export/StixExport.php | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/Lib/Export/StixExport.php b/app/Lib/Export/StixExport.php index 8c6d49326..b02eec473 100644 --- a/app/Lib/Export/StixExport.php +++ b/app/Lib/Export/StixExport.php @@ -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()