Skip to content

Commit b0cb117

Browse files
committed
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.
1 parent 62a0799 commit b0cb117

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libexpr/get-drvs.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "eval-inline.hh"
44

55
#include <cstring>
6+
#include <regex>
67

78

89
namespace nix {
@@ -262,6 +263,9 @@ static string addToPath(const string & s1, const string & s2)
262263
}
263264

264265

266+
static std::regex attrRegex("[A-Za-z_][A-Za-z0-9-_+]*");
267+
268+
265269
static void getDerivations(EvalState & state, Value & vIn,
266270
const string & pathPrefix, Bindings & autoArgs,
267271
DrvInfos & drvs, Done & done,
@@ -286,6 +290,8 @@ static void getDerivations(EvalState & state, Value & vIn,
286290
precedence). */
287291
for (auto & i : v.attrs->lexicographicOrder()) {
288292
Activity act(*logger, lvlDebug, format("evaluating attribute ‘%1%’") % i->name);
293+
if (!std::regex_match(std::string(i->name), attrRegex))
294+
continue;
289295
string pathPrefix2 = addToPath(pathPrefix, i->name);
290296
if (combineChannels)
291297
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);

0 commit comments

Comments
 (0)