diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-10-18 19:18:55 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-10-18 19:21:30 +0200 |
commit | 9b46e3084bdb6b15465dcff55f7d56d7e523d630 (patch) | |
tree | 4eae3e0c457da9519de23e33c3c2ede8d378cdb9 /nixos/modules/services/monitoring | |
parent | ab8489cc404462f4108c0735c7e33106917f82d9 (diff) | |
download | nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar.gz nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar.bz2 nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar.lz nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar.xz nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.tar.zst nixlib-9b46e3084bdb6b15465dcff55f7d56d7e523d630.zip |
nixos/prometheus: add hardening exceptions to node-exporter
Conditionally grants access for the logind, wifi and network_route collectors.
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/node.nix | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/node.nix b/nixos/modules/services/monitoring/prometheus/exporters/node.nix index baac21b050f5..5e5fc7cd5524 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/node.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/node.nix @@ -35,10 +35,15 @@ in ${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags} ''; - # The systemd collector needs AF_UNIX - RestrictAddressFamilies = lib.optional (lib.any (x: x == "systemd") cfg.enabledCollectors) "AF_UNIX"; + RestrictAddressFamilies = optionals (any (collector: (collector == "logind" || collector == "systemd")) cfg.enabledCollectors) [ + # needs access to dbus via unix sockets (logind/systemd) + "AF_UNIX" + ] ++ optionals (any (collector: (collector == "network_route" || collector == "wifi")) cfg.enabledCollectors) [ + # needs netlink sockets for wireless collector + "AF_NETLINK" + ]; # The timex collector needs to access clock APIs - ProtectClock = lib.any (x: x == "timex") cfg.disabledCollectors; + ProtectClock = any (collector: collector == "timex") cfg.disabledCollectors; }; }; } |