inspec/tasks/command_simulator.rb
Victoria Jeffrey 1ea965080a initial commit
2016-09-01 22:33:41 +01:00

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