mirror of
https://github.com/NixOS/nix.git
synced 2025-12-02 07:00:59 +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
|
|
@ -34,9 +34,14 @@ std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
|
|||
for (auto & inputScheme : *inputSchemes) {
|
||||
auto res = inputScheme->inputFromAttrs(attrs2);
|
||||
if (res) {
|
||||
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
|
||||
// FIXME: require SRI hash.
|
||||
res->narHash = Hash(*narHash);
|
||||
if (auto narHash = maybeGetStrAttr(attrs, "narHash")) {
|
||||
if (narHash->empty()) {
|
||||
res->narHash = Hash(htUnknown);
|
||||
printError("warning: found empty hash, assuming you wanted '%s'", res->narHash->to_string());
|
||||
} else
|
||||
// FIXME: require SRI hash.
|
||||
res->narHash = Hash(*narHash);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue