summaryrefslogtreecommitdiffstats
path: root/nixos/tests/hardened.nix
diff options
context:
space:
mode:
authorJoachim Fasting <joachifm@fastmail.fm>2017-04-30 08:38:47 +0200
committerJoachim Fasting <joachifm@fastmail.fm>2017-04-30 12:05:42 +0200
commitffa83edf4a29b21f12eb96d5eb7b63e1ebae7a5f (patch)
treeed3b52c1366fe757ac5ba9ff01f96100d9048654 /nixos/tests/hardened.nix
parentab4fa1cce4c3c536811d8d7ddfcad1a8310cfb90 (diff)
nixos/tests: add tests for exercising various hardening features
This test exercises the linux_hardened kernel along with the various hardening features (enabled via the hardened profile). Move hidepid test from misc, so that misc can go back to testing a vanilla configuration.
Diffstat (limited to 'nixos/tests/hardened.nix')
-rw-r--r--nixos/tests/hardened.nix31
1 files changed, 31 insertions, 0 deletions
diff --git a/nixos/tests/hardened.nix b/nixos/tests/hardened.nix
new file mode 100644
index 000000000000..389d7ed7ffaa
--- /dev/null
+++ b/nixos/tests/hardened.nix
@@ -0,0 +1,31 @@
+import ./make-test.nix ({ pkgs, ...} : {
+ name = "hardened";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ joachifm ];
+ };
+
+ machine =
+ { config, lib, pkgs, ... }:
+ with lib;
+ { users.users.alice = { isNormalUser = true; extraGroups = [ "proc" ]; };
+ users.users.sybil = { isNormalUser = true; group = "wheel"; };
+ imports = [ ../modules/profiles/hardened.nix ];
+ };
+
+ testScript =
+ ''
+ # Test hidepid
+ subtest "hidepid", sub {
+ $machine->succeed("grep -Fq hidepid=2 /proc/mounts");
+ $machine->succeed("[ `su - sybil -c 'pgrep -c -u root'` = 0 ]");
+ $machine->succeed("[ `su - alice -c 'pgrep -c -u root'` != 0 ]");
+ };
+
+ # Test kernel module hardening
+ subtest "lock-modules", sub {
+ $machine->waitForUnit("multi-user.target");
+ # note: this better a be module we normally wouldn't load ...
+ $machine->fail("modprobe dccp");
+ };
+ '';
+})