1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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