Skip to content

Commit 21e5e95

Browse files
committed
Merge pull request #91 from hardening-io/update-common
update common Gemfile for chef11+12
2 parents b531acf + 86b9ff5 commit 21e5e95

File tree

6 files changed

+231
-227
lines changed

6 files changed

+231
-227
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
rvm:
23
- 1.9.3
34
- 2.0.0
@@ -12,5 +13,5 @@ notifications:
1213
secure: bOxdT8KjXuWpBaNvMsf1zGcBRS5Ua3ESYcBWUEXXKE+f+AatmATCdynHq1QJBzE6NtWcGvxlacF4oA3FMmMhJZW9PF3igmYK2TC/aF8TXQ+nE8uzibkj+BphI6/so6TnXCPxoCp6TQ8gZm9cWyj1M4gnFJiZx9eYMVKCIOSRU/0=
1314
matrix:
1415
exclude:
15-
- rvm: 1.9.3
16-
gemfile: Gemfile
16+
- rvm: 1.9.3
17+
gemfile: Gemfile

libraries/get_ssh_ciphers.rb

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class Chef
2424
class Recipe
2525
class SshCipher
26+
# rubocop:disable AbcSize
2627
def self.get_ciphers(node, cbc_required)
2728
weak_ciphers = cbc_required ? 'weak' : 'default'
2829

libraries/get_ssh_kex.rb

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class Chef
2424
class Recipe
2525
class SshKex
26+
# rubocop:disable AbcSize
2627
def self.get_kexs(node, weak_kex)
2728
weak_kex = weak_kex ? 'weak' : 'default'
2829

libraries/get_ssh_macs.rb

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class Chef
2424
class Recipe
2525
class SshMac
26+
# rubocop:disable AbcSize
2627
def self.get_macs(node, weak_hmac)
2728
weak_macs = weak_hmac ? 'weak' : 'default'
2829

spec/recipes/client_spec.rb

+94-94
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,43 @@
2929
end
3030

3131
it 'creates the directory /etc/ssh' do
32-
expect(chef_run).to create_directory('/etc/ssh')
33-
.with(mode: '0755')
34-
.with(owner: 'root')
35-
.with(group: 'root')
32+
expect(chef_run).to create_directory('/etc/ssh').
33+
with(mode: '0755').
34+
with(owner: 'root').
35+
with(group: 'root')
3636
end
3737

3838
it 'creates /etc/ssh/ssh_config' do
39-
expect(chef_run).to create_template('/etc/ssh/ssh_config')
40-
.with(owner: 'root')
41-
.with(group: 'root')
42-
.with(mode: '0644')
39+
expect(chef_run).to create_template('/etc/ssh/ssh_config').
40+
with(owner: 'root').
41+
with(group: 'root').
42+
with(mode: '0644')
4343
end
4444

