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:
@@ -3234,12 +3234,23 @@ class Cases
|
||||
} else {
|
||||
$sStepUid = $sStepUidObj;
|
||||
}
|
||||
|
||||
$delimiter = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(TriggersPeer::TRI_UID);
|
||||
$c->addAsColumn("TRI_TITLE", ContentPeer::CON_VALUE);
|
||||
$c->addSelectColumn(StepTriggerPeer::ST_CONDITION);
|
||||
$c->addSelectColumn(TriggersPeer::TRI_TYPE);
|
||||
$c->addSelectColumn(TriggersPeer::TRI_WEBBOT);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(TriggersPeer::TRI_UID, ContentPeer::CON_ID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_CATEGORY, $delimiter . "TRI_TITLE" . $delimiter, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, Criteria::EQUAL);
|
||||
$c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
$c->add(StepTriggerPeer::STEP_UID, $sStepUid);
|
||||
$c->add(StepTriggerPeer::TAS_UID, $sTasUid);
|
||||
$c->add(StepTriggerPeer::ST_TYPE, $sTriggerType);
|
||||
@@ -3247,13 +3258,13 @@ class Cases
|
||||
$c->addAscendingOrderByColumn(StepTriggerPeer::ST_POSITION);
|
||||
$rs = TriggersPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
while (is_array($row)) {
|
||||
$aTriggers[] = $row;
|
||||
$rs->next();
|
||||
|
||||
while ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
|
||||
$aTriggers[] = $row;
|
||||
}
|
||||
|
||||
return $aTriggers;
|
||||
}
|
||||
|
||||
@@ -3270,22 +3281,55 @@ class Cases
|
||||
|
||||
public function executeTriggers($sTasUid, $sStepType, $sStepUidObj, $sTriggerType, $aFields = array())
|
||||
{
|
||||
G::LoadClass("codeScanner");
|
||||
|
||||
$aTriggers = $this->loadTriggers($sTasUid, $sStepType, $sStepUidObj, $sTriggerType);
|
||||
|
||||
if (count($aTriggers) > 0) {
|
||||
global $oPMScript;
|
||||
|
||||
$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" : "");
|
||||
|
||||
$strFoundDisabledCode = "";
|
||||
|
||||
foreach ($aTriggers as $aTrigger) {
|
||||
//Check disabled code
|
||||
$arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $aTrigger["TRI_WEBBOT"]);
|
||||
|
||||
if (count($arrayFoundDisabledCode) > 0) {
|
||||
$strCodeAndLine = "";
|
||||
|
||||
foreach ($arrayFoundDisabledCode["source"] as $key => $value) {
|
||||
$strCodeAndLine .= (($strCodeAndLine != "")? ", " : "") . G::LoadTranslation("ID_DISABLED_CODE_CODE_AND_LINE", array($key, implode(", ", $value)));
|
||||
}
|
||||
|
||||
$strFoundDisabledCode .= "<br />- " . $aTrigger["TRI_TITLE"] . ": " . $strCodeAndLine;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Execute
|
||||
$bExecute = true;
|
||||
|
||||
if ($aTrigger['ST_CONDITION'] !== '') {
|
||||
$oPMScript->setScript($aTrigger['ST_CONDITION']);
|
||||
$bExecute = $oPMScript->evaluate();
|
||||
}
|
||||
|
||||
if ($bExecute) {
|
||||
$oPMScript->setScript($aTrigger['TRI_WEBBOT']);
|
||||
$oPMScript->execute();
|
||||
}
|
||||
}
|
||||
|
||||
if ($strFoundDisabledCode != "") {
|
||||
G::SendTemporalMessage(G::LoadTranslation("ID_DISABLED_CODE_TRIGGER_TO_EXECUTE", array($strFoundDisabledCode)), "", "string");
|
||||
}
|
||||
|
||||
return $oPMScript->aFields;
|
||||
} else {
|
||||
return $aFields;
|
||||
|
||||
@@ -4420,6 +4420,103 @@ class Processes
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disabled code
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
*
|
||||
* return array Return array with disabled code found, array empty otherwise
|
||||
*/
|
||||
public function getDisabledCode($processUid = "")
|
||||
{
|
||||
try {
|
||||
G::LoadClass("codeScanner");
|
||||
|
||||
$arrayDisabledCode = array();
|
||||
|
||||
//Set variables
|
||||
$cs = new CodeScanner("DISABLED_CODE");
|
||||
|
||||
$delimiter = DBAdapter::getStringDelimiter();
|
||||
|
||||
//Processes
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(ProcessPeer::PRO_UID);
|
||||
$criteria->addAsColumn("PRO_TITLE", ContentPeer::CON_VALUE);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(ProcessPeer::PRO_UID, ContentPeer::CON_ID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_CATEGORY, $delimiter . "PRO_TITLE" . $delimiter, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, Criteria::EQUAL);
|
||||
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(ProcessPeer::PRO_UID, $processUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$rsCriteria = ProcessPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$processUid = $row["PRO_UID"];
|
||||
$processTitle = $row["PRO_TITLE"];
|
||||
|
||||
//Triggers
|
||||
$criteriaTrigger = new Criteria("workflow");
|
||||
|
||||
$criteriaTrigger->addSelectColumn(TriggersPeer::TRI_UID);
|
||||
$criteriaTrigger->addAsColumn("TRI_TITLE", ContentPeer::CON_VALUE);
|
||||
$criteriaTrigger->addSelectColumn(TriggersPeer::TRI_WEBBOT);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(TriggersPeer::TRI_UID, ContentPeer::CON_ID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_CATEGORY, $delimiter . "TRI_TITLE" . $delimiter, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(ContentPeer::CON_LANG, $delimiter . SYS_LANG . $delimiter, Criteria::EQUAL);
|
||||
$criteriaTrigger->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
$criteriaTrigger->add(TriggersPeer::PRO_UID, $processUid, Criteria::EQUAL);
|
||||
|
||||
$rsCriteriaTrigger = TriggersPeer::doSelectRS($criteriaTrigger);
|
||||
$rsCriteriaTrigger->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteriaTrigger->next()) {
|
||||
$row = $rsCriteriaTrigger->getRow();
|
||||
|
||||
$triggerUid = $row["TRI_UID"];
|
||||
$triggerTitle = $row["TRI_TITLE"];
|
||||
$triggerWebbot = $row["TRI_WEBBOT"];
|
||||
|
||||
//Check disabled code
|
||||
$arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $triggerWebbot);
|
||||
|
||||
if (count($arrayFoundDisabledCode) > 0) {
|
||||
if (!isset($arrayDisabledCode[$processUid])) {
|
||||
$arrayDisabledCode[$processUid] = array(
|
||||
"processUid" => $processUid,
|
||||
"processTitle" => $processTitle,
|
||||
"triggers" => array()
|
||||
);
|
||||
}
|
||||
|
||||
$arrayDisabledCode[$processUid]["triggers"][] = array(
|
||||
"triggerUid" => $triggerUid,
|
||||
"triggerTitle" => $triggerTitle,
|
||||
"disabledCode" => $arrayFoundDisabledCode["source"],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayDisabledCode;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
//end class processes
|
||||
|
||||
|
||||
@@ -1551,7 +1551,7 @@ class workspaceTools
|
||||
foreach ($metadata->databases as $db) {
|
||||
if ($dbName != $newDBNames[$db->name]) {
|
||||
$dbName = $newDBNames[$db->name];
|
||||
|
||||
|
||||
if (mysql_select_db($dbName, $link)) {
|
||||
if(!$overwrite) {
|
||||
throw new Exception("Destination Database already exist (use -o to overwrite)");
|
||||
@@ -1819,4 +1819,26 @@ class workspaceTools
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disabled code
|
||||
*
|
||||
* return array Return array with disabled code found, array empty otherwise
|
||||
*/
|
||||
public function getDisabledCode()
|
||||
{
|
||||
try {
|
||||
$this->initPropel(true);
|
||||
|
||||
G::LoadClass("processes");
|
||||
|
||||
$process = new Processes();
|
||||
|
||||
//Return
|
||||
return $process->getDisabledCode();
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class AppHistory extends BaseAppHistory
|
||||
$title = $arrayOutputDocumentData["OUT_DOC_TITLE"] . " (" . G::LoadTranslation("ID_OUTPUT_DOCUMENT") . ")";
|
||||
break;
|
||||
case "ASSIGN_TASK":
|
||||
$title = G::LoadTranslation("ASSIGN_TASK") . " (" . G::LoadTranslation("ID_TRIGGERS") . ")";
|
||||
$title = G::LoadTranslation("ID_ASSIGN_TASK") . " (" . G::LoadTranslation("ID_TRIGGERS") . ")";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user