mirror of
https://github.com/inspec/inspec
synced 2024-12-24 12:03:23 +00:00
5875864f45
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
44 lines
994 B
Ruby
44 lines
994 B
Ruby
# encoding: utf-8
|
|
require 'zip'
|
|
require 'vulcano/targets/dir'
|
|
|
|
module Vulcano::Targets
|
|
class ZipHelper
|
|
|
|
def content input, filter
|
|
content = []
|
|
::Zip::InputStream.open(input) do |io|
|
|
while (entry = io.get_next_entry)
|
|
content.push({
|
|
content: io.read,
|
|
ref: File::join(input, entry.name),
|
|
})
|
|
end
|
|
end
|
|
return content
|
|
end
|
|
|
|
def structure input
|
|
files = Array.new
|
|
::Zip::InputStream.open(input) do |io|
|
|
while (entry = io.get_next_entry)
|
|
files.push(entry.name)
|
|
end
|
|
end
|
|
return files
|
|
end
|
|
|
|
def resolve(path)
|
|
files = structure(path)
|
|
helper = DirsHelper.getHandler(files)
|
|
if helper.nil?
|
|
raise "Don't know how to handle folder #{path}"
|
|
end
|
|
# get all file contents
|
|
file_handler = Vulcano::Targets.modules['file']
|
|
test_files = helper.get_filenames(files)
|
|
content(path, test_files)
|
|
end
|
|
|
|
end
|
|
end
|