diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91babc17efe..b9aab4928c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -284,11 +284,12 @@ repos: (dev/build/perl/virtualmin/dolibarr.pl )$ args: [ --tabs, --nola ] - - repo: https://github.com/henryykt/pre-commit-perl - rev: v0.0.5 - hooks: - - id: perlcritic - # virtualmin excuded - reason https://github.com/Dolibarr/dolibarr/pull/36370#issuecomment-3565101823 - exclude: (?x)^ - (dev/build/perl/virtualmin/dolibarr.pl - )$ + + #- repo: https://github.com/henryykt/pre-commit-perl + # rev: v0.0.5 + # hooks: + # - id: perlcritic + # # virtualmin excluded - reason https://github.com/Dolibarr/dolibarr/pull/36370#issuecomment-3565101823 + # exclude: (?x)^ + # (dev/build/perl/virtualmin/dolibarr.pl + # )$ diff --git a/.travis.yml b/.travis.yml index 98182c9eda0..c0207ddc95c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -535,9 +535,9 @@ script: echo - | - echo Show some debug info like table content or log - #echo '\d llx_adherent' | psql 'postgresql://postgres:postgres@127.0.0.1:5432/travis' - cat $TRAVIS_BUILD_DIR/upgrade18001900.log + echo Show some debug info, like table content, or migration log from some versions + echo '\d llx_blockedlog' | psql 'postgresql://postgres:postgres@127.0.0.1:5432/travis' + cat $TRAVIS_BUILD_DIR/upgrade500600.log cat $TRAVIS_BUILD_DIR/upgrade19002000.log echo @@ -557,6 +557,7 @@ script: php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KnowledgeManagement,MAIN_MODULE_EventOrganization,MAIN_MODULE_PARTNERSHIP >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_EmailCollector >> $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_BlockedLog >> $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e diff --git a/dev/build/.gitignore b/dev/build/.gitignore index 54c5d8be9c3..6c69990aaf4 100644 --- a/dev/build/.gitignore +++ b/dev/build/.gitignore @@ -7,3 +7,4 @@ /dolibarr-*.zip /*.exe /html +/makepack-dolibarr.pl.bak diff --git a/dev/build/generate_filelist_xml.php b/dev/build/generate_filelist_xml.php index 9ecf3751344..fb0b976a12d 100755 --- a/dev/build/generate_filelist_xml.php +++ b/dev/build/generate_filelist_xml.php @@ -40,6 +40,8 @@ if (substr($sapi_type, 0, 3) == 'cgi') { define('DOL_DOCUMENT_ROOT', dirname(dirname($path)).'/htdocs'); +$algo = 'sha256'; + require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -231,7 +233,7 @@ if ($release) { $gitcommit = trim($fileforgitcontent); fputs($fp, ''."\n"); - fputs($fp, ''."\n"); + fputs($fp, ''."\n"); foreach ($includeconstants as $countrycode => $tmp) { fputs($fp, ''."\n"); @@ -265,9 +267,9 @@ if ($release) { $needtoclose = 1; } if (filetype($file) == "file") { - $md5 = md5_file($file); - $checksumconcat[] = $md5; - fputs($fp, ' '.$md5.''."\n"); + $hashoffile = hash_file($algo, $file); + $checksumconcat[] = $hashoffile; + fputs($fp, ' <'.$algo.'file name="'.basename($file).'" size="'.filesize($file).'">'.$hashoffile.''."\n"); } } if ($needtoclose) { @@ -277,10 +279,10 @@ if ($release) { fputs($fp, ''."\n"); asort($checksumconcat); // Sort list of checksum - $md5htdocsdir = md5(join(',', $checksumconcat)); + $hashhtdocsdir = hash($algo, join(',', $checksumconcat)); fputs($fp, ''."\n"); - fputs($fp, $md5htdocsdir."\n"); + fputs($fp, $hashhtdocsdir."\n"); fputs($fp, ''."\n\n"); @@ -308,9 +310,9 @@ if ($release) { $needtoclose = 1; } if (filetype($file) == "file") { - $md5 = md5_file($file); - $checksumconcat[] = $md5; - fputs($fp, ' '.$md5.''."\n"); + $hashoffile = hash_file($algo, $file); + $checksumconcat[] = $hashoffile; + fputs($fp, ' <'.$algo.'file name="'.basename($file).'" size="'.filesize($file).'">'.$hashoffile.''."\n"); } } if ($needtoclose) { @@ -320,10 +322,10 @@ if ($release) { fputs($fp, ''."\n"); asort($checksumconcat); // Sort list of checksum - $md5scriptsdir = md5(join(',', $checksumconcat)); + $hashscriptsdir = hash($algo, join(',', $checksumconcat)); fputs($fp, ''."\n"); - fputs($fp, $md5scriptsdir."\n"); + fputs($fp, $hashscriptsdir."\n"); fputs($fp, ''."\n\n"); } @@ -371,10 +373,10 @@ foreach ($arrayofunalterablefiles as $entry) { $needtoclose = 1; } if (filetype($file) == "file") { - $md5 = md5_file($file); - $checksumconcat[] = $md5; + $hashoffile = hash_file($algo, $file); + $checksumconcat[] = $hashoffile; if ($release) { - fputs($fp, ' '.$md5.''."\n"); + fputs($fp, ' <'.$algo.'file name="'.basename($file).'" size="'.filesize($file).'">'.$hashoffile.''."\n"); } } } @@ -407,10 +409,10 @@ foreach ($arrayofunalterablefiles as $entry) { $needtoclose = 1; } if (filetype($file) == "file") { - $md5 = md5_file($file); - $checksumconcat[] = $md5; + $hashoffile = hash_file($algo, $file); + $checksumconcat[] = $hashoffile; if ($release) { - fputs($fp, ' '.$md5.''."\n"); + fputs($fp, ' <'.$algo.'file name="'.basename($file).'" size="'.filesize($file).'">'.$hashoffile.''."\n"); } } if ($needtoclose) { @@ -423,13 +425,13 @@ foreach ($arrayofunalterablefiles as $entry) { } asort($checksumconcat); // Sort list of checksum -$md5unalterable_files = md5(join(',', $checksumconcat)); +$hashunalterable_files = hash($algo, join(',', $checksumconcat)); if ($release) { fputs($fp, ''."\n"); fputs($fp, ''."\n"); - fputs($fp, $md5unalterable_files."\n"); + fputs($fp, $hashunalterable_files."\n"); fputs($fp, ''."\n\n"); // End of file @@ -443,9 +445,9 @@ print "\n"; if ($release) { if (empty($buildzip)) { print "File ".$outputfile." generated.\n"; - print "Signature for htdocs files: ".$md5htdocsdir."\n"; - print "Signature for scripts files: ".$md5scriptsdir."\n"; - print "Signature for the ".count($checksumconcat)." unalterable files: ".$md5unalterable_files."\n"; + print "Signature for htdocs files: ".$hashhtdocsdir."\n"; + print "Signature for scripts files: ".$hashscriptsdir."\n"; + print "Signature for the ".count($checksumconcat)." unalterable files: ".$hashunalterable_files."\n"; } else { if ($buildzip == '1' || $buildzip == 'zip') { $result = dol_compress_file($outputfile, $outputfile.'.zip', 'zip'); @@ -464,7 +466,7 @@ if ($release) { } if ($checklock) { - print "Signature for unalterable files: ".$md5unalterable_files."\n"; + print "Signature for unalterable files: ".$algo." ".$hashunalterable_files."\n"; $lockedfile = DOL_DOCUMENT_ROOT.'/../dev/lockedfiles.txt'; $checksuminlockedfile = ''; @@ -475,15 +477,15 @@ if ($checklock) { // Now we check the content of lockedfiles.txt $arraylocked = file($lockedfile); foreach ($arraylocked as $line) { - $tmparray = preg_split("/\s+/", $line, 3); - if ($tmparray[0] == $checklockmajorversion) { - $checksuminlockedfile = $tmparray[2]; + $tmparray = preg_split("/\s+/", $line, 4); + if ($tmparray[0] == $checklockmajorversion && $tmparray[2] == $algo) { + $checksuminlockedfile = $tmparray[3]; } } if (empty($checksuminlockedfile)) { - print "The major version ".$checklockmajorversion." is not locked on the scope ".$checksource." (file found but no matching entry found into dev/lockedfiles.txt).\n"; - } elseif ($checksuminlockedfile != $md5unalterable_files) { - print "The major version ".$checklockmajorversion." is locked on scope '".$checksource."' to checksum ".$checksuminlockedfile."\n"; + print "The major version ".$checklockmajorversion." is not locked on the scope '".$checksource."' (file found but no matching entry found into dev/lockedfiles.txt).\n"; + } elseif ($checksuminlockedfile != $hashunalterable_files) { + print "The major version ".$checklockmajorversion." is locked on scope '".$checksource."' to checksum ".$algo." ".$checksuminlockedfile."\n"; if ($checklockmajorversion != $checksource) { print "The checksum now differs from the locked one, so we return an error.\n"; print "\n"; diff --git a/dev/build/makepack-dolibarr.pl b/dev/build/makepack-dolibarr.pl index 6aa331f050d..29b1285cce0 100755 --- a/dev/build/makepack-dolibarr.pl +++ b/dev/build/makepack-dolibarr.pl @@ -14,7 +14,7 @@ #---------------------------------------------------------------------------- ## no critic (InputOutput::ProhibitExplicitStdin,InputOutput::RequireBriefOpen) -use strict; +#use strict; use warnings; use Cwd; use Term::ANSIColor; diff --git a/dev/lockedfiles.txt b/dev/lockedfiles.txt index 687076e05ab..656c64e857e 100644 --- a/dev/lockedfiles.txt +++ b/dev/lockedfiles.txt @@ -2,6 +2,6 @@ This file is the list of the signatures of some set of files locked to block a commit if files are tried to be modified for a given version. It is used by the CI or the script to check and guarantee that no change is done on a given scope of files. -Version Scope Signature (generated by dev/build/generate_filelist_xml.php) that must remain unchanged for this couple version/scope +Version Scope Algo Signature (generated by dev/build/generate_filelist_xml.php) that must remain unchanged for this couple version/scope -x.0.0 unalterable_files 123456 +23.0.0 unalterable_files sha256 123456 diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 3fee85da0cd..e2ce16e4aeb 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -225,6 +225,7 @@ class DolibarrApi unset($object->error); unset($object->errors); unset($object->errorhidden); + unset($object->warnings); unset($object->TRIGGER_PREFIX); unset($object->ref_previous); diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 732dfcf3c90..ffe54611c6b 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -106,15 +106,15 @@ $morehtmlcenter = ''; $registrationnumber = getHashUniqueIdOfRegistration(); $texttop = ''.$langs->trans("RegistrationNumber").': '.dol_trunc($registrationnumber, 10).''; -print load_fiche_titre($title, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); +print load_fiche_titre($title.'
'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); if ($withtab) { $head = blockedlogadmin_prepare_head(GETPOST('withtab', 'alpha')); print dol_get_fiche_head($head, 'blockedlog', '', -1); } -print $texttop; -print '

