Class: Inspec::Resources::SiteProvider
- Inherits:
-
Object
- Object
- Inspec::Resources::SiteProvider
- Defined in:
- lib/resources/iis_site.rb
Instance Attribute Summary collapse
-
#inspec ⇒ Object
readonly
Returns the value of attribute inspec.
Instance Method Summary collapse
-
#iis_site(name) ⇒ Object
want to populate everything using one powershell command here and spit it out as json.
-
#initialize(inspec) ⇒ SiteProvider
constructor
A new instance of SiteProvider.
Constructor Details
#initialize(inspec) ⇒ SiteProvider
Returns a new instance of SiteProvider.
74 75 76 |
# File 'lib/resources/iis_site.rb', line 74 def initialize(inspec) @inspec = inspec end |
Instance Attribute Details
#inspec ⇒ Object (readonly)
Returns the value of attribute inspec.
72 73 74 |
# File 'lib/resources/iis_site.rb', line 72 def inspec @inspec end |
Instance Method Details
#iis_site(name) ⇒ Object
want to populate everything using one powershell command here and spit it out as json
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/resources/iis_site.rb', line 79 def iis_site(name) command = "Get-Website '#{name}' | select-object -Property Name,State,PhysicalPath,bindings,ApplicationPool | ConvertTo-Json" cmd = @inspec.command(command) begin site = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e return nil end bindings_array = site['bindings']['Collection'].map { |k, _str| k['protocol'] << ' ' << k['bindingInformation'] << (k['protocol'] == 'https' ? ' sslFlags=' << flags : '') } # map our values to a hash table info = { name: site['name'], state: site['state'], path: site['physicalPath'], bindings: bindings_array, app_pool: site['applicationPool'], } info end |