diff --git a/gulliver/bin/tasks/pakeGulliver.php b/gulliver/bin/tasks/pakeGulliver.php index 0b3389785..ea21f2039 100755 --- a/gulliver/bin/tasks/pakeGulliver.php +++ b/gulliver/bin/tasks/pakeGulliver.php @@ -2732,7 +2732,7 @@ function run_check_plugin_disabled_code($task, $args) if (count($arrayData) > 0) { G::LoadClass("codeScanner"); - $cs = new CodeScanner("DISABLED_CODE"); + $cs = new CodeScanner(true); $strFoundDisabledCode = ""; diff --git a/gulliver/system/class.codeScanner.php b/gulliver/system/class.codeScanner.php index cb12e9a37..1b59367ac 100644 --- a/gulliver/system/class.codeScanner.php +++ b/gulliver/system/class.codeScanner.php @@ -14,15 +14,33 @@ class CodeScanner /** * Constructor of the class * - * return void + * @param mixed $option Option + * + * @return void */ - public function __construct($option) + public function __construct($option = null) { try { - switch ($option) { - case "DISABLED_CODE": - $this->setArrayDisabledCode(); - break; + $flag = false; + + if (!is_null($option)) { + switch (gettype($option)) { + case 'string': + $workspace = new workspaceTools($option); + + if ($workspace->workspaceExists()) { + $arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace->name); + $flag = (int)($arraySystemConfiguration['enable_blacklist']) == 1; + } + break; + case 'boolean': + $flag = $option; + break; + } + } + + if ($flag) { + $this->setArrayDisabledCode(); } } catch (Exception $e) { throw $e; @@ -32,9 +50,9 @@ class CodeScanner /** * Set disabled code * - * return void + * @return void */ - public function setArrayDisabledCode() + private function setArrayDisabledCode() { try { //Disabled functions (PHP) @@ -61,9 +79,9 @@ class CodeScanner /** * Get disabled code * - * return array Return array with disabled code + * @return array Returns an array with disabled code */ - public function getArrayDisabledCode() + private function getArrayDisabledCode() { try { return $this->arrayDisabledCode; @@ -75,9 +93,9 @@ class CodeScanner /** * Verify if exists disabled code * - * return bool Return true if exists disabled code, false otherwise + * @return bool Returns true if exists disabled code, false otherwise */ - public function existsDisabledCode() + private function existsDisabledCode() { try { return !empty($this->arrayDisabledCode); @@ -91,9 +109,9 @@ class CodeScanner * * @param string $source Source * - * return array Return array with disabled code found, array empty otherwise + * @return array Returns an array with disabled code found, array empty otherwise */ - public function checkDisabledCodeInSource($source) + private function checkDisabledCodeInSource($source) { try { if (!$this->existsDisabledCode()) { @@ -155,7 +173,7 @@ class CodeScanner * @param string $option Option (SOURCE, PATH, FILE) * @param string $data Data * - * return array Return array with disabled code found, array empty otherwise + * return array Returns an array with disabled code found, array empty otherwise */ public function checkDisabledCode($option, $data) { diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 2e99cf8e6..9ad684fba 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -3555,10 +3555,8 @@ class Cases $oPMScript = new PMScript(); $oPMScript->setFields($aFields); - $arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - /*----------------------------------********---------------------------------*/ - $cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new CodeScanner(SYS_SYS); $strFoundDisabledCode = ""; /*----------------------------------********---------------------------------*/ diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index 11b11699f..b84733cf9 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -5913,11 +5913,12 @@ class Processes /** * Get disabled code * - * @param string $processUid Unique id of Process + * @param string $processUid Unique id of Process + * @param string $workspaceName Workspace name * - * return array Return array with disabled code found, array empty otherwise + * @return array Returns an array with disabled code found, array empty otherwise */ - public function getDisabledCode($processUid = "") + public function getDisabledCode($processUid = null, $workspaceName = null) { try { /*----------------------------------********---------------------------------*/ @@ -5933,7 +5934,7 @@ class Processes } //Set variables - $cs = new CodeScanner("DISABLED_CODE"); + $cs = new CodeScanner((!is_null($workspaceName))? $workspaceName : SYS_SYS); $delimiter = DBAdapter::getStringDelimiter(); @@ -5949,7 +5950,7 @@ class Processes $arrayCondition[] = array(ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); - if ($processUid != "") { + if (!is_null($processUid)) { $criteria->add(ProcessPeer::PRO_UID, $processUid, Criteria::EQUAL); } diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php index 4eaaba30b..b744a1e7c 100755 --- a/workflow/engine/classes/class.system.php +++ b/workflow/engine/classes/class.system.php @@ -72,6 +72,7 @@ class System 'safari_cookie_lifetime' => 1, 'error_reporting' => "", 'display_errors' => 'On', + 'enable_blacklist' => 0, 'system_utc_time_zone' => 0, 'server_protocol' => '', 'server_hostname_requests_frontend' => '' diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index f425e7d53..d15eb74d9 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -1946,7 +1946,7 @@ class workspaceTools /** * Get disabled code * - * return array Return array with disabled code found, array empty otherwise + * @return array Returns an array with disabled code found, array empty otherwise */ public function getDisabledCode() { @@ -1958,7 +1958,7 @@ class workspaceTools $process = new Processes(); //Return - return $process->getDisabledCode(); + return $process->getDisabledCode(null, $this->name); } catch (Exception $e) { throw $e; } diff --git a/workflow/engine/methods/processes/processes_Import_Ajax.php b/workflow/engine/methods/processes/processes_Import_Ajax.php index f9e03fd56..64386742a 100644 --- a/workflow/engine/methods/processes/processes_Import_Ajax.php +++ b/workflow/engine/methods/processes/processes_Import_Ajax.php @@ -71,9 +71,7 @@ if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm if (!empty($arrayTrigger)) { G::LoadClass("codeScanner"); - $arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - - $cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new CodeScanner(SYS_SYS); $strFoundDisabledCode = ""; @@ -313,7 +311,7 @@ if (isset($_POST["PRO_FILENAME"]) && G::LoadClass( 'Process' ); $oProcess = new Process(); $processData = $oProcess->load( $prjUid ); - $proType = $processData["PRO_TYPE"]; + $proType = $processData["PRO_TYPE"]; $result = array( "success" => true, diff --git a/workflow/engine/methods/setup/pluginsChange.php b/workflow/engine/methods/setup/pluginsChange.php index 8e9b473c6..581f1de7b 100755 --- a/workflow/engine/methods/setup/pluginsChange.php +++ b/workflow/engine/methods/setup/pluginsChange.php @@ -58,9 +58,7 @@ if ($handle = opendir( PATH_PLUGINS )) { //Check disabled code G::LoadClass("codeScanner"); - $arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - - $cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new CodeScanner(SYS_SYS); $arrayFoundDisabledCode = array_merge($cs->checkDisabledCode("FILE", PATH_PLUGINS . $pluginName . ".php"), $cs->checkDisabledCode("PATH", PATH_PLUGINS . $pluginName)); diff --git a/workflow/engine/methods/setup/pluginsImportFile.php b/workflow/engine/methods/setup/pluginsImportFile.php index 2bc45867b..51e9d0938 100755 --- a/workflow/engine/methods/setup/pluginsImportFile.php +++ b/workflow/engine/methods/setup/pluginsImportFile.php @@ -252,9 +252,7 @@ try { //Check disabled code G::LoadClass("codeScanner"); - $arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - - $cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new CodeScanner(SYS_SYS); $arrayFoundDisabledCode = array_merge($cs->checkDisabledCode("FILE", $path . $pluginFile), $cs->checkDisabledCode("PATH", $path . $sClassName)); diff --git a/workflow/engine/methods/triggers/triggers_Save.php b/workflow/engine/methods/triggers/triggers_Save.php index 7f84e9a8a..275bc7f55 100755 --- a/workflow/engine/methods/triggers/triggers_Save.php +++ b/workflow/engine/methods/triggers/triggers_Save.php @@ -87,9 +87,7 @@ if (isset( $sfunction ) && $sfunction == 'lookforNameTrigger') { //Check disabled code G::LoadClass("codeScanner"); - $arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - - $cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new CodeScanner(SYS_SYS); $arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $value["TRI_WEBBOT"]); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Trigger.php b/workflow/engine/src/ProcessMaker/BusinessModel/Trigger.php index d940fe144..827269dc6 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Trigger.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Trigger.php @@ -188,9 +188,7 @@ class Trigger //Check disabled code \G::LoadClass("codeScanner"); - $arraySystemConfiguration = \System::getSystemConfiguration(PATH_CONFIG . "env.ini"); - - $cs = new \CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : ""); + $cs = new \CodeScanner(SYS_SYS); $arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $dataTrigger["TRI_WEBBOT"]);