'; +//print $texttop; +//print '

'; print ''.$langs->trans("BlockedLogDesc")."
\n"; diff --git a/htdocs/blockedlog/admin/blockedlog_archives.php b/htdocs/blockedlog/admin/blockedlog_archives.php index ef0c1d01203..5a1932d2d07 100644 --- a/htdocs/blockedlog/admin/blockedlog_archives.php +++ b/htdocs/blockedlog/admin/blockedlog_archives.php @@ -447,14 +447,14 @@ $morehtmlcenter = ''; $registrationnumber = getHashUniqueIdOfRegistration(); $texttop = ''.$langs->trans("RegistrationNumber").': '.dol_trunc($registrationnumber, 10).''; -print load_fiche_titre($title, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); +print load_fiche_titre($title.'
'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); $head = blockedlogadmin_prepare_head(GETPOST('withtab', 'alpha')); print dol_get_fiche_head($head, 'archives', '', -1); -print $texttop; -print '

'; +//print $texttop; +//print '

'; print '
'; @@ -546,7 +546,7 @@ print ''; print '
'; -print $langs->trans("RestrictYearToExport").': '; +print ''.$langs->trans("RestrictYearToExport").': '; // Month print $formother->select_month((string) GETPOSTINT('monthtoexport'), 'monthtoexport', $langs->trans("Month"), 0, 'minwidth50 maxwidth75imp valignmiddle', true); print ''; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index eda4843e2a3..6bb1f40cf76 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -405,14 +405,14 @@ $morehtmlcenter = ''; $registrationnumber = getHashUniqueIdOfRegistration(); $texttop = ''.$langs->trans("RegistrationNumber").': '.dol_trunc($registrationnumber, 10).''; -print load_fiche_titre($title, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); +print load_fiche_titre($title.'
'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter); $head = blockedlogadmin_prepare_head(GETPOST('withtab', 'alpha')); print dol_get_fiche_head($head, 'fingerprints', '', -1); -print $texttop; -print '

