mirror of
https://github.com/inspec/inspec
synced 2024-12-18 00:53:22 +00:00
577688a3a0
Many of the resources are named as a top-level class with a fairly generic class name, such as "OS". This causes an issue specifically with kitchen-google which depends on a gem which depends on the "os" gem which itself defines an OS class with a different superclass. This prevents users from using TK, Google Compute, and Inspec without this fix. Some mocked commands had their digest changed as well due to the new indentation, specifically in the User and RegistryKey classes. I strongly recommend viewing this diff with `git diff --ignore-space-change` to see the *real* changes. :)
43 lines
1.1 KiB
Ruby
43 lines
1.1 KiB
Ruby
# encoding: utf-8
|
|
# copyright: 2015, Vulcano Security GmbH
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
# license: All rights reserved
|
|
|
|
module Inspec::Resources
|
|
class Script < Cmd
|
|
name 'script'
|
|
desc 'Use the script InSpec audit resource to test a Windows PowerShell script on the Microsoft Windows platform.'
|
|
example "
|
|
script = <<-EOH
|
|
# you powershell script
|
|
EOH
|
|
|
|
describe script(script) do
|
|
its('matcher') { should eq 'output' }
|
|
end
|
|
"
|
|
|
|
def initialize(script)
|
|
unless inspec.os.windows?
|
|
return skip_resource 'The `script` resource is not supported on your OS yet.'
|
|
end
|
|
|
|
# encodes a script as base64 to run as powershell encodedCommand
|
|
# this comes with performance issues: @see https://gist.github.com/fnichol/7b20596b950e65fb96f9
|
|
require 'winrm'
|
|
script = WinRM::PowershellScript.new(script)
|
|
cmd = "powershell -encodedCommand #{script.encoded}"
|
|
super(cmd)
|
|
end
|
|
|
|
# we cannot determine if a command exists, because that does not work for scripts
|
|
def exist?
|
|
nil
|
|
end
|
|
|
|
def to_s
|
|
'Script'
|
|
end
|
|
end
|
|
end
|