mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
22 lines
580 B
Ruby
22 lines
580 B
Ruby
# encoding: utf-8
|
|
require 'train'
|
|
|
|
commands = { 'inspec_exec' => 'inspec exec examples/profile/controls/example.rb', 'inspec_version' => 'inspec version' }
|
|
|
|
backend = Train.create('local')
|
|
conn = backend.connection
|
|
|
|
commands.each do |keyname, command|
|
|
# loop around commands
|
|
cmd = conn.run_command(command)
|
|
cmd.stdout
|
|
|
|
# save the result and put it in inspec/www/app/results with the keyname as filename
|
|
result = cmd.stdout
|
|
dir = 'www/app/responses/'
|
|
out_file = File.new(File.join(dir, "#{keyname}.txt"), 'w')
|
|
out_file.puts(result)
|
|
out_file.close
|
|
end
|
|
|
|
conn.close
|