Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus: harden systemd service #415

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus1_all.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus1_extra.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_6_retention.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_all.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_extra.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/prometheus1.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/prometheus2.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any good reason for not setting the KillMode to control-group?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about it. I didn't touch this options since I don't know yet which value would suit best.

Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions templates/prometheus.systemd.epp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ Restart=always
<% if $max_open_files { -%>
LimitNOFILE=<%= $max_open_files %>
<% } -%>
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target