'; +//print $texttop; +//print '

'; print '
'; diff --git a/htdocs/blockedlog/admin/filecheck.php b/htdocs/blockedlog/admin/filecheck.php index 7045dc93e3b..87c976b9f7f 100644 --- a/htdocs/blockedlog/admin/filecheck.php +++ b/htdocs/blockedlog/admin/filecheck.php @@ -233,6 +233,9 @@ if (empty($error) && !empty($xml)) { $file_list = array(); $out = ''; + //$algo = 'md5'; // For v22- + $algo = 'sha256'; // For v23+ + // Forced constants if (is_object($xml->dolibarr_constants[0]) || $mode == 'unalterable') { $out .= load_fiche_titre($langs->trans("ForcedConstants")); @@ -349,6 +352,7 @@ if (empty($error) && !empty($xml)) { $onlymodifiedorremoved = 0; } + // Scan htdocs if (is_object($listoffilestoanalyze)) { // @phan-suppress-next-line PhanTypeArraySuspicious @@ -361,15 +365,15 @@ if (empty($error) && !empty($xml)) { // Fill file_list with files in signature, new files, modified files getFilesUpdated($file_list, $listoffilestoanalyze, '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list - '@phan-var-force array{insignature:string[],missing?:array,updated:array} $file_list'; + '@phan-var-force array{insignature:string[],missing?:array,updated:array} $file_list'; // Complete with list of new files into $file_list['added'] - if ($onlymodifiedorremoved) { + if (empty($onlymodifiedorremoved)) { foreach ($scanfiles as $valfile) { $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); if (!in_array($tmprelativefilename, $file_list['insignature'])) { - $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][] = array('filename' => $tmprelativefilename, 'md5' => $md5newfile); + $hashnewfile = @hash_file($algo, $valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename' => $tmprelativefilename, 'hash' => $hashnewfile, 'algo' => $algo); } } } @@ -398,7 +402,7 @@ if (empty($error) && !empty($xml)) { $out .= dol_print_size((int) $file['expectedsize']); } $out .= ''."\n"; - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''."\n"; + $out .= ''.dol_escape_htmltag($file['expectedhash']).''."\n"; $out .= "\n"; } } else { @@ -432,8 +436,8 @@ if (empty($error) && !empty($xml)) { $out .= ''; $out .= ''.$i.''."\n"; $out .= ''.dol_escape_htmltag($file['filename']).''."\n"; - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''."\n"; - $out .= ''.dol_escape_htmltag($file['md5']).''."\n"; + $out .= ''.dol_escape_htmltag($file['expectedhash']).''."\n"; + $out .= ''.dol_escape_htmltag($file['hash']).''."\n"; $out .= ''; if ($file['expectedsize']) { $out .= dol_print_size((int) $file['expectedsize']); @@ -490,8 +494,8 @@ if (empty($error) && !empty($xml)) { $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } $out .= ''."\n"; - $out .= ''.dol_escape_htmltag((string) $file['expectedmd5']).''."\n"; // @phan-suppress-current-line PhanTypeInvalidDimOffset - $out .= ''.dol_escape_htmltag($file['md5']).''."\n"; + $out .= ''.dol_escape_htmltag((string) $file['expectedhash']).''."\n"; // @phan-suppress-current-line PhanTypeInvalidDimOffset + $out .= ''.dol_escape_htmltag($file['hash']).''."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; $out .= ''.dol_print_size($size).''."\n"; @@ -525,14 +529,14 @@ if (empty($error) && !empty($xml)) { if (is_object($xml->dolibarr_scripts_dir[0])) { $file_list = array(); $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', ???, $checksumconcat); // Fill array $file_list - '@phan-var-force array{insignature:string[],missing?:array,updated:array} $file_list'; + '@phan-var-force array{insignature:string[],missing?:array,updated:array} $file_list'; }*/ // Section Globalchecksum asort($checksumconcat); // Sort list of checksum - $checksumget = md5(implode(',', $checksumconcat)); + $checksumget = hash($algo, implode(',', $checksumconcat)); if ($mode == 'unalterable') { $nameofsection = 'dolibarr_unalterable_files_checksum'; @@ -585,7 +589,16 @@ if (empty($error) && !empty($xml)) { $outforlistoffiles .= '