tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
landrun: init at 0.1.15
FliegendeWurst
10 months ago
23be8883
f0b75c41
+110
1 changed file
expand all
collapse all
unified
split
pkgs
by-name
la
landrun
package.nix
+110
pkgs/by-name/la/landrun/package.nix
···
1
1
+
{
2
2
+
stdenv,
3
3
+
lib,
4
4
+
buildGoModule,
5
5
+
fetchFromGitHub,
6
6
+
versionCheckHook,
7
7
+
which,
8
8
+
}:
9
9
+
10
10
+
buildGoModule (finalAttrs: {
11
11
+
pname = "landrun";
12
12
+
version = "0.1.15";
13
13
+
14
14
+
src = fetchFromGitHub {
15
15
+
owner = "Zouuup";
16
16
+
repo = "landrun";
17
17
+
tag = "v${finalAttrs.version}";
18
18
+
hash = "sha256-yfK7Q3FKXp5pXVBNV0w/vN0xuoaTxWCq19ziBQnLapg=";
19
19
+
};
20
20
+
21
21
+
# Test script requires lots of patching for build sandbox.
22
22
+
# Networking tests are disabled, since they actually access the internet.
23
23
+
# Two tests that specifically target /usr/bin are disabled.
24
24
+
postPatch = ''
25
25
+
patchShebangs --build test.sh
26
26
+
substituteInPlace test.sh \
27
27
+
--replace-fail 'Basic access tests' '# Basic access tests' \
28
28
+
--replace-fail '--rox /usr --ro /lib --ro /lib64' '--rox ${builtins.storeDir}' \
29
29
+
--replace-fail '--rox /usr --ro /lib,/lib64,' '--rox ${builtins.storeDir} --ro ' \
30
30
+
--replace-fail '--rox /usr --ro /etc -- whoami' '--help' \
31
31
+
--replace-fail '--rox /usr' '--rox ${builtins.storeDir}' \
32
32
+
--replace-fail '--ro /usr/bin' "" \
33
33
+
--replace-fail '#!/bin/bash' '#!${stdenv.shell}' \
34
34
+
--replace-fail '/usr/bin/true' '$(which true)' \
35
35
+
--replace-fail 'ls /usr | grep bin' '$(which ls) / | $(which grep) build' \
36
36
+
--replace-fail 'ls /usr' '$(which ls) /build' \
37
37
+
--replace-fail 'cat ' '$(which cat) ' \
38
38
+
--replace-fail 'grep ' '$(which grep) ' \
39
39
+
--replace-fail 'ls -la /usr/bin' 'ls -la /build' \
40
40
+
--replace-fail 'run_test "TCP connection' 'false && run_test "TCP' \
41
41
+
--replace-fail 'run_test "Unrestricted network access"' 'false && run_test ""' \
42
42
+
--replace-fail 'run_test "Restricted network access"' 'false && run_test ""' \
43
43
+
--replace-fail 'run_test "Execute from read-only paths regression test' 'false && run_test "' \
44
44
+
--replace-fail 'run_test "Root path' 'false && run_test "Root path'
45
45
+
'';
46
46
+
47
47
+
vendorHash = "sha256-Bs5b5w0mQj1MyT2ctJ7V38Dy60moB36+T8TFH38FA08=";
48
48
+
49
49
+
doInstallCheck = true;
50
50
+
nativeInstallCheckInputs = [
51
51
+
versionCheckHook
52
52
+
which
53
53
+
];
54
54
+
postInstallCheck = ''
55
55
+
# only check functionality if the builder supports it (Linux 5.13+)
56
56
+
set +e
57
57
+
$out/bin/landrun --best-effort --rox ${builtins.storeDir} sh -c 'exit'
58
58
+
[[ $? != 0 ]] && set -e && return
59
59
+
set -e
60
60
+
61
61
+
# only run upstream tests if the builder supports all features (Linux 6.7+)
62
62
+
set +e
63
63
+
$out/bin/landrun --rox ${builtins.storeDir} sh -c 'exit'
64
64
+
[[ $? == 0 ]] && set -e && export PATH=$out/bin:"$PATH" && ./test.sh --use-system
65
65
+
set -e
66
66
+
67
67
+
pushd $(mktemp -d)
68
68
+
69
69
+
# check directory read/write restrictions work
70
70
+
mkdir dir1
71
71
+
echo content > dir1/file1
72
72
+
73
73
+
set +e
74
74
+
$out/bin/landrun --best-effort --rox ${builtins.storeDir} sh -c '< dir1/file1'
75
75
+
[[ $? == 0 ]] && die
76
76
+
set -e
77
77
+
78
78
+
$out/bin/landrun --best-effort --rox ${builtins.storeDir} --ro ./dir1 --env PATH sh -c 'cat dir1/file1' \
79
79
+
| grep content > /dev/null
80
80
+
81
81
+
set +e
82
82
+
$out/bin/landrun --best-effort --rox ${builtins.storeDir} --ro ./dir1 sh -c 'echo x > dir1/file1'
83
83
+
[[ $? == 0 ]] && die
84
84
+
set -e
85
85
+
cat dir1/file1 | grep content > /dev/null
86
86
+
87
87
+
$out/bin/landrun --best-effort --rox ${builtins.storeDir} --rw ./dir1 sh -c 'echo x > dir1/file1'
88
88
+
cat dir1/file1 | grep x > /dev/null
89
89
+
90
90
+
popd
91
91
+
'';
92
92
+
93
93
+
meta = {
94
94
+
description = "Lightweight, secure sandbox for running Linux processes using Landlock LSM";
95
95
+
mainProgram = "landrun";
96
96
+
longDescription = ''
97
97
+
Landrun is designed to make it practical to sandbox any command with fine-grained filesystem
98
98
+
and network access controls, without root/containers/SELinux/AppArmor.
99
99
+
100
100
+
It's lightweight, auditable, and wraps Landlock v5 features.
101
101
+
102
102
+
Linux 5.13+ is required for file access restrictions, Linux 6.7+ for TCP restrictions.
103
103
+
'';
104
104
+
homepage = "https://github.com/Zouuup/landrun";
105
105
+
changelog = "https://github.com/Zouuup/landrun/releases/tag/{finalAttrs.src.tag}";
106
106
+
license = lib.licenses.gpl2Only;
107
107
+
maintainers = [ lib.maintainers.fliegendewurst ];
108
108
+
platforms = lib.platforms.linux;
109
109
+
};
110
110
+
})