Puppet Class: security_baseline
- Defined in:
- manifests/init.pp
Summary
Security baseline enforcement and monitoringOverview
Define a complete security baseline and monitor the rules. The definition of the baseline can be done in Hiera. The purpose of the module is to give the ability to setup complete security baseline which not necessarily have to stick to an industry security guide like the CIS benchmarks. One main purpose is to ensure the module can be extended by further security settings and monitorings without changing the code of this module.
The easiest way to use the module is to put all rule data into a hiera file. For more information please coinsult the README file.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'manifests/init.pp', line 97
class security_baseline (
String $baseline_version,
Hash $rules,
Boolean $debug = false,
Boolean $log_info = false,
String $logfile = '/opt/puppetlabs/facter/facts.d/security_baseline_findings.yaml',
String $summary_report = '/opt/puppetlabs/facter/facts.d/security_baseline_summary.yaml',
Array $auditd_suid_include = [],
Array $auditd_suid_exclude = [],
String $auditd_rules_file = '/etc/audit/rules.d/sec_baseline_auditd.rules',
Enum['fact', 'csv_file'] $reporting_type = 'fact',
Enum['summary', 'details', 'both'] $reports = 'both',
String $auditd_rules_fact_file = '/opt/puppetlabs/facter/facts.d/security_baseline_auditd.yaml',
String $suid_fact_file = '/opt/puppetlabs/facter/facts.d/security_baseline_suid_programs.yaml',
String $sgid_fact_file = '/opt/puppetlabs/facter/facts.d/security_baseline_sgid_programs.yaml',
Boolean $update_postrun_command = true,
String $fact_upload_command = '/usr/share/security_baseline/bin/fact_upload.sh',
Boolean $reboot = false,
Integer $reboot_timeout = 60,
String $ruby_binary = '/opt/puppetlabs/puppet/bin/ruby',
Boolean $dry_run = false,
String $logstash_host = '',
Boolean $configure_logstash = false,
Integer $logstash_port = 5999,
Integer $logstash_timeout = 1000,
Array $exclude_dirs_unowned_files = [],
Array $exclude_dirs_world_writeable = [],
Array $exclude_dirs_sticky_ww = [],
) {
include ::security_baseline::services
include ::security_baseline::system_file_permissions_cron
if($debug) {
echo { "Applying security baseline version: ${baseline_version}":
loglevel => 'debug',
withpath => false,
}
}
if($dry_run) {
echo { 'Running in dry_run mode, no rules will be enforced':
loglevel => 'info',
withpath => false,
}
}
class { '::security_baseline::world_writeable_files_cron':
dirs_to_exclude => $exclude_dirs_world_writeable,
}
class { '::security_baseline::unowned_files_cron':
dirs_to_exclude => $exclude_dirs_unowned_files,
}
class { '::security_baseline::config':
update_postrun_command => $update_postrun_command,
fact_upload_command => $fact_upload_command,
reporting_type => $reporting_type,
logfile => $logfile,
summary => $summary_report,
ruby_binary => $ruby_binary,
}
class {'security_baseline::auditd_suid_rules_cron':
include => $auditd_suid_include,
exclude => $auditd_suid_exclude,
auditd_rules_fact_file => $auditd_rules_fact_file,
suid_fact_file => $suid_fact_file,
sgid_fact_file => $sgid_fact_file,
}
if($configure_logstash) {
class { '::security_baseline::fact_indirector':
configure_logstash => $configure_logstash,
logstash_host => $logstash_host,
logstash_port => $logstash_port,
logstash_timeout => $logstash_timeout
}
}
if ($reports == 'both' or $reports == 'details') {
if ($reporting_type == 'fact') {
concat { $logfile:
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
}
concat::fragment { 'start':
content => epp('security_baseline/logfile_start.epp', {'version' => $baseline_version}),
target => $logfile,
order => 1,
}
} elsif ($reporting_type == 'csv_file') {
concat { $logfile:
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
}
concat::fragment { 'start':
content => epp('security_baseline/csv_file_start.epp', {}),
target => $logfile,
order => 1,
}
}
} elsif ($reports == 'summary') {
file { $logfile:
ensure => absent,
}
}
create_resources('::security_baseline::sec_check', $rules)
$reboot_classes = $rules.filter |$name, $data| {has_key($data, 'reboot') and ($data['reboot'] == true) }
$classes = $reboot_classes.map |$key, $value| {
if(defined(Class[$value['class']])) {
capitalize($value['class'].split('::')).join('::')
}
}
if($reports == 'both' or $reports == 'details') {
if ($reporting_type == 'fact') {
concat::fragment { 'finish':
content => epp('security_baseline/logfile_end.epp', {}),
target => $logfile,
order => 9999,
}
} elsif ($reporting_type == 'csv_file') {
concat::fragment { 'finish':
content => epp('security_baseline/csv_file_end.epp', {}),
target => $logfile,
order => 9999,
}
}
}
if($reboot and $dry_run == false) {
reboot { 'after_run':
timeout => $reboot_timeout,
message => 'forced reboot by Puppet',
subscribe => Class[$classes],
apply => 'finished',
}
}
}
|