mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
improvement: file permission matchers add full description
This commit is contained in:
parent
b942a1a103
commit
9e79b49f43
2 changed files with 64 additions and 0 deletions
63
lib/matchers/matchers.rb
Normal file
63
lib/matchers/matchers.rb
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# Copyright (c) 2015 Vulcano Security GmbH. All rights reserved.
|
||||||
|
RSpec::Matchers.define :be_readable do
|
||||||
|
match do |file|
|
||||||
|
file.readable?(@by_type, @by_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by do |by_type|
|
||||||
|
@by_type = by_type
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by_user do |by_user|
|
||||||
|
@by_user = by_user
|
||||||
|
end
|
||||||
|
|
||||||
|
description do
|
||||||
|
res = "be readable"
|
||||||
|
res += " by #{@by_type}" unless @by_type.nil?
|
||||||
|
res += " by user #{@by_user}" unless @by_user.nil?
|
||||||
|
res
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec::Matchers.define :be_writable do
|
||||||
|
match do |file|
|
||||||
|
file.writable?(@by_type, @by_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by do |by_type|
|
||||||
|
@by_type = by_type
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by_user do |by_user|
|
||||||
|
@by_user = by_user
|
||||||
|
end
|
||||||
|
|
||||||
|
description do
|
||||||
|
res = "be writable"
|
||||||
|
res += " by #{@by_type}" unless @by_type.nil?
|
||||||
|
res += " by user #{@by_user}" unless @by_user.nil?
|
||||||
|
res
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec::Matchers.define :be_executable do
|
||||||
|
match do |file|
|
||||||
|
file.executable?(@by_type, @by_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by do |by_type|
|
||||||
|
@by_type = by_type
|
||||||
|
end
|
||||||
|
|
||||||
|
chain :by_user do |by_user|
|
||||||
|
@by_user = by_user
|
||||||
|
end
|
||||||
|
|
||||||
|
description do
|
||||||
|
res = "be executable"
|
||||||
|
res += " by #{@by_type}" unless @by_type.nil?
|
||||||
|
res += " by user #{@by_user}" unless @by_user.nil?
|
||||||
|
res
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,6 +17,7 @@ require 'resources/processes'
|
||||||
require 'resources/registry_key'
|
require 'resources/registry_key'
|
||||||
require 'resources/security_policy'
|
require 'resources/security_policy'
|
||||||
require 'resources/ssh_conf'
|
require 'resources/ssh_conf'
|
||||||
|
require 'matchers/matchers'
|
||||||
|
|
||||||
require 'vulcano/version'
|
require 'vulcano/version'
|
||||||
require 'vulcano/rule'
|
require 'vulcano/rule'
|
||||||
|
|
Loading…
Reference in a new issue