Skip to content

Commit

Permalink
Update of rubocop to 0.65
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Sidorenko <[email protected]>
  • Loading branch information
artem-sidorenko committed Mar 8, 2019
1 parent 56b3957 commit e46d184
Show file tree
Hide file tree
Showing 37 changed files with 134 additions and 147 deletions.
17 changes: 4 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AllCops:
Exclude:
- vendor/**/*
- test/**/*
TargetRubyVersion: 2.1 # we need this because of chef 12.5.1 support
TargetRubyVersion: 2.5
Metrics/AbcSize:
Max: 29
Metrics/LineLength:
Expand All @@ -17,26 +17,17 @@ Style/Documentation:
Enabled: false
Layout/DotPosition:
EnforcedStyle: trailing
Enabled: true
Style/Encoding:
EnforcedStyle: always
Enabled: true
Layout/ExtraSpacing:
Exclude:
- attributes/default.rb
Style/HashSyntax:
Enabled: true
Style/NumericLiteralPrefix:
Enabled: false
Layout/AlignHash:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
Style/NumericLiterals:
MinDigits: 10
Style/RegexpLiteral:
AllowInnerSlashes: true
Layout/SpaceAroundOperators:
Exclude:
- attributes/default.rb
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
Style/FrozenStringLiteralComment:
Enabled: false
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

source 'https://supermarket.chef.io'

Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

source 'https://rubygems.org'

Expand All @@ -10,7 +10,7 @@ group :test do
gem 'coveralls', require: false
gem 'foodcritic', '~> 15.1'
gem 'rake'
gem 'rubocop', '~> 0.49.0'
gem 'rubocop', '~> 0.65.0'
gem 'simplecov', '~> 0.16'
end

Expand Down
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

# rubocop:disable Style/SymbolArray

Expand Down Expand Up @@ -65,8 +65,8 @@ end

desc 'Run kitchen integration tests'
task :kitchen do
SSH_KEY_FILE = '~/.ssh/ci_id_rsa'.freeze
SSH_KEY_ENV_VAR_NAME = 'CI_SSH_KEY'.freeze
SSH_KEY_FILE = '~/.ssh/ci_id_rsa'
SSH_KEY_ENV_VAR_NAME = 'CI_SSH_KEY'
concurrency = ENV['CONCURRENCY'] || 1
instance = ENV['INSTANCE'] || ''
args = ENV['CI'] ? '--destroy=always' : ''
Expand All @@ -92,3 +92,4 @@ task :kitchen do

sh('sh', '-c', "bundle exec kitchen test -c #{concurrency} #{args} #{instance}")
end
# rubocop:enable Style/SymbolArray
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion attributes/sysctl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion libraries/apt_package_extras.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand Down
6 changes: 2 additions & 4 deletions libraries/cookbook_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand All @@ -24,9 +24,7 @@ class Chef
class Recipe
def cookbook_version(cookbook_name, version_contraint)
cb = run_context.cookbook_collection[cookbook_name]
if cb.nil?
raise "Can't find cookbook #{cookbook_name}! Can't determine its version."
end
raise "Can't find cookbook #{cookbook_name}! Can't determine its version." if cb.nil?

v = cb.metadata.version
Chef::VersionConstraint::Platform.new(version_contraint).include?(v)
Expand Down
3 changes: 2 additions & 1 deletion libraries/gpgcheck.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand Down Expand Up @@ -31,6 +31,7 @@ def self.check(file)
File.open(file) do |f|
f.each_line do |line|
next unless pattern.match(line)

Chef::Log.warn file + ': gpgcheck=1 not properly configured'
end
end
Expand Down
12 changes: 6 additions & 6 deletions libraries/helpers_param.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand All @@ -23,15 +23,15 @@
module SysctlCookbook
module SysctlHelpers
module Param
def coerce_attributes(a, out = nil)
case a
def coerce_attributes(attr, out = nil)
case attr
when Array
"#{out}=#{a.join(' ')}"
"#{out}=#{attr.join(' ')}"
when String, Integer
"#{out}=#{a}"
"#{out}=#{attr}"
when Hash
out += '.' unless out.nil?
a.map { |k, v| coerce_attributes(v, "#{out}#{k}") }.flatten.sort
attr.map { |k, v| coerce_attributes(v, "#{out}#{k}") }.flatten.sort
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion libraries/suid_sgid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name:: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8 # ~FC061
# frozen_string_literal: true

