fix: [restSearch] Ignoring square brackets around STIX2 objects returned by the python script

Because they are already provided by the framing script
pull/3766/head
chrisr3d 2018-10-05 10:28:48 +02:00
parent c4f84b2a12
commit d65482c297
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
3 changed files with 9 additions and 7 deletions

View File

@ -9,12 +9,12 @@ class Stix1Export extends StixExport
private $__baseurl = null;
private $__org = null;
protected function initiate_framing_params($return_type)
protected function initiate_framing_params()
{
$this->__baseurl = escapeshellarg(Configure::read('MISP.baseurl'));
$this->__org = escapeshellarg(Configure::read('MISP.org'));
$framing_file = $this->__scripts_dir . 'misp_framing.py ';
return 'python3 ' . $framing_file . $return_type . ' ' . $this->__baseurl . ' ' . $this->__org . ' xml' . $this->__end_of_cmd;
return 'python3 ' . $framing_file . $this->__return_type . ' ' . $this->__baseurl . ' ' . $this->__org . ' xml' . $this->__end_of_cmd;
}
protected function __parse_misp_events($filename)

View File

@ -7,10 +7,10 @@ class Stix2Export extends StixExport
protected $__attributes_limit = 15000;
private $__script_name = 'stix2/misp2stix2.py ';
protected function initiate_framing_params($return_type)
protected function initiate_framing_params()
{
$framing_file = $this->__scripts_dir . 'misp_framing.py ';
return 'python3 ' . $framing_file . $return_type . ' ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd;
return 'python3 ' . $framing_file . $this->__return_type . ' ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd;
}
protected function __parse_misp_events($filename)

View File

@ -4,7 +4,8 @@ class StixExport
{
protected $__scripts_dir = APP . 'files/scripts/';
protected $__end_of_cmd = ' 2>' . APP . 'tmp/logs/exec-errors.log';
protected $__return_type = null;
private $__tmp_dir = null;
private $__framing = null;
private $__stix_file = null;
@ -46,7 +47,8 @@ class StixExport
public function header($options = array())
{
$framing_cmd = $this->initiate_framing_params($options['returnFormat']);
$this->__return_type = $options['returnFormat'];
$framing_cmd = $this->initiate_framing_params();
$randomFileName = $this->generateRandomFileName();
$this->__tmp_dir = $this->__scripts_dir . 'tmp/';
$this->__framing = json_decode(shell_exec($framing_cmd), true);
@ -67,7 +69,7 @@ class StixExport
return '';
}
$file = new File($this->__tmp_dir . $filename . '.out');
$stix_event = $file->read();
$stix_event = ($this->__return_type == 'stix') ? $file->read() : substr($file->read(), 1, -1);
$file->close();
$file->delete();
unlink($this->__tmp_dir . $filename);