From 43b26ef1b9eb30ea2e2155e747fca1041e10726d Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 25 Feb 2023 17:13:08 -0500 Subject: [PATCH] delete more stuff --- app/assets/js/assetguard.js | 86 ------------------------------------- 1 file changed, 86 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index b496e08..ac2cc40 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -1,5 +1,4 @@ // Requirements -const AdmZip = require('adm-zip') const async = require('async') const child_process = require('child_process') const crypto = require('crypto') @@ -937,26 +936,6 @@ class AssetGuard extends EventEmitter { return crypto.createHash(algo).update(buf).digest('hex') } - /** - * Used to parse a checksums file. This is specifically designed for - * the checksums.sha1 files found inside the forge scala dependencies. - * - * @param {string} content The string content of the checksums file. - * @returns {Object} An object with keys being the file names, and values being the hashes. - */ - static _parseChecksumsFile(content){ - let finalContent = {} - let lines = content.split('\n') - for(let i=0; i} checksums The checksums listed in the forge version index. - * @returns {boolean} True if the file exists and the hashes match, otherwise false. - */ - static _validateForgeChecksum(filePath, checksums){ - if(fs.existsSync(filePath)){ - if(checksums == null || checksums.length === 0){ - return true - } - let buf = fs.readFileSync(filePath) - let calcdhash = AssetGuard._calculateHash(buf, 'sha1') - let valid = checksums.includes(calcdhash) - if(!valid && filePath.endsWith('.jar')){ - valid = AssetGuard._validateForgeJar(filePath, checksums) - } - return valid - } - return false - } - - /** - * Validates a forge jar file dependency who declares a checksums.sha1 file. - * This can be an expensive task as it usually requires that we calculate thousands - * of hashes. - * - * @param {Buffer} buf The buffer of the jar file. - * @param {Array.} checksums The checksums listed in the forge version index. - * @returns {boolean} True if all hashes declared in the checksums.sha1 file match the actual hashes. - */ - static _validateForgeJar(buf, checksums){ - // Double pass method was the quickest I found. I tried a version where we store data - // to only require a single pass, plus some quick cleanup but that seemed to take slightly more time. - - const hashes = {} - let expected = {} - - const zip = new AdmZip(buf) - const zipEntries = zip.getEntries() - - //First pass - for(let i=0; i