Skip to content

Commit

Permalink
getDerivations(): Filter out packages with bad derivation names
Browse files Browse the repository at this point in the history
In particular, this disallows attribute names containing dots or
starting with dots. Hydra already disallowed these. This affects the
following packages in Nixpkgs master:

  2048-in-terminal
  2bwm
  389-ds-base
  90secondportraits
  lispPackages.3bmd
  lispPackages.hu.dwim.asdf
  lispPackages.hu.dwim.def

Closes #1342.
  • Loading branch information
edolstra committed Apr 19, 2017
1 parent 62a0799 commit b0cb117
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libexpr/get-drvs.cc
Expand Up @@ -3,6 +3,7 @@
#include "eval-inline.hh"

#include <cstring>
#include <regex>


namespace nix {
Expand Down Expand Up @@ -262,6 +263,9 @@ static string addToPath(const string & s1, const string & s2)
}


static std::regex attrRegex("[A-Za-z_][A-Za-z0-9-_+]*");


static void getDerivations(EvalState & state, Value & vIn,
const string & pathPrefix, Bindings & autoArgs,
DrvInfos & drvs, Done & done,
Expand All @@ -286,6 +290,8 @@ static void getDerivations(EvalState & state, Value & vIn,
precedence). */
for (auto & i : v.attrs->lexicographicOrder()) {
Activity act(*logger, lvlDebug, format("evaluating attribute ‘%1%’") % i->name);
if (!std::regex_match(std::string(i->name), attrRegex))
continue;
string pathPrefix2 = addToPath(pathPrefix, i->name);
if (combineChannels)
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
Expand Down

0 comments on commit b0cb117

Please sign in to comment.