4545
it 'disables weak hmacs' do
46-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
47-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
46+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
47+
with_content(/MACs [^#]*\bhmac-sha1\b/)
4848
end
4949

5050
it 'disables weak kexs' do
51-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
52-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
53-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
54-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
55-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
56-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
51+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
52+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
53+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
54+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
55+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
56+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
5757
end
5858

5959
it 'disables cbc ciphers' do
60-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
61-
.with_content(/Ciphers [^#]*-cbc\b/)
60+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
61+
with_content(/Ciphers [^#]*-cbc\b/)
6262
end
6363

6464
it 'enables ctr ciphers' do
65-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
66-
.with_content(/Ciphers [^#]*\baes128-ctr\b/)
67-
.with_content(/Ciphers [^#]*\baes192-ctr\b/)
68-
.with_content(/Ciphers [^#]*\baes256-ctr\b/)
65+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
66+
with_content(/Ciphers [^#]*\baes128-ctr\b/).
67+
with_content(/Ciphers [^#]*\baes192-ctr\b/).
68+
with_content(/Ciphers [^#]*\baes256-ctr\b/)
6969
end
7070

7171
context 'weak_hmac enabled only for the client' do
@@ -76,8 +76,8 @@
7676
end
7777

7878
it 'allows weak hmacs for the client' do
79-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
80-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
79+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
80+
with_content(/MACs [^#]*\bhmac-sha1\b/)
8181
end
8282

8383
it 'does not warn about depreciation' do
@@ -93,8 +93,8 @@
9393
end
9494

9595
it 'does not enable weak hmacs on the client' do
96-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
97-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
96+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
97+
with_content(/MACs [^#]*\bhmac-sha1\b/)
9898
end
9999
end
100100

@@ -106,12 +106,12 @@
106106
end
107107

108108
it 'allows weak kexs on the client' do
109-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
110-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
111-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
112-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
113-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
114-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
109+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
110+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
111+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
112+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
113+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
114+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
115115
end
116116

117117
it 'does not warn about depreciation' do
@@ -127,12 +127,12 @@
127127
end
128128

129129
it 'does not allow weak kexs on the client' do
130-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
131-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
132-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
133-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
134-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
135-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
130+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
131+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
132+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
133+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
134+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
135+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
136136
end
137137
end
138138

@@ -144,10 +144,10 @@
144144
end
145145

146146
it 'allows cbc ciphers on the client' do
147-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
148-
.with_content(/Ciphers [^#]*\baes256-cbc\b/)
149-
.with_content(/Ciphers [^#]*\baes192-cbc\b/)
150-
.with_content(/Ciphers [^#]*\baes128-cbc\b/)
147+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
148+
with_content(/Ciphers [^#]*\baes256-cbc\b/).
149+
with_content(/Ciphers [^#]*\baes192-cbc\b/).
150+
with_content(/Ciphers [^#]*\baes128-cbc\b/)
151151
end
152152

153153
it 'does not warn about depreciation' do
@@ -163,8 +163,8 @@
163163
end
164164

165165
it 'does not allow cbc ciphers on the client' do
166-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
167-
.with_content(/Ciphers [^#]*\b.*-cbc\b/)
166+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
167+
with_content(/Ciphers [^#]*\b.*-cbc\b/)
168168
end
169169
end
170170

@@ -177,28 +177,28 @@
177177
end
178178

179179
it 'allows weak hmacs' do
180-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
181-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
180+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
181+
with_content(/MACs [^#]*\bhmac-sha1\b/)
182182
end
183183

184184
it 'still does not allow weak kexs' do
185-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
186-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
187-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
188-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
189-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
190-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
185+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
186+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
187+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
188+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
189+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
190+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
191191
end
192192

193193
it 'still doss not allow cbc ciphers' do
194-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
195-
.with_content(/Ciphers [^#]*-cbc\b/)
194+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
195+
with_content(/Ciphers [^#]*-cbc\b/)
196196
end
197197

198198
it 'warns about depreciation' do
199-
expect(chef_run).to write_log('deprecated-ssh/weak_hmac_client')
200-
.with(message: /deprecated/)
201-
.with(level: :warn)
199+
expect(chef_run).to write_log('deprecated-ssh/weak_hmac_client').
200+
with(message: /deprecated/).
201+
with(level: :warn)
202202
end
203203
end
204204

@@ -210,28 +210,28 @@
210210
end
211211

212212
it 'allows weak kexs on the client' do
213-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
214-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
215-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
216-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
217-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
218-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
213+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
214+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
215+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
216+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
217+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
218+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
219219
end
220220

221221
it 'still does not allow weak macs' do
222-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
223-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
222+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
223+
with_content(/MACs [^#]*\bhmac-sha1\b/)
224224
end
225225

226226
it 'still does not allow cbc ciphers' do
227-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
228-
.with_content(/Ciphers [^#]*-cbc\b/)
227+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
228+
with_content(/Ciphers [^#]*-cbc\b/)
229229
end
230230

231231
it 'warns about depreciation' do
232-
expect(chef_run).to write_log('deprecated-ssh/weak_kex_client')
233-
.with(message: /deprecated/)
234-
.with(level: :warn)
232+
expect(chef_run).to write_log('deprecated-ssh/weak_kex_client').
233+
with(message: /deprecated/).
234+
with(level: :warn)
235235
end
236236
end
237237

@@ -243,37 +243,37 @@
243243
end
244244

245245
it 'allows cbc ciphers for the client' do
246-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
247-
.with_content(/Ciphers [^#]*\baes256-cbc\b/)
248-
.with_content(/Ciphers [^#]*\baes192-cbc\b/)
249-
.with_content(/Ciphers [^#]*\baes128-cbc\b/)
246+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
247+
with_content(/Ciphers [^#]*\baes256-cbc\b/).
248+
with_content(/Ciphers [^#]*\baes192-cbc\b/).
249+
with_content(/Ciphers [^#]*\baes128-cbc\b/)
250250
end
251251

252252
it 'still does not allow weak macs' do
253-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
254-
.with_content(/MACs [^#]*\bhmac-sha1\b/)
253+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
254+
with_content(/MACs [^#]*\bhmac-sha1\b/)
255255
end
256256

257257
it 'still does not allow weak kexs' do
258-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
259-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
260-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
261-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
262-
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
263-
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
258+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
259+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
260+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
261+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
262+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config').
263+
with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
264264
end
265265

266266
it 'still enables ctr ciphers' do
267-
expect(chef_run).to render_file('/etc/ssh/ssh_config')
268-
.with_content(/Ciphers [^#]*\baes128-ctr\b/)
269-
.with_content(/Ciphers [^#]*\baes192-ctr\b/)
270-
.with_content(/Ciphers [^#]*\baes256-ctr\b/)
267+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
268+
with_content(/Ciphers [^#]*\baes128-ctr\b/).
269+
with_content(/Ciphers [^#]*\baes192-ctr\b/).
270+
with_content(/Ciphers [^#]*\baes256-ctr\b/)
271271
end
272272

273273
it 'warns about depreciation' do
274-
expect(chef_run).to write_log('deprecated-ssh/cbc_required_client')
275-
.with(message: /deprecated/)
276-
.with(level: :warn)
274+
expect(chef_run).to write_log('deprecated-ssh/cbc_required_client').
275+
with(message: /deprecated/).
276+
with(level: :warn)
277277
end
278278
end
279279
end
@@ -291,9 +291,9 @@
291291
end
292292

293293
it "warns about ignoring the global #{attr} value for the client" do
294-
expect(chef_run).to write_log("ignored-ssh/#{attr}_client")
295-
.with(message: "Ignoring ssh/#{attr}:true for client")
296-
.with_level(:warn)
294+
expect(chef_run).to write_log("ignored-ssh/#{attr}_client").
295+
with(message: "Ignoring ssh/#{attr}:true for client").
296+
with_level(:warn)
297297
end
298298
end
299299

@@ -308,8 +308,8 @@
308308
end
309309

310310
it "does not warn about ignoring the global #{attr}" do
311-
expect(chef_run).not_to write_log("ignored-ssh/#{attr}_client")
312-
.with_level(:warn)
311+
expect(chef_run).not_to write_log("ignored-ssh/#{attr}_client").
312+
with_level(:warn)
313313
end
314314
end
315315
end

0 commit comments

Comments
 (0)