chg: [internal] Use ProcessTool in Sighting

pull/7975/head
Jakub Onderka 2021-11-19 22:21:57 +01:00
parent acd88ade13
commit bd9cecbc2c
2 changed files with 2 additions and 6 deletions

View File

@ -1948,11 +1948,6 @@ class AppModel extends Model
return true;
}
public function getPythonVersion()
{
return Configure::read('MISP.python_bin') ?: 'python3';
}
public function validateAuthkey($value)
{
if (empty($value['authkey'])) {

View File

@ -2,6 +2,7 @@
App::uses('AppModel', 'Model');
App::uses('TmpFileTool', 'Tools');
App::uses('ServerSyncTool', 'Tools');
App::uses('ProcessTool', 'Tools');
/**
* @property Attribute $Attribute
@ -744,7 +745,7 @@ class Sighting extends AppModel
$tempFile->close();
$scriptFile = APP . "files" . DS . "scripts" . DS . "stixsighting2misp.py";
// Execute the python script and point it to the temporary filename
$result = shell_exec($this->getPythonVersion() . ' ' . $scriptFile . ' ' . $randomFileName);
$result = ProcessTool::execute([ProcessTool::pythonBin(), $scriptFile, $randomFileName]);
// The result of the script will be a returned JSON object with 2 variables: success (boolean) and message
// If success = 1 then the temporary output file was successfully written, otherwise an error message is passed along
$result = json_decode($result, true);