diff --git a/doc/manual/rl-next/sri-hash-output.md b/doc/manual/rl-next/sri-hash-output.md new file mode 100644 index 000000000..4f1d2967c --- /dev/null +++ b/doc/manual/rl-next/sri-hash-output.md @@ -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. diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index ed54fe36c..dcc5e2be2 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -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; } } diff --git a/lix/libstore/export-import.cc b/lix/libstore/export-import.cc index a17ce2af2..062be93de 100644 --- a/lix/libstore/export-import.cc +++ b/lix/libstore/export-import.cc @@ -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 diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 1d6b88872..6426d9bf5 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -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 { diff --git a/lix/nix/verify.cc b/lix/nix/verify.cc index 727c197c3..c4ee44f7a 100644 --- a/lix/nix/verify.cc +++ b/lix/nix/verify.cc @@ -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)); } }