Skip to content
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
1 change: 1 addition & 0 deletions .kitchen.do.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
driver:
name: digitalocean
size: 512mb
region: nyc3

transport:
ssh_key: '~/.ssh/ci_id_rsa'
Expand Down
12 changes: 9 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AllCops:
Exclude:
- vendor/**/*
- test/**/*
TargetRubyVersion: 2.1 # we need this because of chef 12.5.1 support
Metrics/AbcSize:
Max: 29
Metrics/LineLength:
Expand All @@ -13,13 +14,13 @@ Metrics/MethodLength:
Max: 40
Style/Documentation:
Enabled: false
Style/DotPosition:
Layout/DotPosition:
EnforcedStyle: trailing
Enabled: true
Style/Encoding:
EnforcedStyle: always
Enabled: true
Style/ExtraSpacing:
Layout/ExtraSpacing:
Exclude:
- attributes/default.rb
Style/HashSyntax:
Expand All @@ -30,6 +31,11 @@ Style/NumericLiterals:
MinDigits: 10
Style/RegexpLiteral:
AllowInnerSlashes: true
Style/SpaceAroundOperators:
Layout/SpaceAroundOperators:
Exclude:
- attributes/default.rb
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
Style/FrozenStringLiteralComment:
Enabled: false
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bundler_args: "--without development"
dist: trusty
cache: bundler

rvm: 2.3.3
rvm: 2.4.1

before_install:
- gem update --system # see https://github.com/bundler/bundler/issues/5357
Expand Down
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

source 'https://rubygems.org'

gem 'berkshelf', '~> 5.3'
gem 'chef', '~> 12.5'
gem 'berkshelf', '~> 6.1'
gem 'chef', '~> 12.5' # chefspec builds get stucked with 13.1

group :test do
gem 'chefspec', '~> 5.3.0'
gem 'chefspec', '~> 7.1.0'
gem 'coveralls', require: false
gem 'foodcritic', '~> 6.0'
gem 'foodcritic', '~> 11.1'
gem 'rake'
gem 'rubocop', '~> 0.46.0'
gem 'rubocop', '~> 0.49.0'
gem 'simplecov', '~> 0.10'
end

group :development do
gem 'guard'
gem 'guard-foodcritic', '~>2.1'
gem 'guard-foodcritic', '~> 3.0'
gem 'guard-rspec'
gem 'guard-rubocop'
end
Expand All @@ -29,5 +29,5 @@ group :integration do
end

group :tools do
gem 'github_changelog_generator', '~> 1.12.0'
gem 'github_changelog_generator', '~> 1.14'
end
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env rake
# encoding: utf-8

# rubocop:disable Style/SymbolArray

require 'foodcritic'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Expand Down
3 changes: 2 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Attributes:: default
Expand Down Expand Up @@ -76,7 +77,7 @@
default['os-hardening']['auth']['pam']['passwdqc']['options'] = 'min=disabled,disabled,16,12,8'
default['os-hardening']['auth']['pam']['cracklib']['options'] = 'try_first_pass retry=3 type='
default['os-hardening']['auth']['pam']['pwquality']['options'] = 'try_first_pass retry=3 type='
default['os-hardening']['auth']['root_ttys'] = %w(console tty1 tty2 tty3 tty4 tty5 tty6)
default['os-hardening']['auth']['root_ttys'] = %w[console tty1 tty2 tty3 tty4 tty5 tty6]
default['os-hardening']['auth']['uid_min'] = 1000
default['os-hardening']['auth']['gid_min'] = 1000
default['os-hardening']['auth']['sys_uid_min'] = 100
Expand Down
1 change: 1 addition & 0 deletions attributes/sysctl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Attributes:: sysctl
Expand Down
1 change: 1 addition & 0 deletions libraries/apt_package_extras.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Library:: apt_package_extras
Expand Down
1 change: 1 addition & 0 deletions libraries/cookbook_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Library:: cookbook_version
Expand Down
1 change: 1 addition & 0 deletions libraries/gpgcheck.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Library:: gpgcheck
Expand Down
5 changes: 3 additions & 2 deletions libraries/suid_sgid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name:: os-hardening
# Library:: suid_sgid
Expand Down Expand Up @@ -54,10 +55,10 @@ def self.remove_suid_sgid_from_blacklist(blacklist)
end

