mirror of
https://github.com/inspec/inspec
synced 2025-02-18 15:08:44 +00:00
Addressing review items.
Signed-off-by: Aaron Lippold <lippold@gmail.com>
This commit is contained in:
parent
9a8ed4d3e5
commit
179c48fd21
2 changed files with 7 additions and 7 deletions
|
@ -119,7 +119,7 @@ not
|
|||
|
||||
Without the zero prefix for the octal value, InSpec will interpret it as the _decimal_ value 644, which is octal 1024 or `-----w-r-T`, and any test for a file that is `-rw-r--r--` will fail.
|
||||
|
||||
#### Note: If you want to validate that a file has an upper or lower bound in `mode` see the [`more_permissive_than?`(mode)](#more_permissive_than?(mode)) matcher below.
|
||||
Note: see the [`be_more_permissive_than(mode)`](#be_more_permissive_than?(mode)) matcher for upper and lower bounds on file mode.
|
||||
|
||||
### mtime
|
||||
|
||||
|
@ -544,13 +544,13 @@ The `have_mode` matcher tests if a file has a mode assigned to it:
|
|||
|
||||
it { should have_mode }
|
||||
|
||||
### `more_permissive_than?(mode)`
|
||||
### `be_more_permissive_than(mode)`
|
||||
|
||||
`more_permissive_than?(mode)` takes the maximum desired mode - in `octal format`
|
||||
`be_more_permissive_than(mode)` takes the maximum desired mode - in `octal format`
|
||||
('0644' or '0777') - of your file as a `String` and returns a `Boolean`. It will
|
||||
return `true` if your file has a mode with greater permissions than specified.
|
||||
|
||||
describe file('/etc/passwd') do
|
||||
it { should_not be_more_permissive_than?('0644') }
|
||||
it { should be_more_permissive_than?('0000') }
|
||||
it { should_not be_more_permissive_than('0644') }
|
||||
it { should be_more_permissive_than('0000') }
|
||||
end
|
||||
|
|
|
@ -135,7 +135,7 @@ module Inspec::Resources
|
|||
|
||||
def more_permissive_than?(max_mode = nil)
|
||||
raise Inspec::Exceptions::ResourceFailed, 'The file' + file.path + 'doesn\'t seem to exist' unless exist?
|
||||
raise ArgumentError, 'You must provide a value for the `maximum permission target` for the file.' if max_mode.nil?
|
||||
raise ArgumentError, 'You must proivde a value for the `maximum allowable permission` for the file.' if max_mode.nil?
|
||||
raise ArgumentError, 'You must proivde the `maximum permission target` as a `String`, you provided: ' + max_mode.class.to_s unless max_mode.is_a?(String)
|
||||
raise ArgumentError, 'The value of the `maximum permission target` should be a valid file mode in 4-ditgit octal format: for example, `0644` or `0777`' unless /(0)?([0-7])([0-7])([0-7])/.match?(max_mode)
|
||||
|
||||
|
@ -152,7 +152,7 @@ module Inspec::Resources
|
|||
# mode. This will determine if any of the bits that would indicate a more
|
||||
# permissive mode are set in the actual mode.
|
||||
#
|
||||
# 3. If the result is 0000. If the result is 0000, the files mode is equal
|
||||
# 3. If the result is 0000, the files mode is equal
|
||||
# to or less permissive than the desired mode (PASS). Otherwise, the files
|
||||
# mode is more permissive than the desired mode (FAIL).
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue