Class: Script

Inherits:
Cmd
  • Object
show all
Defined in:
lib/resources/script.rb

Overview

copyright: 2015, Vulcano Security GmbH author: Christoph Hartmann author: Dominik Richter license: All rights reserved

Instance Attribute Summary

Attributes inherited from Cmd

#command

Instance Method Summary collapse

Methods inherited from Cmd

#exit_status, #result, #stderr, #stdout

Constructor Details

#initialize(script) ⇒ Script

Returns a new instance of Script.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/resources/script.rb', line 20

def initialize(script)
  case inspec.os[:family]
  when 'windows'
    # 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}"
  else
    cmd = ''
    return skip_resource 'The `script` resource is not supported on your OS yet.'
  end
  super(cmd)
end

Instance Method Details

#exist?Boolean

we cannot determine if a command exists, because that does not work for scripts

Returns:

  • (Boolean)


36
37
38
# File 'lib/resources/script.rb', line 36

def exist?
  nil
end

#to_sObject



40
41
42
# File 'lib/resources/script.rb', line 40

def to_s
  'Script'
end