-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Selinux enforcing support for RHEL/Centos
lets have an attribute that allows to set SELinux mode to enforce/ permissive or let it as it is.
- Loading branch information
Andreas Moeller
committed
Oct 20, 2017
1 parent
d7ea263
commit 28b54ed
Showing
9 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# encoding: utf-8 | ||
|
||
# | ||
# Cookbook Name: os-hardening | ||
# Recipe: selinux.rv | ||
# | ||
# Copyright 2017, Deutsche Telekom AG | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# SELinux enforcing support | ||
|
||
case node['platform_family'] | ||
when 'rhel', 'fedora' | ||
unless node['os-hardening']['security']['selinux_mode'] == 'unmanaged' | ||
semode = case node['os-hardening']['security']['selinux_mode'] | ||
when 'enforcing' | ||
'Enforcing' | ||
when 'permissive' | ||
'Permissive' | ||
else | ||
raise "Unsupported selinuxmode #{node['os-hardening']['security']['selinux_mode']}" | ||
end | ||
|
||
execute "Set selinux mode to #{semode}" do | ||
command "setenforce #{semode}" | ||
not_if "getenforce | grep -F #{semode}" | ||
end | ||
|
||
template '/etc/selinux/config' do | ||
source 'rhel_selinuxconfig.erb' | ||
mode 0644 | ||
owner 'root' | ||
group 'root' | ||
variables selinux_mode: node['os-hardening']['security']['selinux_mode'] | ||
end | ||
end | ||
else | ||
raise "Selinux recipe is not supported on the platform family #{node['platform_family']}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% node['config_disclaimer'].to_s.split("\n").each do |l| %> | ||
# <%= l %> | ||
<% end %> | ||
|
||
# This file controls the state of SELinux on the system. | ||
# SELINUX= can take one of these three values: | ||
# enforcing - SELinux security policy is enforced. | ||
# permissive - SELinux prints warnings instead of enforcing. | ||
# disabled - No SELinux policy is loaded. | ||
SELINUX=<%= @selinux_mode %> | ||
# SELINUXTYPE= can take one of these three values: | ||
# targeted - Targeted processes are protected, | ||
# minimum - Modification of targeted policy. Only selected processes are protected. | ||
# mls - Multi Level Security protection. | ||
SELINUXTYPE=targeted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: os-hardening-integration-tests | ||
version: 1.0.0 | ||
depends: | ||
- name: linux-baseline | ||
url: https://github.com/dev-sec/linux-baseline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_controls 'os-hardening-integration-tests' | ||
|
||
control 'SELinux-01' do | ||
impact 1.0 | ||
title 'Verify SELinux enforcing' | ||
desc 'Verify SELinux enforcing' | ||
|
||
describe file('/etc/selinux/config') do | ||
its('content') { should include 'SELINUX=enforcing' } | ||
end | ||
|
||
describe command('getenforce') do | ||
its('stdout') { should eq "Enforcing\n" } | ||
its('stderr') { should eq '' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: os-hardening-integration-tests-selinux | ||
version: 1.0.0 | ||
depends: | ||
- name: os-hardening-integration-tests | ||
path: test/integration/default |