mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-01 16:36:45 +01:00
Aggiunto controllo aggiuntivo sui checksum dei file (#705)
This commit is contained in:
parent
275db1f4a5
commit
0703214738
1
.gitignore
vendored
1
.gitignore
vendored
@ -89,6 +89,7 @@ VERSION
|
||||
REVISION
|
||||
.php_cs.cache
|
||||
manifest.json
|
||||
checksum.json
|
||||
|
||||
/tests/_log/*
|
||||
/tests/_temp/*
|
||||
|
@ -46,7 +46,7 @@
|
||||
"league/csv": "^8.2",
|
||||
"maximebf/debugbar": "^1.15",
|
||||
"monolog/monolog": "^1.22",
|
||||
"mpdf/mpdf": "^7.1",
|
||||
"mpdf/mpdf": "^v8.0.7",
|
||||
"mpociot/vat-calculator": "^2.3",
|
||||
"owasp/csrf-protector-php": "^1.0",
|
||||
"phpmailer/phpmailer": "^6.0",
|
||||
|
156
gulpfile.js
156
gulpfile.js
@ -3,7 +3,6 @@ var gulp = require('gulp');
|
||||
var merge = require('merge-stream');
|
||||
var del = require('del');
|
||||
var debug = require('gulp-debug');
|
||||
var shell = require('shelljs');
|
||||
|
||||
var mainBowerFiles = require('main-bower-files');
|
||||
var gulpIf = require('gulp-if');
|
||||
@ -25,6 +24,13 @@ var concat = require('gulp-concat');
|
||||
// Altro
|
||||
var flatten = require('gulp-flatten');
|
||||
var rename = require('gulp-rename');
|
||||
|
||||
// Release
|
||||
var glob = require('globby');
|
||||
var md5File = require('md5-file')
|
||||
var fs = require('fs');
|
||||
var archiver = require('archiver');
|
||||
var shell = require('shelljs');
|
||||
var inquirer = require('inquirer');
|
||||
|
||||
// Configurazione
|
||||
@ -282,24 +288,9 @@ function phpDebugBar() {
|
||||
|
||||
// Operazioni per la release
|
||||
function release(done) {
|
||||
var archiver = require('archiver');
|
||||
var fs = require('fs');
|
||||
|
||||
// Rimozione file indesiderati
|
||||
del([
|
||||
'./vendor/tecnickcom/tcpdf/fonts/*',
|
||||
'!./vendor/tecnickcom/tcpdf/fonts/*helvetica*',
|
||||
'./vendor/mpdf/mpdf/tmp/*',
|
||||
'./vendor/mpdf/mpdf/ttfonts/*',
|
||||
'!./vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
|
||||
'!./vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
|
||||
'./vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/*',
|
||||
'./vendor/respect/validation/tests/*',
|
||||
]);
|
||||
|
||||
// Impostazione dello zip
|
||||
var output = fs.createWriteStream('./release.zip');
|
||||
var archive = archiver('zip');
|
||||
let output = fs.createWriteStream('./release.zip', {flags: 'w'});
|
||||
let archive = archiver('zip');
|
||||
|
||||
output.on('close', function () {
|
||||
console.log('ZIP completato!');
|
||||
@ -311,65 +302,90 @@ function release(done) {
|
||||
|
||||
archive.pipe(output);
|
||||
|
||||
// Aggiunta dei file
|
||||
archive.glob('**/*', {
|
||||
// Individuazione dei file da aggiungere
|
||||
glob([
|
||||
'**/*',
|
||||
'!checksum.json',
|
||||
'!.idea/**',
|
||||
'!.git/**',
|
||||
'!node_modules/**',
|
||||
'!backup/**',
|
||||
'!files/**',
|
||||
'!logs/**',
|
||||
'!config.inc.php',
|
||||
'!**/*.(lock|phar|log|zip|bak|jar|txt)',
|
||||
'!**/~*',
|
||||
'!vendor/tecnickcom/tcpdf/examples/*',
|
||||
'!vendor/tecnickcom/tcpdf/fonts/*',
|
||||
'vendor/tecnickcom/tcpdf/fonts/*helvetica*',
|
||||
'!vendor/mpdf/mpdf/tmp/*',
|
||||
'!vendor/mpdf/mpdf/ttfonts/*',
|
||||
'vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
|
||||
'vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
|
||||
'!vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/*',
|
||||
'!vendor/respect/validation/tests/*',
|
||||
], {
|
||||
dot: true,
|
||||
ignore: [
|
||||
'.git/**',
|
||||
'node_modules/**',
|
||||
'backup/**',
|
||||
'files/**',
|
||||
'logs/**',
|
||||
'config.inc.php',
|
||||
'**/*.lock',
|
||||
'**/*.phar',
|
||||
'**/*.log',
|
||||
'**/*.zip',
|
||||
'**/*.bak',
|
||||
'**/*.jar',
|
||||
'**/*.txt',
|
||||
'**/~*',
|
||||
]
|
||||
});
|
||||
}).then(function (files){
|
||||
// Aggiunta dei file con i relativi checksum
|
||||
let checksum = {};
|
||||
for (const file of files) {
|
||||
if (fs.lstatSync(file).isDirectory()) {
|
||||
archive.directory(file, file);
|
||||
} else {
|
||||
archive.file(file);
|
||||
|
||||
// Eccezioni
|
||||
archive.file('backup/.htaccess');
|
||||
archive.file('files/.htaccess');
|
||||
archive.file('files/my_impianti/componente.ini');
|
||||
archive.file('logs/.htaccess');
|
||||
|
||||
// Aggiunta del commit corrente nel file REVISION
|
||||
archive.append(shell.exec('git rev-parse --short HEAD', {
|
||||
silent: true
|
||||
}).stdout, {
|
||||
name: 'REVISION'
|
||||
});
|
||||
|
||||
// Opzioni sulla release
|
||||
inquirer.prompt([{
|
||||
type: 'input',
|
||||
name: 'version',
|
||||
message: 'Numero di versione:',
|
||||
}, {
|
||||
type: 'confirm',
|
||||
name: 'beta',
|
||||
message: 'Versione beta?',
|
||||
default: false,
|
||||
}]).then(function (result) {
|
||||
version = result.version;
|
||||
|
||||
if (result.beta) {
|
||||
version += 'beta';
|
||||
if (!file.startsWith('vendor')) {
|
||||
checksum[file] = md5File.sync(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archive.append(version, {
|
||||
name: 'VERSION'
|
||||
// Eccezioni
|
||||
archive.file('backup/.htaccess', {});
|
||||
archive.file('files/.htaccess', {});
|
||||
archive.file('files/my_impianti/componente.ini', {});
|
||||
archive.file('logs/.htaccess', {});
|
||||
|
||||
// Aggiunta del file dei checksum
|
||||
let checksumFile = fs.createWriteStream('./checksum.json', {flags: 'w'});
|
||||
checksumFile.write(JSON.stringify(checksum));
|
||||
checksumFile.close();
|
||||
archive.file('checksum.json', {});
|
||||
|
||||
// Aggiunta del commit corrente nel file REVISION
|
||||
archive.append(shell.exec('git rev-parse --short HEAD', {
|
||||
silent: true
|
||||
}).stdout, {
|
||||
name: 'REVISION'
|
||||
});
|
||||
|
||||
// Completamento dello zip
|
||||
archive.finalize();
|
||||
// Opzioni sulla release
|
||||
inquirer.prompt([{
|
||||
type: 'input',
|
||||
name: 'version',
|
||||
message: 'Numero di versione:',
|
||||
}, {
|
||||
type: 'confirm',
|
||||
name: 'beta',
|
||||
message: 'Versione beta?',
|
||||
default: false,
|
||||
}]).then(function (result) {
|
||||
let version = result.version;
|
||||
|
||||
done();
|
||||
if (result.beta) {
|
||||
version += 'beta';
|
||||
}
|
||||
|
||||
archive.append(version, {
|
||||
name: 'VERSION'
|
||||
});
|
||||
|
||||
// Completamento dello zip
|
||||
archive.finalize();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,6 @@ if (!$riferimenti->isEmpty()) {
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-info">
|
||||
<i class="fa fa-info-circle"></i>'.tr('Nessun riferimento presente').'.
|
||||
<i class="fa fa-info-circle"></i> '.tr('Nessun riferimento presente').'.
|
||||
</div>';
|
||||
}
|
||||
|
95
modules/aggiornamenti/checksum.php
Normal file
95
modules/aggiornamenti/checksum.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$file = basename(__FILE__);
|
||||
$effettua_controllo = filter('effettua_controllo');
|
||||
|
||||
// Schermata di caricamento delle informazioni
|
||||
if (empty($effettua_controllo)) {
|
||||
echo '
|
||||
<div id="righe_controlli">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info" id="box-loading">
|
||||
<i class="fa fa-spinner fa-spin"></i> '.tr('Caricamento in corso').'...
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_controlli");
|
||||
var loader = $("#box-loading");
|
||||
$(document).ready(function () {
|
||||
loader.show();
|
||||
|
||||
content.html("");
|
||||
content.load("'.$structure->fileurl($file).'?effettua_controllo=1", function() {
|
||||
loader.hide();
|
||||
});
|
||||
})
|
||||
</script>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = file_get_contents(DOCROOT.'/checksum.json');
|
||||
$checksum = json_decode($contents);
|
||||
|
||||
if (empty($checksum)) {
|
||||
echo '
|
||||
<div class="alert alert-warning">
|
||||
<i class="fa fa-warning"></i> '.tr('Impossibile effettuare controlli di integrità in assenza del file _FILE_', [
|
||||
'_FILE_' => '<b>checksum.json</b>',
|
||||
]).'.
|
||||
</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Controllo degli errori
|
||||
$errors = [];
|
||||
foreach ($checksum as $file => $md5) {
|
||||
$verifica = md5_file(DOCROOT.'/'.$file);
|
||||
if ($verifica != $md5) {
|
||||
$errors[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
// Schermata di visualizzazione degli errori
|
||||
if (!empty($errors)) {
|
||||
echo '
|
||||
<p>'.tr("Segue l'elenco dei file che presentano checksum diverso rispetto a quello regitrato nella versione ufficiale").'.</p>
|
||||
<div class="alert alert-warning">
|
||||
<i class="fa fa-warning"></i>
|
||||
'.tr('Attenzione: questa funzionalità può presentare dei risultati falsamente positivi, sulla base del contenuto del file _FILE_', [
|
||||
'_FILE_' => '<b>checksum.json</b>',
|
||||
]).'.
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.tr('File con integrità errata').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
foreach ($errors as $error) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
'.$error.'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>';
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-info">
|
||||
<i class="fa fa-info-circle"></i> '.tr('Nessun file con problemi di integrità').'.
|
||||
</div>';
|
||||
}
|
@ -47,7 +47,9 @@ if (function_exists(custom)) {
|
||||
echo '
|
||||
<div class="alert alert-warning">
|
||||
<i class="fa fa-warning"></i>
|
||||
<b>Attenzione!</b> Ci sono delle tabelle non previste nella versione standard del gestionale: '.implode(', ', $tables).'.
|
||||
<b>'.tr('Attenzione!').'</b> '.tr('Ci sono delle tabelle non previste nella versione standard del gestionale: _LIST_', [
|
||||
'_LIST_' => implode(', ', $tables),
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
||||
@ -114,8 +116,12 @@ function update() {
|
||||
}
|
||||
}
|
||||
|
||||
function checksum(button) {
|
||||
openModal("'.tr('Controllo di integrità').'", "'.$module->fileurl('checksum.php').'?id_module='.$id_module.'");
|
||||
}
|
||||
|
||||
function search(button) {
|
||||
buttonLoading(button);
|
||||
let restore = buttonLoading(button);
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
@ -136,11 +142,10 @@ function search(button) {
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
</script>
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="col-md-4">
|
||||
<div class="box box-success">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
@ -159,9 +164,22 @@ function search(button) {
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
</div>
|
||||
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
'.tr("Verifica l'integrità dell'intallazione").' <span class="tip" title="'.tr("Verifica l'integrità della tua installazione attraverso un controllo sui checksum dei file").'."><i class="fa fa-question-circle-o"></i></span>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="checksum(this)">
|
||||
<i class="fa fa-list-alt"></i> '.tr('Controlla').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="box box-info">
|
||||
|
@ -43,6 +43,7 @@
|
||||
"archiver": "^3.0.0",
|
||||
"cwd": "^0.10.0",
|
||||
"del": "^4.0.0",
|
||||
"globby": "^11.0.1",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-autoprefixer": "^7.0.0",
|
||||
"gulp-clean-css": "^4.0.0",
|
||||
@ -59,6 +60,7 @@
|
||||
"gulp-util": "^3.0.8",
|
||||
"inquirer": "^4.0.1",
|
||||
"main-bower-files": "^2.13.1",
|
||||
"md5-file": "^5.0.0",
|
||||
"shelljs": "^0.7.7"
|
||||
},
|
||||
"scripts": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user