Merge "UX: Show users SRI hashes everywhere instead of base32" into main

This commit is contained in:
jade
2025-03-23 17:46:11 +00:00
committed by Lix Systems Gerrit
5 changed files with 17 additions and 9 deletions
+8
View File
@@ -0,0 +1,8 @@
---
synopsis: "Consistently use SRI hashes in hash mismatch errors"
cls: [2868]
category: Improvements
credits: jade
---
Previously there were a few weird cases (flake inputs, e.g., among others) where Lix would print the old Nix base-32 hash format (sha256:abcd...) rather than the newer [SRI base64 format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) (sha256-AAAA...) that is used in most Lix hash mismatch errors.
This made it annoying to compare them to hashes shown by most of the modern UI surface of Lix which uses SRI.
+2 -2
View File
@@ -807,8 +807,8 @@ static void opVerifyPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
if (current.first != info->narHash) {
printError("path '%s' was modified! expected hash '%s', got '%s'",
store->printStorePath(path),
info->narHash.to_string(Base::Base32, true),
current.first.to_string(Base::Base32, true));
info->narHash.to_string(Base::SRI, true),
current.first.to_string(Base::SRI, true));
status = 1;
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ try {
Hash hash = hashSink.currentHash().first;
if (hash != info->narHash && info->narHash != Hash(info->narHash.type))
throw Error("hash of path '%s' has changed from '%s' to '%s'!",
printStorePath(path), info->narHash.to_string(Base::Base32, true), hash.to_string(Base::Base32, true));
printStorePath(path), info->narHash.to_string(Base::SRI, true), hash.to_string(Base::SRI, true));
teeSink
<< exportMagic
+4 -4
View File
@@ -1353,7 +1353,7 @@ try {
if (hashResult.first != info.narHash)
throw Error("hash mismatch importing path '%s';\n specified: %s\n got: %s",
printStorePath(info.path), info.narHash.to_string(Base::Base32, true), hashResult.first.to_string(Base::Base32, true));
printStorePath(info.path), info.narHash.to_string(Base::SRI, true), hashResult.first.to_string(Base::SRI, true));
if (hashResult.second != info.narSize)
throw Error("size mismatch importing path '%s';\n specified: %s\n got: %s",
@@ -1369,8 +1369,8 @@ try {
if (specified.hash != actualHash.hash) {
throw Error("ca hash mismatch importing path '%s';\n specified: %s\n got: %s",
printStorePath(info.path),
specified.hash.to_string(Base::Base32, true),
actualHash.hash.to_string(Base::Base32, true));
specified.hash.to_string(Base::SRI, true),
actualHash.hash.to_string(Base::SRI, true));
}
}
@@ -1755,7 +1755,7 @@ try {
if (info->narHash != nullHash && info->narHash != current.first) {
printError("path '%s' was modified! expected hash '%s', got '%s'",
printStorePath(i), info->narHash.to_string(Base::Base32, true), current.first.to_string(Base::Base32, true));
printStorePath(i), info->narHash.to_string(Base::SRI, true), current.first.to_string(Base::SRI, true));
if (repair) TRY_AWAIT(repairPath(i)); else errors = true;
} else {
+2 -2
View File
@@ -111,8 +111,8 @@ struct CmdVerify : StorePathsCommand
act2.result(resCorruptedPath, store->printStorePath(info->path));
printError("path '%s' was modified! expected hash '%s', got '%s'",
store->printStorePath(info->path),
info->narHash.to_string(Base::Base32, true),
hash.first.to_string(Base::Base32, true));
info->narHash.to_string(Base::SRI, true),
hash.first.to_string(Base::SRI, true));
}
}