Skip to content

Commit 65b25e9

Browse files
committed
comply with latest rubocop rules
Signed-off-by: Christoph Hartmann <[email protected]>
1 parent b2b2aeb commit 65b25e9

File tree

6 files changed

+32
-49
lines changed

6 files changed

+32
-49
lines changed

.rubocop.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
---
22
AllCops:
3+
DisplayCopNames: true
34
Exclude:
45
- vendor/**/*
56
- test/**/*
6-
- metadata.rb
7-
- Berksfile
8-
Documentation:
9-
Enabled: false
10-
AlignParameters:
11-
Enabled: true
12-
Encoding:
13-
Enabled: true
14-
HashSyntax:
15-
Enabled: true
16-
LineLength:
17-
Enabled: false
18-
EmptyLinesAroundBlockBody:
19-
Enabled: false
20-
MethodLength:
21-
Max: 40
22-
NumericLiterals:
23-
MinDigits: 10
7+
Metrics/AbcSize:
8+
Max: 29
249
Metrics/CyclomaticComplexity:
2510
Max: 10
11+
Metrics/LineLength:
12+
Enabled: false
13+
Metrics/MethodLength:
14+
Max: 40
2615
Metrics/PerceivedComplexity:
2716
Max: 10
28-
Metrics/AbcSize:
29-
Max: 29
17+
Style/Documentation:
18+
Enabled: false
3019
Style/DotPosition:
3120
EnforcedStyle: trailing
3221
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

Guardfile

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# encoding: utf-8
22

3-
# Guardfile
4-
53
guard :rubocop do
64
watch(/.+\.rb$/)
75
watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
@@ -17,8 +15,8 @@ end
1715

1816
guard :rspec do
1917
watch(/^spec\/.+_spec\.rb$/)
20-
watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
21-
watch('spec/spec_helper.rb') { 'spec' }
18+
watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
19+
watch('spec/spec_helper.rb') { 'spec' }
2220
end
2321

2422
guard :kitchen, all_on_start: false do

metadata.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name "postgres-hardening"
2-
maintainer "Christoph Hartmann"
3-
maintainer_email "[email protected]"
4-
license "Apache v2.0"
5-
description "Installs and configures a secure posgres server"
1+
# encoding: utf-8
2+
name 'postgres-hardening'
3+
maintainer 'Christoph Hartmann'
4+
maintainer_email '[email protected]'
5+
license 'Apache v2.0'
6+
description 'Installs and configures a secure posgres server'
67
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-
version "1.1.0"
8+
version '1.1.0'
89

910
depends 'postgresql', '>= 3.4.0'
1011

@@ -17,3 +18,6 @@
1718
supports 'fedora'
1819
supports 'debian'
1920
supports 'ubuntu'
21+
22+
source_url 'https://github.com/dev-sec/chef-postgres-hardening'
23+
issues_url 'https://github.com/dev-sec/chef-postgres-hardening/issues'

recipes/hardening.rb

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
# ensure, that you have postgresql::server in your runlist
2222
case node['platform_family']
2323
when 'debian'
24-
2524
['', node['postgresql']['version']].each do |dir|
26-
2725
directory File.join('/var/lib/postgresql/', dir) do
2826
mode '0700'
2927
end
@@ -42,5 +40,4 @@
4240
only_if "ls -l /var/lib/postgresql/#{node['postgresql']['version']}/main/server.key |grep /etc/ssl/private/ssl-cert-snakeoil.key"
4341
notifies change_notify, 'service[postgresql]'
4442
end
45-
4643
end

spec/default_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
require 'spec_helper'
1919

2020
describe 'postgres-hardening::default' do
21-
2221
let(:chef_run) do
2322
ChefSpec::SoloRunner.new do |node|
2423
node.set['postgresql']['version'] = '9.3'
@@ -35,5 +34,4 @@
3534
it 'includes postgres-hardening::hardening recipe' do
3635
expect(chef_run).to include_recipe('postgres-hardening::hardening')
3736
end
38-
3937
end

spec/hardening_spec.rb

-14
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
require 'spec_helper'
1919

2020
describe 'postgres-hardening::hardening' do
21-
2221
context 'with platform_family debian' do
23-
2422
platforms = [
2523
{ os_name: 'ubuntu', os_version: '12.04', postgres_version: '9.3' },
2624
{ os_name: 'ubuntu', os_version: '14.04', postgres_version: '9.3' },
@@ -29,9 +27,7 @@
2927
]
3028

3129
platforms.each do |platform|
32-
3330
context "operating system #{platform[:os_name]} #{platform[:os_version]}" do
34-
3531
let(:chef_run) do
3632
ChefSpec::ServerRunner.new(
3733
platform: platform[:os_name], version: platform[:os_version]
@@ -46,7 +42,6 @@
4642
end
4743

4844
it 'creates necessary directories with correct mode' do
49-
5045
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.crt |grep /etc/ssl/certs/ssl-cert-snakeoil.pem").and_return(true)
5146
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.key |grep /etc/ssl/private/ssl-cert-snakeoil.key").and_return(true)
5247

@@ -55,33 +50,24 @@
5550

5651
expect(chef_run).to create_directory("/var/lib/postgresql/#{@postgres_version}").
5752
with(mode: '0700')
58-
5953
end
6054

6155
it 'deletes links if commands return true' do
62-
6356
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.crt |grep /etc/ssl/certs/ssl-cert-snakeoil.pem").and_return(true)
6457
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.key |grep /etc/ssl/private/ssl-cert-snakeoil.key").and_return(true)
6558

6659
expect(chef_run).to delete_link("/var/lib/postgresql/#{@postgres_version}/main/server.crt")
6760
expect(chef_run).to delete_link("/var/lib/postgresql/#{@postgres_version}/main/server.key")
68-
6961
end
7062

7163
it 'does not delete links if commands return false' do
72-
7364
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.crt |grep /etc/ssl/certs/ssl-cert-snakeoil.pem").and_return(false)
7465
stub_command("ls -l /var/lib/postgresql/#{@postgres_version}/main/server.key |grep /etc/ssl/private/ssl-cert-snakeoil.key").and_return(false)
7566

7667
expect(chef_run).to_not delete_link("/var/lib/postgresql/#{@postgres_version}/main/server.crt")
7768
expect(chef_run).to_not delete_link("/var/lib/postgresql/#{@postgres_version}/main/server.key")
78-
7969
end
80-
8170
end
82-
8371
end
84-
8572
end
86-
8773
end

0 commit comments

Comments
 (0)