#
# Copyright 2014, Deutsche Telekom AG
Expand Down
2 changes: 1 addition & 1 deletion recipes/apt.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion recipes/auditd.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
6 changes: 2 additions & 4 deletions recipes/limits.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down Expand Up @@ -31,7 +31,5 @@
mode '0440'
owner 'root'
group 'root'
if node['os-hardening']['security']['kernel']['enable_core_dump']
action :delete
end
action :delete if node['os-hardening']['security']['kernel']['enable_core_dump']
end
36 changes: 18 additions & 18 deletions recipes/login_defs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down Expand Up @@ -26,23 +26,23 @@
owner 'root'
group 'root'
variables(
additional_user_paths: node['os-hardening']['env']['extra_user_paths'].join(':'), # :/usr/local/games:/usr/games
umask: node['os-hardening']['env']['umask'],
password_max_age: node['os-hardening']['auth']['pw_max_age'],
password_min_age: node['os-hardening']['auth']['pw_min_age'],
password_warn_age: node['os-hardening']['auth']['pw_warn_age'],
login_retries: node['os-hardening']['auth']['retries'],
login_timeout: node['os-hardening']['auth']['timeout'],
chfn_restrict: '', # "rwh"
additional_user_paths: node['os-hardening']['env']['extra_user_paths'].join(':'), # :/usr/local/games:/usr/games
umask: node['os-hardening']['env']['umask'],
password_max_age: node['os-hardening']['auth']['pw_max_age'],
password_min_age: node['os-hardening']['auth']['pw_min_age'],
password_warn_age: node['os-hardening']['auth']['pw_warn_age'],
login_retries: node['os-hardening']['auth']['retries'],
login_timeout: node['os-hardening']['auth']['timeout'],
chfn_restrict: '', # "rwh"
allow_login_without_home: node['os-hardening']['auth']['allow_homeless'],
uid_min: node['os-hardening']['auth']['uid_min'],
uid_max: node['os-hardening']['auth']['uid_max'],
gid_min: node['os-hardening']['auth']['gid_min'],
gid_max: node['os-hardening']['auth']['gid_max'],
sys_uid_min: node['os-hardening']['auth']['sys_uid_min'],
sys_uid_max: node['os-hardening']['auth']['sys_uid_max'],
sys_gid_min: node['os-hardening']['auth']['sys_gid_min'],
sys_gid_max: node['os-hardening']['auth']['sys_gid_max'],
mail_dir: node['os-hardening']['auth']['maildir']
uid_min: node['os-hardening']['auth']['uid_min'],
uid_max: node['os-hardening']['auth']['uid_max'],
gid_min: node['os-hardening']['auth']['gid_min'],
gid_max: node['os-hardening']['auth']['gid_max'],
sys_uid_min: node['os-hardening']['auth']['sys_uid_min'],
sys_uid_max: node['os-hardening']['auth']['sys_uid_max'],
sys_gid_min: node['os-hardening']['auth']['sys_gid_min'],
sys_gid_max: node['os-hardening']['auth']['sys_gid_max'],
mail_dir: node['os-hardening']['auth']['maildir']
)
end
2 changes: 1 addition & 1 deletion recipes/minimize_access.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
2 changes: 1 addition & 1 deletion recipes/packages.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
12 changes: 6 additions & 6 deletions recipes/pam.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down Expand Up @@ -51,7 +51,7 @@
template passwdqc_path do
source 'pam_passwdqc.erb'
cookbook node['os-hardening']['auth']['pam']['passwdqc']['template_cookbook']
mode 0640
mode '0640'
owner 'root'
group 'root'
end
Expand All @@ -73,14 +73,14 @@
end

# configure tally2
if node['os-hardening']['auth']['retries'] > 0
if node['os-hardening']['auth']['retries'].positive?
# tally2 is needed for pam
package 'libpam-modules'

template tally2_path do
source 'pam_tally2.erb'
cookbook node['os-hardening']['auth']['pam']['tally2']['template_cookbook']
mode 0640
mode '0640'
owner 'root'
group 'root'
end
Expand Down Expand Up @@ -125,15 +125,15 @@
template '/etc/pam.d/system-auth-ac' do
source 'rhel_system_auth.erb'
cookbook node['os-hardening']['auth']['pam']['system-auth']['template_cookbook']
mode 0640
mode '0640'
owner 'root'
group 'root'
end

# NSA 2.3.3.5 Upgrade Password Hashing Algorithm to SHA-512
template '/etc/libuser.conf' do
source 'rhel_libuser.conf.erb'
mode 0640
mode '0640'
owner 'root'
group 'root'
end
Expand Down
8 changes: 3 additions & 5 deletions recipes/profile.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand All @@ -21,10 +21,8 @@

template '/etc/profile.d/pinerolo_profile.sh' do
source 'profile.conf.erb'
mode 0755
mode '0755'
owner 'root'
group 'root'
if node['os-hardening']['security']['kernel']['enable_core_dump']
action :delete
end
action :delete if node['os-hardening']['security']['kernel']['enable_core_dump']
end
2 changes: 1 addition & 1 deletion recipes/securetty.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
4 changes: 2 additions & 2 deletions recipes/selinux.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down Expand Up @@ -40,7 +40,7 @@

template '/etc/selinux/config' do
source 'rhel_selinuxconfig.erb'
mode 0644
mode '0644'
owner 'root'
group 'root'
variables selinux_mode: node['os-hardening']['security']['selinux_mode']
Expand Down
2 changes: 1 addition & 1 deletion recipes/suid_sgid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# frozen_string_literal: true

#
# Cookbook Name: os-hardening
Expand Down
Loading

0 comments on commit e46d184

Please sign in to comment.