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")
@path = selinux_path
cmd = inspec.command("sestatus")
if cmd.exit_status != 0
return skip_resource "#{cmd.stdout}"
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?
@ -37,19 +39,19 @@ module Inspec::Resources
end
def disabled?
@data["selinuxstatus"] == 'disabled' unless @data.empty?
@data["selinuxstatus"] == "disabled" unless @data.empty?
end
def enforcing?
@data["currentmode"] == 'enforcing' unless @data.empty?
@data["currentmode"] == "enforcing" unless @data.empty?
end
def permissive?
@data["currentmode"] == 'permissive' unless @data.empty?
@data["currentmode"] == "permissive" unless @data.empty?
end
def to_s
"SELinux"
end
end
end
end

View file

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