Skip to content

Commit d204ea3

Browse files
authored
Merge pull request #124 from shortdudey123/update_test
Update Rubocop, Foodcritic, and Chefspec coverage
2 parents 043d048 + 1103e08 commit d204ea3

15 files changed

+218
-148
lines changed

.gitignore

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
README.pdf
2-
README.html
3-
shared_test_repo/
4-
test/integration
5-
.kitchen
1+
*~
2+
*#
3+
.#*
4+
\#*#
5+
.*.sw[a-z]
6+
*.un~
67
coverage
8+
exp.*
9+
pkg/
10+
shared_test_repo/
711

8-
Gemfile.lock
12+
# Berkshelf
13+
.vagrant
14+
/cookbooks
915
Berksfile.lock
16+
17+
# Bundler
18+
Gemfile.lock
19+
bin/*
20+
.bundle/*
21+
22+
# Test Kitchen
23+
.kitchen/
24+
.kitchen.local.yml

.rubocop.yml

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
---
22
AllCops:
3+
DisplayCopNames: true
34
Exclude:
45
- vendor/**/*
56
- test/**/*
6-
- metadata.rb
7-
- Berksfile
8-
- Guardfile
9-
Documentation:
10-
Enabled: false
11-
AlignParameters:
12-
Enabled: true
13-
Encoding:
14-
Enabled: true
15-
HashSyntax:
16-
Enabled: true
17-
LineLength:
18-
Enabled: false
19-
EmptyLinesAroundBlockBody:
20-
Enabled: false
21-
MethodLength:
22-
Max: 40
23-
NumericLiterals:
24-
MinDigits: 10
7+
Metrics/AbcSize:
8+
Max: 29
259
Metrics/CyclomaticComplexity:
2610
Max: 10
11+
Metrics/LineLength:
12+
Enabled: false
13+
Metrics/MethodLength:
14+
Max: 40
2715
Metrics/PerceivedComplexity:
2816
Max: 10
29-
Metrics/AbcSize:
30-
Max: 29
17+
Style/Documentation:
18+
Enabled: false
3119
Style/DotPosition:
3220
EnforcedStyle: trailing
3321
Enabled: true
22+
Style/Encoding:
23+
EnforcedStyle: always
24+
Enabled: true
25+
Style/ExtraSpacing:
26+
Exclude:
27+
- attributes/default.rb
28+
Style/RegexpLiteral:
29+
AllowInnerSlashes: true
30+
Style/SpaceAroundOperators:
31+
Exclude:
32+
- attributes/default.rb

Berksfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
source "https://supermarket.getchef.com"
1+
# encoding: utf-8
2+
3+
source 'https://supermarket.chef.io'
24

35
metadata
46

5-
cookbook "chef-solo-search", :git => "https://github.com/edelight/chef-solo-search"
6-
cookbook "apt"
7-
cookbook "yum"
7+
cookbook 'chef-solo-search', git: 'https://github.com/edelight/chef-solo-search'
8+
cookbook 'apt'
9+
cookbook 'yum'

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ end
1414
group :test do
1515
gem 'rake'
1616
gem 'chefspec', '~> 4.2.0'
17-
gem 'foodcritic', '~> 4.0'
17+
gem 'foodcritic', '~> 6.3'
1818
gem 'thor-foodcritic'
19-
gem 'rubocop', '~> 0.31.0'
19+
gem 'rubocop', '~> 0.43.0'
2020
gem 'coveralls', require: false
2121
gem 'minitest', '~> 5.5'
2222
gem 'simplecov', '~> 0.10'
@@ -25,7 +25,7 @@ end
2525
group :development do
2626
gem 'guard'
2727
gem 'guard-rspec'
28-
gem 'guard-kitchen'
28+
# gem 'guard-kitchen' # guard-kitchen is not compatable with Guard 2.x
2929
gem 'guard-rubocop'
3030
gem 'guard-foodcritic'
3131
end

Guardfile

+12-11
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ end
1717

1818
guard :rspec do
1919
watch(/^spec\/.+_spec\.rb$/)
20-
watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
21-
watch('spec/spec_helper.rb') { 'spec' }
20+
watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
21+
watch('spec/spec_helper.rb') { 'spec' }
2222
end
2323

