From 87190f65109c2d9b6346650f3ee6adf4d310f9f3 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Fri, 7 Dec 2018 15:31:04 +0100 Subject: [PATCH] fix: [restSearch] Using the correct python version to call STIX scripts - Using the correct python defined in virtual env, if available, and the default global python3 otherwise --- app/Lib/Export/Stix1Export.php | 6 ++++-- app/Lib/Export/Stix2Export.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Lib/Export/Stix1Export.php b/app/Lib/Export/Stix1Export.php index 275852aee..7968b4910 100644 --- a/app/Lib/Export/Stix1Export.php +++ b/app/Lib/Export/Stix1Export.php @@ -14,12 +14,14 @@ class Stix1Export extends StixExport $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 . $this->__return_type . ' ' . $this->__baseurl . ' ' . $this->__org . ' xml' . $this->__end_of_cmd; + $my_server = ClassRegistry::init('Server'); + return $my_server->getPythonVersion() . ' ' . $framing_file . $this->__return_type . ' ' . $this->__baseurl . ' ' . $this->__org . ' xml' . $this->__end_of_cmd; } protected function __parse_misp_events($filename) { $scriptFile = $this->__scripts_dir . $this->__script_name; - return shell_exec('python3 ' . $scriptFile . ' ' . $filename . ' xml ' . $this->__baseurl . ' ' . $this->__org . $this->__end_of_cmd); + $my_server = ClassRegistry::init('Server'); + return shell_exec($my_server->getPythonVersion() . ' ' . $scriptFile . ' ' . $filename . ' xml ' . $this->__baseurl . ' ' . $this->__org . $this->__end_of_cmd); } } diff --git a/app/Lib/Export/Stix2Export.php b/app/Lib/Export/Stix2Export.php index 30b9914ca..ddf4f0b92 100644 --- a/app/Lib/Export/Stix2Export.php +++ b/app/Lib/Export/Stix2Export.php @@ -10,13 +10,15 @@ class Stix2Export extends StixExport protected function initiate_framing_params() { $framing_file = $this->__scripts_dir . 'misp_framing.py '; - return 'python3 ' . $framing_file . $this->__return_type . ' ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd; + $my_server = ClassRegistry::init('Server'); + return $my_server->getPythonVersion() . ' ' . $framing_file . $this->__return_type . ' ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd; } protected function __parse_misp_events($filename) { $scriptFile = $this->__scripts_dir . $this->__script_name; $filename = $this->__scripts_dir . 'tmp/' . $filename; - return shell_exec('python3 ' . $scriptFile . ' ' . $filename . $this->__end_of_cmd); + $my_server = ClassRegistry::init('Server'); + return shell_exec($my_server->getPythonVersion() . ' ' . $scriptFile . ' ' . $filename . $this->__end_of_cmd); } }