mirror of https://github.com/MISP/MISP
chg: [stix-export] Simplified loading python bin
parent
fad8ee23a1
commit
2b31ada0a5
|
@ -15,14 +15,12 @@ class Stix1Export extends StixExport
|
|||
{
|
||||
$this->__baseurl = escapeshellarg(Configure::read('MISP.baseurl'));
|
||||
$this->__org = escapeshellarg(Configure::read('MISP.org'));
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
return $my_server->getPythonVersion() . ' ' . $this->__framing_script . ' stix1 -v ' . $this->__version . ' -n ' . $this->__baseurl . ' -o ' . $this->__org . ' -f ' . $this->__return_format . ' ' . $this->__end_of_cmd;
|
||||
return $this->pythonBin() . ' ' . $this->__framing_script . ' stix1 -v ' . $this->__version . ' -n ' . $this->__baseurl . ' -o ' . $this->__org . ' -f ' . $this->__return_format . ' ' . $this->__end_of_cmd;
|
||||
}
|
||||
|
||||
protected function __parse_misp_events($filenames)
|
||||
{
|
||||
$scriptFile = $this->__scripts_dir . $this->__script_name;
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
return shell_exec($my_server->getPythonVersion() . ' ' . $scriptFile . '-v ' . $this->__version . ' -f ' . $this->__return_format . ' -o ' . $this->__org . ' -i ' . $this->__tmp_dir . $filenames . $this->__end_of_cmd);
|
||||
return shell_exec($this->pythonBin() . ' ' . $scriptFile . '-v ' . $this->__version . ' -f ' . $this->__return_format . ' -o ' . $this->__org . ' -i ' . $this->__tmp_dir . $filenames . $this->__end_of_cmd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,14 @@ class Stix2Export extends StixExport
|
|||
|
||||
protected function __initiate_framing_params()
|
||||
{
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
return $my_server->getPythonVersion() . ' ' . $this->__framing_script . ' stix2 -v ' . $this->__version . ' --uuid ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd;
|
||||
return $this->pythonBin() . ' ' . $this->__framing_script . ' stix2 -v ' . $this->__version . ' --uuid ' . escapeshellarg(CakeText::uuid()) . $this->__end_of_cmd;
|
||||
}
|
||||
|
||||
protected function __parse_misp_events($filenames)
|
||||
{
|
||||
$scriptFile = $this->__scripts_dir . $this->__script_name;
|
||||
$filenames = implode(' ' . $this->__tmp_dir, $this->__filenames);
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$result = shell_exec($my_server->getPythonVersion() . ' ' . $scriptFile . '-v ' . $this->__version . ' -i ' . $this->__tmp_dir . $filenames . $this->__end_of_cmd);
|
||||
$result = shell_exec($this->pythonBin() . ' ' . $scriptFile . '-v ' . $this->__version . ' -i ' . $this->__tmp_dir . $filenames . $this->__end_of_cmd);
|
||||
$result = preg_split("/\r\n|\n|\r/", trim($result));
|
||||
return end($result);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class StixExport
|
||||
abstract class StixExport
|
||||
{
|
||||
public $additional_params = array(
|
||||
'includeEventTags' => 1,
|
||||
|
@ -26,6 +26,8 @@ class StixExport
|
|||
public $non_restrictive_export = true;
|
||||
public $use_default_filters = true;
|
||||
|
||||
private $Server;
|
||||
|
||||
public function setDefaultFilters($filters)
|
||||
{
|
||||
$sane_version = (!empty($filters['stix-version']) && in_array($filters['stix-version'], $this->__sane_versions));
|
||||
|
@ -145,4 +147,15 @@ class StixExport
|
|||
$this->__stix_file->close();
|
||||
$this->__stix_file->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function pythonBin()
|
||||
{
|
||||
if (!isset($this->Server)) {
|
||||
$this->Server = ClassRegistry::init('Server');
|
||||
}
|
||||
return $this->Server->getPythonVersion();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1914,11 +1914,7 @@ class AppModel extends Model
|
|||
|
||||
public function getPythonVersion()
|
||||
{
|
||||
if (!empty(Configure::read('MISP.python_bin'))) {
|
||||
return Configure::read('MISP.python_bin');
|
||||
} else {
|
||||
return 'python3';
|
||||
}
|
||||
return Configure::read('MISP.python_bin') ?: 'python3';
|
||||
}
|
||||
|
||||
public function validateAuthkey($value)
|
||||
|
|
Loading…
Reference in New Issue