def self.remove_suid_sgid_from_unknown(whitelist = [], root = '/', dry_run = false)
all_suid_sgid_files = find_all_suid_sgid_files(root).select do |file|
all_suid_sgid_files = find_all_suid_sgid_files(root).reject do |file|
in_whitelist = whitelist.include?(file)
Chef::Log.info "suid_sgid: Whitelisted file '#{file}', not altering SUID/SGID bit" if in_whitelist && !dry_run
!in_whitelist
in_whitelist
end

all_suid_sgid_files.each do |file|
Expand Down
5 changes: 4 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8 # ~FC061

#
# Copyright 2014, Deutsche Telekom AG
#
Expand All @@ -18,11 +19,13 @@
name 'os-hardening'
maintainer 'Dominik Richter'
maintainer_email '[email protected]'
license 'Apache 2.0'
license 'Apache-2.0'
description 'Installs and configures operating system hardening'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.0.1'

chef_version '>= 12.5' if respond_to?(:chef_version)

supports 'ubuntu', '>= 12.04'
supports 'debian', '>= 6.0'
supports 'centos', '>= 5.0'
Expand Down
1 change: 1 addition & 0 deletions recipes/apt.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: apt.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/auditd.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: auditd.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: default
Expand Down
1 change: 1 addition & 0 deletions recipes/limits.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: limits.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/login_defs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: login_defs.rb
Expand Down
3 changes: 2 additions & 1 deletion recipes/minimize_access.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: minimize_access
Expand All @@ -20,7 +21,7 @@

# remove write permissions from path folders ($PATH) for all regular users
# this prevents changing any system-wide command from normal users
paths = %w(/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin) + node['os-hardening']['env']['extra_user_paths']
paths = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin] + node['os-hardening']['env']['extra_user_paths']
paths.each do |folder|
execute "remove write permission from #{folder}" do
command "chmod go-w -R #{folder}"
Expand Down
1 change: 1 addition & 0 deletions recipes/packages.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: packages.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/pam.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: pam.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/profile.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: profile.rb
Expand Down
1 change: 1 addition & 0 deletions recipes/securetty.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: securetty
Expand Down
1 change: 1 addition & 0 deletions recipes/suid_sgid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: suid_sgid
Expand Down
1 change: 1 addition & 0 deletions recipes/sysctl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: sysctl
Expand Down
3 changes: 2 additions & 1 deletion recipes/yum.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Cookbook Name: os-hardening
# Recipe: pack_yum.rb
Expand Down Expand Up @@ -42,7 +43,7 @@
if node['os-hardening']['security']['packages']['clean']

# remove unused repos
%w(CentOS-Debuginfo CentOS-Media CentOS-Vault).each do |repo|
%w[CentOS-Debuginfo CentOS-Media CentOS-Vault].each do |repo|
yum_repository repo do
action :remove
end
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/auditd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2017, Artem Sidorenko
#
Expand Down
5 changes: 3 additions & 2 deletions spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down Expand Up @@ -26,9 +27,9 @@
node.normal['cpu']['0']['vendor_id'] = 'GenuineIntel'
node.normal['env']['extra_user_paths'] = []

paths = %w(
paths = %w[
/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin
) + node['env']['extra_user_paths']
] + node['env']['extra_user_paths']
paths.each do |folder|
stub_command(
"find #{folder} -perm -go+w -type f | wc -l | egrep '^0$'"
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/limits_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/login_defs_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/minimize_access_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/pam_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/profile_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/securetty_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/suid_sgid_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/recipes/sysctl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: UTF-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# Copyright 2014, Deutsche Telekom AG
#
Expand Down