24-
guard :kitchen, all_on_start: false do
25-
watch(/test\/.+/)
26-
watch(/^recipes\/(.+)\.rb$/)
27-
watch(/^attributes\/(.+)\.rb$/)
28-
watch(/^files\/(.+)/)
29-
watch(/^templates\/(.+)/)
30-
watch(/^providers\/(.+)\.rb/)
31-
watch(/^resources\/(.+)\.rb/)
32-
end
24+
# guard-kitchen is not compatable with Guard 2.x
25+
# guard :kitchen, all_on_start: false do
26+
# watch(/test\/.+/)
27+
# watch(/^recipes\/(.+)\.rb$/)
28+
# watch(/^attributes\/(.+)\.rb$/)
29+
# watch(/^files\/(.+)/)
30+
# watch(/^templates\/(.+)/)
31+
# watch(/^providers\/(.+)\.rb/)
32+
# watch(/^resources\/(.+)\.rb/)
33+
# end

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ begin
5656

5757
# build changelog
5858
require 'github_changelog_generator/task'
59-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
59+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
6060
config.future_release = "v#{metadata.version}"
6161
end
6262
rescue LoadError

gemfile.chef-11

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ group :test do
1515
gem 'chefspec', '~> 4.1.1'
1616
gem 'foodcritic', '~> 3.0'
1717
gem 'thor-foodcritic'
18-
gem 'rubocop', '~> 0.28.0'
18+
gem 'rubocop', '~> 0.43.0'
1919
gem 'coveralls', require: false
2020
end
2121

libraries/get_ssh_ciphers.rb

+10-11
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,33 @@
2323
class Chef
2424
class Recipe
2525
class SshCipher
26-
# rubocop:disable AbcSize
2726
def self.get_ciphers(node, cbc_required)
2827
weak_ciphers = cbc_required ? 'weak' : 'default'
2928

3029
# define cipher set
31-
ciphers_53 = {}
32-
ciphers_53.default = 'aes256-ctr,aes192-ctr,aes128-ctr'
33-
ciphers_53['weak'] = ciphers_53['default'] + ',aes256-cbc,aes192-cbc,aes128-cbc'
30+
ciphers53 = {}
31+
ciphers53.default = 'aes256-ctr,aes192-ctr,aes128-ctr'
32+
ciphers53['weak'] = ciphers53['default'] + ',aes256-cbc,aes192-cbc,aes128-cbc'
3433

35-
ciphers_66 = {}
36-
ciphers_66.default = '[email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr'
37-
ciphers_66['weak'] = ciphers_66['default'] + ',aes256-cbc,aes192-cbc,aes128-cbc'
34+
ciphers66 = {}
35+
ciphers66.default = '[email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr'
36+
ciphers66['weak'] = ciphers66['default'] + ',aes256-cbc,aes192-cbc,aes128-cbc'
3837

3938
# determine the cipher for the operating system
40-
cipher = ciphers_53
39+
cipher = ciphers53
4140

4241
# use newer ciphers on ubuntu
4342
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 14.04
4443
Chef::Log.info('Detected Ubuntu 14.04 or newer, use new ciphers')
45-
cipher = ciphers_66
44+
cipher = ciphers66
4645

4746
elsif node['platform'] == 'debian' && node['platform_version'].to_f >= 8
4847
Chef::Log.info('Detected Debian 8 or newer, use new ciphers')
49-
cipher = ciphers_66
48+
cipher = ciphers66
5049

5150
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
5251
Chef::Log.info('Detected RedHat Family with version 7 or newer, use new ciphers')
53-
cipher = ciphers_66
52+
cipher = ciphers66
5453
end
5554

5655
Chef::Log.info("Choose cipher: #{cipher[weak_ciphers]}")

libraries/get_ssh_kex.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@ class SshKex
2727
def self.get_kexs(node, weak_kex) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
2828
weak_kex = weak_kex ? 'weak' : 'default'
2929

30-
kex_59 = {}
31-
kex_59.default = 'diffie-hellman-group-exchange-sha256'
32-
kex_59['weak'] = kex_59['default'] + ',diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1'
30+
kex59 = {}
31+
kex59.default = 'diffie-hellman-group-exchange-sha256'
32+
kex59['weak'] = kex59['default'] + ',diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1'
3333

34-
kex_66 = {}
35-
kex_66.default = '[email protected],diffie-hellman-group-exchange-sha256'
36-
kex_66['weak'] = kex_66['default'] + ',diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1'
34+
kex66 = {}
35+
kex66.default = '[email protected],diffie-hellman-group-exchange-sha256'
36+
kex66['weak'] = kex66['default'] + ',diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1'
3737

