mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 13:01:12 -07:00
misc(integrity checker): Some enhancements (#1797)
* misc(integrity checker): Some enhancements * Update build_files_integrity.php * Create checksum.yml * Update checksum.yml
This commit is contained in:
parent
1ffee77abe
commit
09cafc2285
2 changed files with 61 additions and 13 deletions
31
.github/workflows/checksum.yml
vendored
Normal file
31
.github/workflows/checksum.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
name: Generate Checksums
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-checksums:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Generate MD5 checksums
|
||||||
|
run: |
|
||||||
|
find . -type f -not -path "./.git/*" -exec md5sum {} \; > internal_data/checksums.md5
|
||||||
|
|
||||||
|
- name: Commit and push checksums.md5 if changed
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
|
||||||
|
if git diff --quiet internal_data/checksums.md5; then
|
||||||
|
echo "No changes in checksums.md5"
|
||||||
|
else
|
||||||
|
git add checksums.md5
|
||||||
|
git commit -m "Update checksums.md5 📄"
|
||||||
|
git push
|
||||||
|
fi
|
|
@ -20,18 +20,27 @@ if (!$bb_cfg['integrity_check']) {
|
||||||
$filesList = [];
|
$filesList = [];
|
||||||
$wrongFilesList = [];
|
$wrongFilesList = [];
|
||||||
|
|
||||||
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r');
|
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r+');
|
||||||
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
|
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
|
||||||
|
|
||||||
$ignoreFiles = [
|
$ignoreFiles = [
|
||||||
'.env.example',
|
'.git/*',
|
||||||
|
'.github/*',
|
||||||
|
'*.md',
|
||||||
|
'*.yml',
|
||||||
|
'*.toml',
|
||||||
|
'*.json',
|
||||||
|
'*.lock',
|
||||||
|
'.env*',
|
||||||
|
'vendor',
|
||||||
|
'.gitignore',
|
||||||
|
'.editorconfig',
|
||||||
'.htaccess',
|
'.htaccess',
|
||||||
'CHANGELOG.md',
|
'*/.htaccess',
|
||||||
'robots.txt',
|
'robots.txt',
|
||||||
|
// TorrentPier specific
|
||||||
'install.php',
|
'install.php',
|
||||||
'favicon.png',
|
'favicon.png',
|
||||||
'composer.json',
|
|
||||||
'composer.lock',
|
|
||||||
hide_bb_path(CHECKSUMS_FILE),
|
hide_bb_path(CHECKSUMS_FILE),
|
||||||
hide_bb_path(BB_ENABLED),
|
hide_bb_path(BB_ENABLED),
|
||||||
'library/config.php',
|
'library/config.php',
|
||||||
|
@ -41,21 +50,29 @@ $ignoreFiles = [
|
||||||
|
|
||||||
foreach ($checksumFile as $line) {
|
foreach ($checksumFile as $line) {
|
||||||
$parts = explode(' ', $line);
|
$parts = explode(' ', $line);
|
||||||
[$hash, $path] = $parts;
|
if (!isset($parts[0]) || !isset($parts[1])) {
|
||||||
|
|
||||||
if (!isset($hash) || !isset($path)) {
|
|
||||||
// Skip end line
|
// Skip end line
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($ignoreFiles) && in_array($path, $ignoreFiles)) {
|
// Skip files from "Ignoring list"
|
||||||
// Skip files from "Ignoring list"
|
if (!empty($ignoreFiles)) {
|
||||||
continue;
|
$skip = false;
|
||||||
|
foreach ($ignoreFiles as $pattern) {
|
||||||
|
$pattern = trim($pattern);
|
||||||
|
if (fnmatch($pattern, $parts[1])) {
|
||||||
|
$skip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($skip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesList[] = [
|
$filesList[] = [
|
||||||
'path' => trim($path),
|
'path' => trim($parts[1]),
|
||||||
'hash' => trim($hash)
|
'hash' => trim($parts[0])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue