PM-473 "Analisis de los resultados de escaneo de las..." SOLVED
Issue:
Analisis de los resultados de escaneo de las funciones en ProcessMaker. Plugin/trigger code scanner.
Cause:
Nueva solicitud de funciones
Solution:
Se ha implementado esta nueva funcionalidad, que consta de lo siguiente:
- Escaneo de codigo al importar un plugin (no se aplica a plugins enterprise)
- Escaneo de codigo al habilitar un plugin (si el plugin ya se encuentra fisicamente en el directorio de los plugins)
- Escaneo de codigo al importar un proceso
- Escaneo de codigo al crear/modificar codigo de un trigger
- Escaneo de codigo al ejecutar un caso que tenga seteados triggers en sus steps (si el trigger tiene codigo
no deseado, no se ejecuta el trigger)
- Se ha agregado la opcion "check-plugin-disabled-code" al comando "./gulliver", el mismo muestra
informacion sobre los plugins con codigo no deseado.
Ej: $ ./gulliver check-plugin-disabled-code [enterprise-plugin|custom-plugin|all|<plugin-name>]
- Se ha agregado la opcion "check-workspace-disabled-code" al comando "./processmaker", el mismo muestra
informacion sobre los workspaces con codigo no deseado en sus triggers.
Ej: $ ./processmaker check-workspace-disabled-code <myWorkspace>
- Por defecto ProcessMaker no realiza el escaneo de codigo, si se desea escanear codigo no deseado, se
debera definir el atributo "enable_blacklist = 1" en el archivo "env.ini", este atributo no se aplica
a las nuevas opciones creadas para los comandos "./gulliver" y "./processmaker"
- Para una configuracion personalizada de codigo no deseado (lista negra), se pueden definir las mismas en
el archivo "path/to/processmaker/workflow/engine/config/blacklist.ini" (si no existe el
archivo se puede crear), o tambien en el atributo "disable_functions" esto en el archivo "php.ini"
Ejemplo de "blacklist.ini":
;Classes
;=======
DashletInterface
;Functions
;=========
eval
exec
;date
;echo
strlen
This commit is contained in:
@@ -26,6 +26,63 @@ use ProcessMaker\Importer\XmlImporter;
|
||||
|
||||
ini_set("max_execution_time", 0);
|
||||
|
||||
if (isset($_FILES["PROCESS_FILENAME"]) &&
|
||||
pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION) == "pm" &&
|
||||
$_FILES["PROCESS_FILENAME"]["error"] == 0
|
||||
) {
|
||||
//Check disabled code
|
||||
$response = array();
|
||||
|
||||
try {
|
||||
$fh = fopen($_FILES["PROCESS_FILENAME"]["tmp_name"], "rb");
|
||||
$content = fread($fh, (int)(fread($fh, 9)));
|
||||
$data = unserialize($content);
|
||||
fclose($fh);
|
||||
|
||||
if (is_object($data) && isset($data->triggers) && is_array($data->triggers) && count($data->triggers) > 0) {
|
||||
G::LoadClass("codeScanner");
|
||||
|
||||
$arraySystemConfiguration = System::getSystemConfiguration(PATH_CONFIG . "env.ini");
|
||||
|
||||
$cs = new CodeScanner((isset($arraySystemConfiguration["enable_blacklist"]) && (int)($arraySystemConfiguration["enable_blacklist"]) == 1)? "DISABLED_CODE" : "");
|
||||
|
||||
$strFoundDisabledCode = "";
|
||||
|
||||
foreach ($data->triggers as $value) {
|
||||
$arrayTriggerData = $value;
|
||||
|
||||
$arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $arrayTriggerData["TRI_WEBBOT"]);
|
||||
|
||||
if (count($arrayFoundDisabledCode) > 0) {
|
||||
$strCodeAndLine = "";
|
||||
|
||||
foreach ($arrayFoundDisabledCode["source"] as $key2 => $value2) {
|
||||
$strCodeAndLine .= (($strCodeAndLine != "")? ", " : "") . G::LoadTranslation("ID_DISABLED_CODE_CODE_AND_LINE", array($key2, implode(", ", $value2)));
|
||||
}
|
||||
|
||||
$strFoundDisabledCode .= (($strFoundDisabledCode != "")? "\n" : "") . "- " . $arrayTriggerData["TRI_TITLE"] . ": " . $strCodeAndLine;
|
||||
}
|
||||
}
|
||||
|
||||
if ($strFoundDisabledCode != "") {
|
||||
$response["status"] = "DISABLED-CODE";
|
||||
$response["success"] = true;
|
||||
$response["message"] = G::LoadTranslation("ID_DISABLED_CODE_PROCESS", array($data->process["PRO_TITLE"], "\n" . $strFoundDisabledCode));
|
||||
|
||||
echo G::json_encode($response);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["success"] = true;
|
||||
$response["catchMessage"] = $e->getMessage();
|
||||
|
||||
echo G::json_encode($response);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES["PROCESS_FILENAME"]) &&
|
||||
pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION) == "pmx"
|
||||
) {
|
||||
@@ -286,17 +343,17 @@ if ($action == "uploadFileNewProcessExist") {
|
||||
|
||||
$importer->throwExceptionIfExistsReservedWordsSql($oData);
|
||||
|
||||
//**cheking if the PRO_CREATE_USER exist**//
|
||||
$usrCrtr = $oData->process['PRO_CREATE_USER'];
|
||||
|
||||
$exist = new Users();
|
||||
if($exist->userExists($usrCrtr)){
|
||||
$usrInfo = $exist->getAllInformation($usrCrtr);
|
||||
if ($usrInfo['status'] == 'CLOSED'){
|
||||
$oData->process['PRO_CREATE_USER'] = $_SESSION['USER_LOGGED'];
|
||||
}
|
||||
} else {
|
||||
$oData->process['PRO_CREATE_USER'] = $_SESSION['USER_LOGGED'];
|
||||
//**cheking if the PRO_CREATE_USER exist**//
|
||||
$usrCrtr = $oData->process['PRO_CREATE_USER'];
|
||||
|
||||
$exist = new Users();
|
||||
if($exist->userExists($usrCrtr)){
|
||||
$usrInfo = $exist->getAllInformation($usrCrtr);
|
||||
if ($usrInfo['status'] == 'CLOSED'){
|
||||
$oData->process['PRO_CREATE_USER'] = $_SESSION['USER_LOGGED'];
|
||||
}
|
||||
} else {
|
||||
$oData->process['PRO_CREATE_USER'] = $_SESSION['USER_LOGGED'];
|
||||
}
|
||||
|
||||
$Fields['PRO_FILENAME'] = $filename;
|
||||
|
||||
Reference in New Issue
Block a user