3838
# determine the kex for the operating system
39-
kex = kex_59
39+
kex = kex59
4040

4141
# use newer kex on ubuntu 14.04
4242
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 14.04
4343
Chef::Log.info('Detected Ubuntu 14.04 or newer, use new key exchange algorithms')
44-
kex = kex_66
44+
kex = kex66
4545

4646
elsif node['platform'] == 'debian' && node['platform_version'].to_f >= 8
4747
Chef::Log.info('Detected Debian 8 or newer, use new key exchange algorithms')
48-
kex = kex_66
48+
kex = kex66
4949

5050
# use newer kex for redhat version 7 or newer
5151
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
5252
Chef::Log.info('Detected Redhat 7 or newer, use new key exchange algorithms')
53-
kex = kex_66
53+
kex = kex66
5454

5555
# deactivate kex on redhat version 6
5656
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f < 7

libraries/get_ssh_macs.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,43 @@ class SshMac
2727
def self.get_macs(node, weak_hmac) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
2828
weak_macs = weak_hmac ? 'weak' : 'default'
2929

30-
macs_53 = {}
31-
macs_53.default = 'hmac-ripemd160,hmac-sha1'
30+
macs53 = {}
31+
macs53.default = 'hmac-ripemd160,hmac-sha1'
3232

33-
macs_59 = {}
34-
macs_59.default = 'hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
35-
macs_59['weak'] = macs_59['default'] + ',hmac-sha1'
33+
macs59 = {}
34+
macs59.default = 'hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
35+
macs59['weak'] = macs59['default'] + ',hmac-sha1'
3636

37-
macs_66 = {}
38-
macs_66.default = '[email protected],[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
39-
macs_66['weak'] = macs_66['default'] + ',hmac-sha1'
37+
macs66 = {}
38+
macs66.default = '[email protected],[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
39+
macs66['weak'] = macs66['default'] + ',hmac-sha1'
4040

4141
# determine the mac for the operating system
42-
macs = macs_59
42+
macs = macs59
4343

4444
# use newer macs on ubuntu 14.04
4545
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 14.04
4646
Chef::Log.info('Detected Ubuntu 14.04 or newer, use new macs')
47-
macs = macs_66
47+
macs = macs66
4848

4949
elsif node['platform'] == 'debian' && node['platform_version'].to_f >= 8
5050
Chef::Log.info('Detected Debian 8 or newer, use new macs')
51-
macs = macs_66
51+
macs = macs66
5252

5353
# use newer macs for rhel >= 7
5454
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 7
5555
Chef::Log.info('Detected RedHat Family with version 7 or newer, use new macs')
56-
macs = macs_66
56+
macs = macs66
5757

5858
# stick to 53 for rhel <= 6
5959
elsif node['platform_family'] == 'rhel' && node['platform_version'].to_f < 7
6060
Chef::Log.info('Detected RedHat Family, use old macs')
61-
macs = macs_53
61+
macs = macs53
6262

6363
# use older mac for debian <= 6
6464
elsif node['platform'] == 'debian' && node['platform_version'].to_f <= 6
6565
Chef::Log.info('Detected Debian 6 or earlier, use old macs')
66-
macs = macs_53
66+
macs = macs53
6767
end
6868

6969
Chef::Log.info("Choose macs: #{macs[weak_macs]}")

metadata.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
# limitations under the License.
1616
#
1717

18-
name "ssh-hardening"
19-
maintainer "Dominik Richter"
20-
maintainer_email "[email protected]"
21-
license "Apache 2.0"
22-
description "This cookbook installs and provides secure ssh and sshd configurations."
18+
name 'ssh-hardening'
19+
maintainer 'Dominik Richter'
20+
maintainer_email '[email protected]'
21+
license 'Apache 2.0'
22+
description 'This cookbook installs and provides secure ssh and sshd configurations.'
2323
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
24-
version "1.2.1"
24+
version '1.2.1'
2525

2626
recipe 'ssh-hardening::default', 'installs and configures ssh client and server'
2727
recipe 'ssh-hardening::client', 'install and apply security hardening for ssh client'
2828
recipe 'ssh-hardening::server', 'install and apply security hardening for ssh server'
29+
30+
source_url 'https://github.com/dev-sec/chef-ssh-hardening'
31+
issues_url 'https://github.com/dev-sec/chef-ssh-hardening/issues'

0 commit comments

Comments
 (0)