In structured attrs derivations, __json is used to serialize the `env` attribute into a JSON object. If the derivation enables structured attributes AND specify its own `__json`, one of the field will take precedence (the reader can have fun by guessing which one). To reduce underspecification, we disallow `__json` in structured attributes derivations. Fixes #380. Change-Id: I51c3b2af1ff9449471ba81d4c72df6a7a263eef7 Signed-off-by: Raito Bezarius <raito@lix.systems>
20 lines
429 B
Python
20 lines
429 B
Python
from testlib.fixtures.nix import Nix
|
|
|
|
|
|
evil_drv = """
|
|
builtins.derivation {
|
|
name = "foo";
|
|
builder = "/bin/sh";
|
|
system = builtins.currentSystem;
|
|
__structuredAttrs = true;
|
|
|
|
__json.hello = "1";
|
|
env.hello = "2";
|
|
}
|
|
"""
|
|
|
|
|
|
def test_improper_structured_attrs_drv(nix: Nix):
|
|
result = nix.nix_build(["--expr", evil_drv]).run().expect(1)
|
|
assert "a `__json` attribute cannot be passed" in result.stderr_s
|