Merged in release/3.8.0 (pull request #8620)

Updating develop branch with last changes in release/3.8.0, issues with plugins, second part
This commit is contained in:
Julio Cesar Laura Avendaño
2022-10-21 18:03:29 +00:00
4 changed files with 43 additions and 24 deletions

View File

@@ -63,6 +63,11 @@ class AuthenticationSource extends BaseAuthenticationSource {
} }
} }
$aData['AUTH_SOURCE_DATA'] = (is_array($aData['AUTH_SOURCE_DATA']) ? serialize($aData['AUTH_SOURCE_DATA']) : $aData['AUTH_SOURCE_DATA']); $aData['AUTH_SOURCE_DATA'] = (is_array($aData['AUTH_SOURCE_DATA']) ? serialize($aData['AUTH_SOURCE_DATA']) : $aData['AUTH_SOURCE_DATA']);
// Removing sensitive data
$loggableData = $aData;
unset($loggableData['AUTH_SOURCE_PASSWORD']);
$oConnection = Propel::getConnection(AuthenticationSourcePeer::DATABASE_NAME); $oConnection = Propel::getConnection(AuthenticationSourcePeer::DATABASE_NAME);
try { try {
$oAuthenticationSource = new AuthenticationSource(); $oAuthenticationSource = new AuthenticationSource();
@@ -71,7 +76,7 @@ class AuthenticationSource extends BaseAuthenticationSource {
$oConnection->begin(); $oConnection->begin();
$iResult = $oAuthenticationSource->save(); $iResult = $oAuthenticationSource->save();
$oConnection->commit(); $oConnection->commit();
Log::channel(':ldapAdvanced')->info("create", Bootstrap::context($aData)); Log::channel(':ldapAdvanced')->info("create", Bootstrap::context($loggableData));
$authSourceServerName = isset($aData['AUTH_SOURCE_SERVER_NAME']) ? ' - Server Name: '.$aData['AUTH_SOURCE_SERVER_NAME'] : ''; $authSourceServerName = isset($aData['AUTH_SOURCE_SERVER_NAME']) ? ' - Server Name: '.$aData['AUTH_SOURCE_SERVER_NAME'] : '';
$authSourcePort = isset($aData['AUTH_SOURCE_PORT']) ? ' - Port: '.$aData['AUTH_SOURCE_PORT'] : ''; $authSourcePort = isset($aData['AUTH_SOURCE_PORT']) ? ' - Port: '.$aData['AUTH_SOURCE_PORT'] : '';
@@ -116,6 +121,11 @@ class AuthenticationSource extends BaseAuthenticationSource {
$authSourceFilter = isset($aData['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) ? ' - Aditional Filter: '.$aData['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER'] : ''; $authSourceFilter = isset($aData['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) ? ' - Aditional Filter: '.$aData['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER'] : '';
$aData['AUTH_SOURCE_DATA'] = (is_array($aData['AUTH_SOURCE_DATA']) ? serialize($aData['AUTH_SOURCE_DATA']) : $aData['AUTH_SOURCE_DATA']); $aData['AUTH_SOURCE_DATA'] = (is_array($aData['AUTH_SOURCE_DATA']) ? serialize($aData['AUTH_SOURCE_DATA']) : $aData['AUTH_SOURCE_DATA']);
// Removing sensitive data
$loggableData = $aData;
unset($loggableData['AUTH_SOURCE_PASSWORD']);
$oConnection = Propel::getConnection(AuthenticationSourcePeer::DATABASE_NAME); $oConnection = Propel::getConnection(AuthenticationSourcePeer::DATABASE_NAME);
try { try {
$oAuthenticationSource = AuthenticationSourcePeer::retrieveByPK($aData['AUTH_SOURCE_UID']); $oAuthenticationSource = AuthenticationSourcePeer::retrieveByPK($aData['AUTH_SOURCE_UID']);
@@ -125,7 +135,7 @@ class AuthenticationSource extends BaseAuthenticationSource {
$oConnection->begin(); $oConnection->begin();
$iResult = $oAuthenticationSource->save(); $iResult = $oAuthenticationSource->save();
$oConnection->commit(); $oConnection->commit();
Log::channel(':ldapAdvanced')->info("update", Bootstrap::context($aData)); Log::channel(':ldapAdvanced')->info("update", Bootstrap::context($loggableData));
G::auditLog("UpdateAuthSource", "Authentication Source Name: ".$aData['AUTH_SOURCE_NAME']." - Authentication Source ID: (".$aData['AUTH_SOURCE_UID'].") ".$authSourceServerName.$authSourcePort.$authSourceEnabledTLS.$authSourceVersion.$authSourceBaseDn.$authAnonymous.$authSourceSearchUser.$authSourceLdapType.$authSourceIdentifier.$authSourceFilter); G::auditLog("UpdateAuthSource", "Authentication Source Name: ".$aData['AUTH_SOURCE_NAME']." - Authentication Source ID: (".$aData['AUTH_SOURCE_UID'].") ".$authSourceServerName.$authSourcePort.$authSourceEnabledTLS.$authSourceVersion.$authSourceBaseDn.$authAnonymous.$authSourceSearchUser.$authSourceLdapType.$authSourceIdentifier.$authSourceFilter);
return $iResult; return $iResult;
} }
@@ -135,7 +145,7 @@ class AuthenticationSource extends BaseAuthenticationSource {
foreach($aValidationFailures as $oValidationFailure) { foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />'; $sMessage .= $oValidationFailure->getMessage() . '<br />';
} }
Log::channel(':ldapAdvanced')->error($sMessage, Bootstrap::context($aData)); Log::channel(':ldapAdvanced')->error($sMessage, Bootstrap::context($loggableData));
throw(new Exception('The registry cannot be updated!<br />'.$sMessage)); throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
} }
} }

View File

@@ -511,6 +511,10 @@ class LdapAdvanced
{ {
$pass = explode("_", $aAuthSource["AUTH_SOURCE_PASSWORD"]); $pass = explode("_", $aAuthSource["AUTH_SOURCE_PASSWORD"]);
// Removing sensitive data
$loggableAuthSource = $aAuthSource;
unset($loggableAuthSource["AUTH_SOURCE_PASSWORD"]);
foreach ($pass as $index => $value) { foreach ($pass as $index => $value) {
if ($value == "2NnV3ujj3w") { if ($value == "2NnV3ujj3w") {
$aAuthSource["AUTH_SOURCE_PASSWORD"] = G::decrypt($pass[0], $aAuthSource["AUTH_SOURCE_SERVER_NAME"]); $aAuthSource["AUTH_SOURCE_PASSWORD"] = G::decrypt($pass[0], $aAuthSource["AUTH_SOURCE_SERVER_NAME"]);
@@ -518,18 +522,18 @@ class LdapAdvanced
} }
$ldapcnn = ldap_connect($aAuthSource['AUTH_SOURCE_SERVER_NAME'], $aAuthSource['AUTH_SOURCE_PORT']); $ldapcnn = ldap_connect($aAuthSource['AUTH_SOURCE_SERVER_NAME'], $aAuthSource['AUTH_SOURCE_PORT']);
$this->stdLog($ldapcnn, "ldap_connect", $aAuthSource); $this->stdLog($ldapcnn, "ldap_connect", $loggableAuthSource);
$ldapServer = $aAuthSource["AUTH_SOURCE_SERVER_NAME"] . ":" . $aAuthSource["AUTH_SOURCE_PORT"]; $ldapServer = $aAuthSource["AUTH_SOURCE_SERVER_NAME"] . ":" . $aAuthSource["AUTH_SOURCE_PORT"];
ldap_set_option($ldapcnn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapcnn, LDAP_OPT_PROTOCOL_VERSION, 3);
$this->stdLog($ldapcnn, "ldap_set_option", $aAuthSource); $this->stdLog($ldapcnn, "ldap_set_option", $loggableAuthSource);
ldap_set_option($ldapcnn, LDAP_OPT_REFERRALS, 0); ldap_set_option($ldapcnn, LDAP_OPT_REFERRALS, 0);
$this->stdLog($ldapcnn, "ldap_set_option", $aAuthSource); $this->stdLog($ldapcnn, "ldap_set_option", $loggableAuthSource);
if (isset($aAuthSource["AUTH_SOURCE_ENABLED_TLS"]) && $aAuthSource["AUTH_SOURCE_ENABLED_TLS"]) { if (isset($aAuthSource["AUTH_SOURCE_ENABLED_TLS"]) && $aAuthSource["AUTH_SOURCE_ENABLED_TLS"]) {
$resultLDAPStartTLS = @ldap_start_tls($ldapcnn); $resultLDAPStartTLS = @ldap_start_tls($ldapcnn);
$this->stdLog($ldapcnn, "ldap_start_tls", $aAuthSource); $this->stdLog($ldapcnn, "ldap_start_tls", $loggableAuthSource);
$ldapServer = "TLS " . $ldapServer; $ldapServer = "TLS " . $ldapServer;
} }
@@ -538,9 +542,9 @@ class LdapAdvanced
$this->log($ldapcnn, "bind $ldapServer like anonymous user"); $this->log($ldapcnn, "bind $ldapServer like anonymous user");
} else { } else {
$bBind = @ldap_bind($ldapcnn, $aAuthSource['AUTH_SOURCE_SEARCH_USER'], $aAuthSource['AUTH_SOURCE_PASSWORD']); $bBind = @ldap_bind($ldapcnn, $aAuthSource['AUTH_SOURCE_SEARCH_USER'], $aAuthSource['AUTH_SOURCE_PASSWORD']);
$this->log($ldapcnn, "bind $ldapServer with user " . $aAuthSource["AUTH_SOURCE_SEARCH_USER"]); $this->log($ldapcnn, "bind $ldapServer with user " . $loggableAuthSource["AUTH_SOURCE_SEARCH_USER"]);
} }
$this->stdLog($ldapcnn, "ldap_bind", $aAuthSource); $this->stdLog($ldapcnn, "ldap_bind", $loggableAuthSource);
$this->getDiagnosticMessage($ldapcnn); $this->getDiagnosticMessage($ldapcnn);
if (!$bBind) { if (!$bBind) {
throw new Exception("Unable to bind to server: $ldapServer . " . "LDAP-Errno: " . ldap_errno($ldapcnn) . " : " . ldap_error($ldapcnn) . " \n"); throw new Exception("Unable to bind to server: $ldapServer . " . "LDAP-Errno: " . ldap_errno($ldapcnn) . " : " . ldap_error($ldapcnn) . " \n");

View File

@@ -449,18 +449,23 @@ class adminProxy extends HttpProxyController
$this->msg = $this->result ? '' : $Server->error; $this->msg = $this->result ? '' : $Server->error;
break; break;
case 3: //try to connect to host case 3: //try to connect to host
if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { try {
$server = $hostinfo[1]; if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) {
$port = $hostinfo[2]; $server = $hostinfo[1];
} else { $port = $hostinfo[2];
$host = $srv; } else {
$server = $srv;
}
$tls = (strtoupper($SMTPSecure) === 'TLS');
$ssl = (strtoupper($SMTPSecure) === 'SSL');
$this->success = $smtp->Connect(($ssl ? 'ssl://':'') . $server, $port, $timeout);
$this->msg = $this->result ? '' : $Server->error;
} catch (Exception $e) {
$this->success = false;
$this->msg = $e->getMessage();
} }
$tls = (strtoupper($SMTPSecure) == 'tls');
$ssl = (strtoupper($SMTPSecure) == 'ssl');
$this->success = $smtp->Connect(($ssl ? 'ssl://':'').$server, $port, $timeout);
$this->msg = $this->result ? '' : $Server->error;
break; break;
case 4: //try login to host case 4: //try login to host
if ($auth_required == 'true') { if ($auth_required == 'true') {

View File

@@ -2,13 +2,13 @@
namespace ProcessMaker\BusinessModel\Files; namespace ProcessMaker\BusinessModel\Files;
use Chumper\Zipper\Zipper;
use Configurations; use Configurations;
use Exception; use Exception;
use G; use G;
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use SplFileInfo; use SplFileInfo;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use ZipArchive;
class FilesLogs extends Files class FilesLogs extends Files
{ {
@@ -227,13 +227,13 @@ class FilesLogs extends Files
private function createZip($files) private function createZip($files)
{ {
try { try {
$zipper = new Zipper(); $zipper = new ZipArchive();
$name = str_replace('.log', '.zip', $files[0]); $name = str_replace('.log', '.zip', $files[0]);
if (count($files) > 1) { if (count($files) > 1) {
$name = 'processmaker_logs.zip'; $name = 'processmaker_logs.zip';
} }
$zipper->zip($this->getPathDataSaveFile() . $name); $zipper->open($this->getPathDataSaveFile() . $name, ZipArchive::CREATE);
$pathFileLogs = $this->getPathFiles(); $pathFileLogs = $this->getPathFiles();
$pathSep = '/'; $pathSep = '/';
@@ -247,7 +247,7 @@ class FilesLogs extends Files
foreach ($files as $key => $file) { foreach ($files as $key => $file) {
$info = pathinfo($file); $info = pathinfo($file);
if (file_exists($pathFileLogs . $info['basename'])) { if (file_exists($pathFileLogs . $info['basename'])) {
$zipper->add($pathFileLogs . $info['basename']); $zipper->addFile($pathFileLogs . $info['basename'], $info['basename']);
} }
} }
$zipper->close(); $zipper->close();