HOR-1400 "Remove code scanner review for ProcessMaker plugins" SOLVED
Issue:
Remove code scanner review for ProcessMaker plugins
Cause:
Nuevo requerimiento de validacion
Solution:
Se a incluido la validacion para los "Enterprise Edition Plugin"; donde se evita que el "Code Scanner" revise estos plugins
This commit is contained in:
@@ -2688,7 +2688,12 @@ function run_check_plugin_disabled_code($task, $args)
|
|||||||
$pluginName = str_replace(".php", "", $file);
|
$pluginName = str_replace(".php", "", $file);
|
||||||
|
|
||||||
if (is_file(PATH_PLUGINS . $pluginName . ".php") && is_dir(PATH_PLUGINS . $pluginName)) {
|
if (is_file(PATH_PLUGINS . $pluginName . ".php") && is_dir(PATH_PLUGINS . $pluginName)) {
|
||||||
if (preg_match("/^.*class\s+" . $pluginName . "Plugin\s+extends\s+(\w*)\s*\{.*$/i", str_replace(array("\n", "\r"), array(" ", " "), file_get_contents(PATH_PLUGINS . $pluginName . ".php")), $arrayMatch)) {
|
if (preg_match(
|
||||||
|
'/^.*class\s+' . $pluginName . 'Plugin\s+extends\s+(\w*)\s*\{.*$/i',
|
||||||
|
str_replace(["\n", "\r", "\t"], ' ', file_get_contents(PATH_PLUGINS . $pluginName . '.php')),
|
||||||
|
$arrayMatch
|
||||||
|
)
|
||||||
|
) {
|
||||||
$pluginParentClassName = $arrayMatch[1];
|
$pluginParentClassName = $arrayMatch[1];
|
||||||
|
|
||||||
switch ($option2) {
|
switch ($option2) {
|
||||||
|
|||||||
@@ -408,11 +408,11 @@ class PMPluginRegistry
|
|||||||
unset($this->_arrayDesignerMenu[$key]);
|
unset($this->_arrayDesignerMenu[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeof( $this->_aMenuOptionsToReplace )){
|
if(sizeof( $this->_aMenuOptionsToReplace )){
|
||||||
unset( $this->_aMenuOptionsToReplace );
|
unset( $this->_aMenuOptionsToReplace );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeof( $this->_aImportProcessCallbackFile )){
|
if(sizeof( $this->_aImportProcessCallbackFile )){
|
||||||
unset( $this->_aImportProcessCallbackFile );
|
unset( $this->_aImportProcessCallbackFile );
|
||||||
}
|
}
|
||||||
@@ -1678,14 +1678,14 @@ class PMPluginRegistry
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace new options to menu
|
* Replace new options to menu
|
||||||
*
|
*
|
||||||
* @param unknown_type $namespace
|
* @param unknown_type $namespace
|
||||||
*
|
*
|
||||||
* @param array $from
|
* @param array $from
|
||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -1701,7 +1701,7 @@ class PMPluginRegistry
|
|||||||
$this->_aMenuOptionsToReplace[$from["section"]][$from["menuId"]][] = $options;
|
$this->_aMenuOptionsToReplace[$from["section"]][$from["menuId"]][] = $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all menu Options from a specific section
|
* Return all menu Options from a specific section
|
||||||
*
|
*
|
||||||
@@ -1713,10 +1713,10 @@ class PMPluginRegistry
|
|||||||
if(sizeof($oMenuFromPlugin)) {
|
if(sizeof($oMenuFromPlugin)) {
|
||||||
if(array_key_exists($strMenuName,$oMenuFromPlugin)) {
|
if(array_key_exists($strMenuName,$oMenuFromPlugin)) {
|
||||||
return $oMenuFromPlugin[$strMenuName];
|
return $oMenuFromPlugin[$strMenuName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a callBackFile in the singleton
|
* Register a callBackFile in the singleton
|
||||||
*
|
*
|
||||||
@@ -1739,12 +1739,12 @@ class PMPluginRegistry
|
|||||||
if (!$found) {
|
if (!$found) {
|
||||||
$callBackFile = new importCallBack( $namespace, $callBackFile );
|
$callBackFile = new importCallBack( $namespace, $callBackFile );
|
||||||
$this->_aImportProcessCallbackFile[] = $callBackFile;
|
$this->_aImportProcessCallbackFile[] = $callBackFile;
|
||||||
}
|
}
|
||||||
} catch(Excepton $e) {
|
} catch(Excepton $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all callBackFiles registered
|
* Return all callBackFiles registered
|
||||||
*
|
*
|
||||||
@@ -1814,5 +1814,25 @@ class PMPluginRegistry
|
|||||||
}
|
}
|
||||||
return $plugin;
|
return $plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the plugin name is Enterprise Plugin
|
||||||
|
*
|
||||||
|
* @param string $pluginName Plugin name
|
||||||
|
* @param string $path Path to plugin
|
||||||
|
*
|
||||||
|
* @return bool Returns TRUE when plugin name is Enterprise Plugin, FALSE otherwise
|
||||||
|
*/
|
||||||
|
public function isEnterprisePlugin($pluginName, $path = null)
|
||||||
|
{
|
||||||
|
$path = (!is_null($path) && $path != '')? rtrim($path, '/\\') . PATH_SEP : PATH_PLUGINS;
|
||||||
|
$pluginFile = $pluginName . '.php';
|
||||||
|
|
||||||
|
//Return
|
||||||
|
return preg_match(
|
||||||
|
'/^.*class\s+' . $pluginName . 'Plugin\s+extends\s+(?:enterprisePlugin)\s*\{.*$/i',
|
||||||
|
str_replace(["\n", "\r", "\t"], ' ', file_get_contents($path . $pluginFile))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$res = $tar->extract($path);
|
$res = $tar->extract($path);
|
||||||
|
|
||||||
|
//Verify if not is Enterprise Plugin
|
||||||
|
if (!$oPluginRegistry->isEnterprisePlugin($sClassName, $path)) {
|
||||||
|
throw new Exception(G::LoadTranslation('ID_EEPLUGIN_IMPORT_PLUGIN_NOT_IS_ENTERPRISE', [$filename]));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get contents of plugin file
|
||||||
$sContent = file_get_contents($path . $pluginFile);
|
$sContent = file_get_contents($path . $pluginFile);
|
||||||
$sContent = str_ireplace($sAux, $sAux . '_', $sContent);
|
$sContent = str_ireplace($sAux, $sAux . '_', $sContent);
|
||||||
$sContent = str_ireplace('PATH_PLUGINS', "'".$path."'", $sContent);
|
$sContent = str_ireplace('PATH_PLUGINS', "'".$path."'", $sContent);
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ if ($handle = opendir( PATH_PLUGINS )) {
|
|||||||
|
|
||||||
if (is_file(PATH_PLUGINS . $pluginName . ".php") && is_dir(PATH_PLUGINS . $pluginName)) {
|
if (is_file(PATH_PLUGINS . $pluginName . ".php") && is_dir(PATH_PLUGINS . $pluginName)) {
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=")) {
|
if (!$oPluginRegistry->isEnterprisePlugin($pluginName) &&
|
||||||
|
PMLicensedFeatures::getSingleton()->verifyfeature('B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=')
|
||||||
|
) {
|
||||||
//Check disabled code
|
//Check disabled code
|
||||||
G::LoadClass("codeScanner");
|
G::LoadClass("codeScanner");
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,11 @@ try {
|
|||||||
}
|
}
|
||||||
$res = $tar->extract( $path );
|
$res = $tar->extract( $path );
|
||||||
|
|
||||||
|
//Check if is enterprise plugin
|
||||||
|
if ($oPluginRegistry->isEnterprisePlugin($sClassName, $path)) {
|
||||||
|
throw new Exception(G::LoadTranslation('ID_PMPLUGIN_IMPORT_PLUGIN_IS_ENTERPRISE', [$filename]));
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=")) {
|
if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=")) {
|
||||||
//Check disabled code
|
//Check disabled code
|
||||||
@@ -259,12 +264,8 @@ try {
|
|||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
//Check if is enterprise plugin
|
//Get contents of plugin file
|
||||||
$sContent = file_get_contents( $path . $pluginFile );
|
$sContent = file_get_contents( $path . $pluginFile );
|
||||||
$chain = preg_quote( 'extends enterprisePlugin' );
|
|
||||||
if (strpos( $sContent, $chain )) {
|
|
||||||
throw (new Exception( 'The plugin ' . $filename . ' is a Enterprise Edition Plugin, please install the Enterprise Plugins Manager to use this plugin.' ));
|
|
||||||
}
|
|
||||||
$sContent = str_ireplace( $sAux, $sAux . '_', $sContent );
|
$sContent = str_ireplace( $sAux, $sAux . '_', $sContent );
|
||||||
$sContent = str_ireplace( 'PATH_PLUGINS', "'" . $path . "'", $sContent );
|
$sContent = str_ireplace( 'PATH_PLUGINS', "'" . $path . "'", $sContent );
|
||||||
$sContent = preg_replace( "/\\\$oPluginRegistry\s*=\s*&\s*PMPluginRegistry::getSingleton\s*\(\s*\)\s*;/i", null, $sContent );
|
$sContent = preg_replace( "/\\\$oPluginRegistry\s*=\s*&\s*PMPluginRegistry::getSingleton\s*\(\s*\)\s*;/i", null, $sContent );
|
||||||
|
|||||||
Reference in New Issue
Block a user