Skip to content

Commit 4dddfaa

Browse files
authored
update code to conform to new linting rules (#145)
* update code to conform to new linting rules Signed-off-by: Martin Schurz <[email protected]> * disable unneeded linting rule Signed-off-by: Martin Schurz <[email protected]>
1 parent 80e931f commit 4dddfaa

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ Metrics/PerceivedComplexity:
2626
Max: 10
2727
Metrics/AbcSize:
2828
Max: 30
29+
# Lint/AmbiguousBlockAssociation is incompatible with RSpec
30+
# https://github.com/rubocop-hq/rubocop/issues/4222
31+
Lint/AmbiguousBlockAssociation:
32+
Enabled: false

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rake/testtask'
24
require 'rubocop/rake_task'
35

controls/os_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Copyright 2015, Patrick Muench
35
#
@@ -26,10 +28,10 @@
2628
shadow_group = 'root'
2729
shadow_group = 'shadow' if os.debian? || os.suse? || os.name == 'alpine'
2830
container_execution = begin
29-
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
30-
rescue NoMethodError
31-
false
32-
end
31+
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
32+
rescue NoMethodError
33+
false
34+
end
3335

3436
blacklist = attribute(
3537
'blacklist',
@@ -250,7 +252,7 @@
250252
it { should be_directory }
251253
end
252254

253-
loaded_files = command('find ' + cpuvulndir + ' -type f -maxdepth 1').stdout.split(/\n/).map(&:strip).find_all { |vulnfiles| !vulnfiles.empty? }
255+
loaded_files = command("find #{cpuvulndir} -type f -maxdepth 1").stdout.split(/\n/).map(&:strip).find_all { |vulnfiles| !vulnfiles.empty? }
254256

255257
loaded_files.each do |vulnfile|
256258
describe file(vulnfile) do

controls/package_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Copyright 2015, Patrick Muench
35
#
@@ -19,10 +21,10 @@
1921

2022
val_syslog_pkg = attribute('syslog_pkg', value: 'rsyslog', description: 'syslog package to ensure present (default: rsyslog, alternative: syslog-ng...')
2123
container_execution = begin
22-
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
23-
rescue NoMethodError
24-
false
25-
end
24+
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
25+
rescue NoMethodError
26+
false
27+
end
2628

2729
control 'package-01' do
2830
impact 1.0

controls/sysctl_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Copyright 2015, Patrick Muench
35
#
@@ -20,10 +22,10 @@
2022
sysctl_forwarding = attribute('sysctl_forwarding', value: false, description: 'Is network forwarding needed?')
2123
kernel_modules_disabled = attribute('kernel_modules_disabled', value: 0, description: 'Should loading of kernel modules be disabled?')
2224
container_execution = begin
23-
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
24-
rescue NoMethodError
25-
false
26-
end
25+
virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/
26+
rescue NoMethodError
27+
false
28+
end
2729

2830
control 'sysctl-01' do
2931
impact 1.0

libraries/suid_blacklist.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# author: Christoph Hartmann
24

35
class SUIDBlacklist < Inspec.resource(1)

libraries/suid_check.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# author: Christoph Hartmann
24

35
class SUIDCheck < Inspec.resource(1)
@@ -10,6 +12,7 @@ class SUIDCheck < Inspec.resource(1)
1012
"
1113

1214
def initialize(blacklist = nil)
15+
super
1316
blacklist = default if blacklist.nil?
1417
@blacklist = blacklist
1518
end

0 commit comments

Comments
 (0)