security(modrinth) reorder hash algo priority, prefer stronger hashes.

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2024-08-24 20:24:35 -07:00
parent fac28a81ae
commit 5f874330d5
No known key found for this signature in database
GPG Key ID: E10E321EB160949B

View File

@ -348,14 +348,14 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
QJsonObject hashes = Json::requireObject(modInfo, "hashes"); QJsonObject hashes = Json::requireObject(modInfo, "hashes");
QString hash; QString hash;
QCryptographicHash::Algorithm hashAlgorithm; QCryptographicHash::Algorithm hashAlgorithm;
hash = Json::ensureString(hashes, "sha1");
hashAlgorithm = QCryptographicHash::Sha1;
if (hash.isEmpty()) {
hash = Json::ensureString(hashes, "sha512"); hash = Json::ensureString(hashes, "sha512");
hashAlgorithm = QCryptographicHash::Sha512; hashAlgorithm = QCryptographicHash::Sha512;
if (hash.isEmpty()) { if (hash.isEmpty()) {
hash = Json::ensureString(hashes, "sha256"); hash = Json::ensureString(hashes, "sha256");
hashAlgorithm = QCryptographicHash::Sha256; hashAlgorithm = QCryptographicHash::Sha256;
if (hash.isEmpty()) {
hash = Json::ensureString(hashes, "sha1");
hashAlgorithm = QCryptographicHash::Sha1;
if (hash.isEmpty()) { if (hash.isEmpty()) {
throw JSONValidationError("No hash found for: " + file.path); throw JSONValidationError("No hash found for: " + file.path);
} }