mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 09:19:36 +01:00
Support empty hash in fetchers
fetchTarball, fetchTree, and fetchGit all have *optional* hash attrs. This means that we need to be careful with what we allow to avoid accidentally making these defaults. When ‘hash = ""’ we assume the empty hash is wanted.
This commit is contained in:
parent
762273f1fd
commit
19aa892f20
4 changed files with 32 additions and 12 deletions
|
|
@ -263,9 +263,14 @@ struct TarballInputScheme : InputScheme
|
|||
throw Error("unsupported tarball input attribute '%s'", name);
|
||||
|
||||
auto input = std::make_unique<TarballInput>(parseURL(getStrAttr(attrs, "url")));
|
||||
if (auto hash = maybeGetStrAttr(attrs, "hash"))
|
||||
// FIXME: require SRI hash.
|
||||
input->hash = Hash(*hash);
|
||||
if (auto hash = maybeGetStrAttr(attrs, "hash")) {
|
||||
if (hash->empty()) {
|
||||
input->hash = Hash(htUnknown);
|
||||
printError("warning: found empty hash, assuming you wanted '%s'", input->hash->to_string());
|
||||
} else
|
||||
// FIXME: require SRI hash.
|
||||
input->hash = Hash(*hash);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue