mirror of
https://github.com/inspec/inspec
synced 2024-12-22 11:03:11 +00:00
3d7244fb07
Wildcards are evaluated prior to applying `sudo` permissions. This means that running `sudo find /some/path/*.conf` will fail if the user does not have read permissions on `/some/path/` because the wildcard cannot expand before `sudo` is applied and `*.conf` isn't a file. The solution for this is to run the command in a subshell that has the proper permissions (e.g. `sudo sh -c 'find /some/path/*.conf'`). This modifies `Utils::FindFiles` to use a subshell thus allowing wildcard support. This fixes #2157 Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
23 lines
458 B
Ruby
23 lines
458 B
Ruby
# Custom resource for Utils::FindFIles
|
|
class TestFindFiles < Inspec.resource(1)
|
|
name 'test_find_files'
|
|
|
|
desc "
|
|
Resource used for testing the funcitonality of Utils::FindFiles
|
|
"
|
|
|
|
example "
|
|
describe test_find_files('/some/filepath') do
|
|
its('results') { should include 'somefile.conf' }
|
|
end
|
|
"
|
|
|
|
require 'utils/find_files'
|
|
include FindFiles
|
|
|
|
attr_reader :results
|
|
|
|
def initialize(path)
|
|
@results = find_files(path)
|
|
end
|
|
end
|