fix linting

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-04-09 15:41:36 +05:30
parent cbe7e8c03f
commit c963b2ac14
2 changed files with 9 additions and 7 deletions

View file

@ -20,11 +20,13 @@ module Inspec::Resources
def initialize(selinux_path = "/etc/selinux/config") def initialize(selinux_path = "/etc/selinux/config")
@path = selinux_path @path = selinux_path
cmd = inspec.command("sestatus") cmd = inspec.command("sestatus")
if cmd.exit_status != 0 if cmd.exit_status != 0
return skip_resource "#{cmd.stdout}" return skip_resource "#{cmd.stdout}"
end end
result = cmd.stdout.delete(" ").gsub(/\n/, ",").gsub(/\r/,"").downcase
@data = Hash[result.scan /([^:]+):([^,]+)[,$]/] result = cmd.stdout.delete(" ").gsub(/\n/, ",").gsub(/\r/, "").downcase
@data = Hash[result.scan(/([^:]+):([^,]+)[,$]/)]
return if inspec.os.linux? return if inspec.os.linux?
@ -37,19 +39,19 @@ module Inspec::Resources
end end
def disabled? def disabled?
@data["selinuxstatus"] == 'disabled' unless @data.empty? @data["selinuxstatus"] == "disabled" unless @data.empty?
end end
def enforcing? def enforcing?
@data["currentmode"] == 'enforcing' unless @data.empty? @data["currentmode"] == "enforcing" unless @data.empty?
end end
def permissive? def permissive?
@data["currentmode"] == 'permissive' unless @data.empty? @data["currentmode"] == "permissive" unless @data.empty?
end end
def to_s def to_s
"SELinux" "SELinux"
end end
end end
end end

View file

@ -556,7 +556,7 @@ class MockLoader
# filesystem command # filesystem command
"2e7e0d4546342cee799748ec7e2b1c87ca00afbe590fa422a7c27371eefa88f0" => cmd.call("get-wmiobject-filesystem"), "2e7e0d4546342cee799748ec7e2b1c87ca00afbe590fa422a7c27371eefa88f0" => cmd.call("get-wmiobject-filesystem"),
'sestatus' => cmd.call("sestatus") "sestatus" => cmd.call("sestatus"),
} }
# ports on linux # ports on linux