aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox/assert.nix
blob: d45e4cb985706e2df24f671c8c774f4929f1fbc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  writeText,
  buildGoModule,

  version,
  name,
  want,
}:
let
  wantFile = writeText "fortify-${name}-want.json" (builtins.toJSON want);
  mainFile = writeText "main.go" ''
    package main

    import "os"
    import "git.gensokyo.uk/security/fortify/test/sandbox"

    func main() { (&sandbox.T{FS: os.DirFS("/"), PMountsPath: "/.fortify/mounts"}).MustCheckFile("${wantFile}") }
  '';
in
buildGoModule {
  pname = "fortify-${name}-check-sandbox";
  inherit version;

  src = ../.;
  vendorHash = null;

  preBuild = ''
    go mod init git.gensokyo.uk/security/fortify/test >& /dev/null
    cp ${mainFile} main.go
  '';
}