aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-19 14:18:26 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-19 14:18:26 +0200
commitb0cb11722626e906a73f10dd9a0c9eea29faf43a (patch)
tree16417976f08da2389c862f090f94b0de9864b6cc
parent62a07992bd480d1b4490d40404147bf24b9ea952 (diff)
getDerivations(): Filter out packages with bad derivation names
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.
-rw-r--r--src/libexpr/get-drvs.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 5342739c5..ae9fb0e5e 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -3,6 +3,7 @@
#include "eval-inline.hh"
#include <cstring>
+#include <regex>
namespace nix {
@@ -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,
@@ -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);