1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00
systemd/shell-completion/zsh
Maanya Goenka dfbda8799c systemd-analyze: add new 'security' option to compare unit's overall exposure level with
--threshold option added to work with security verb and with the --offline option so that
users can determine what qualifies as a security threat. The threshold set by the user is
compared with the overall exposure level assigned to a unit file and if the exposure is
higher than the threshold, 'security' will return a non-zero exit status. The default value
of the --threshold option is 100.

Example Run:

1. testcase.service is a unit file created for testing the --threshold option

    maanya-goenka@debian:~/systemd (systemd-security)$ cat<<EOF>testcase.service

    > [Service]
    > ExecStart = echo hello
    > EOF

    For the purposes of this demo, the security table outputted below has been cut to show only the first two security settings.

    maanya-goenka@debian:~/systemd (systemd-security)$ sudo build/systemd-analyze security --offline=true testcase.service
    /usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
    process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
    Support for KillMode=none is deprecated and will eventually be removed.
    /usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
    unit file, and consider removing the setting altogether.
    /usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
    /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.

      NAME                                        DESCRIPTION                                                       EXPOSURE
    ✗ PrivateNetwork=                             Service has access to the host's network                          0.5
    ✗ User=/DynamicUser=                          Service runs as root user                                         0.4

    → Overall exposure level for testcase.service: 9.6 UNSAFE 😨

    maanya-goenka@debian:~/systemd (systemd-security)$ echo $? 0

2. Next, we use the same testcase.service file but add an additional --threshold=60 parameter. We would expect 'security' to exit
   with a non-zero status because the overall exposure level (= 96) is higher than the set threshold (= 60).

    maanya-goenka@debian:~/systemd (systemd-security)$ sudo build/systemd-analyze security --offline=true --threshold=60 testcase.service
    /usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
    process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
    Support for KillMode=none is deprecated and will eventually be removed.
    /usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
    unit file, and consider removing the setting altogether.
    /usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
    /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.

      NAME                                        DESCRIPTION                                                       EXPOSURE
    ✗ PrivateNetwork=                             Service has access to the host's network                          0.5
    ✗ User=/DynamicUser=                          Service runs as root user                                         0.4

    → Overall exposure level for testcase.service: 9.6 UNSAFE 😨

    maanya-goenka@debian:~/systemd (systemd-security)$ echo $? 1
2021-08-20 10:59:13 -07:00
..
_bootctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_busctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_coredumpctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_hostnamectl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_journalctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_kernel-install shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_localectl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_loginctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_machinectl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_networkctl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_resolvectl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_sd_hosts_or_user_at_host license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
_sd_machines license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
_sd_outputmodes license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
_sd_unit_files license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
_systemctl.in shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_systemd shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_systemd-analyze systemd-analyze: add new 'security' option to compare unit's overall exposure level with 2021-08-20 10:59:13 -07:00
_systemd-delta shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_systemd-inhibit shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_systemd-nspawn tree-wide: "a" -> "an" 2021-06-30 23:33:00 +09:00
_systemd-path zsh: add systemd-path completions 2020-09-23 10:07:14 +02:00
_systemd-run shell-completion/zsh/_systemd-run: Fix completion of command names and arguments 2021-07-17 22:55:40 +01:00
_systemd-tmpfiles shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_timedatectl shell-completion: revert c1072f6473 2021-06-17 14:42:46 +02:00
_udevadm udevadm: introduce -a|--action option for test-builtin command 2021-08-18 00:08:08 +09:00
meson.build meson: use a/b instead of join_paths(a,b) 2021-07-27 19:32:35 +02:00