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.
91 92 93 |
# File 'lib/resources/iis_site.rb', line 91 def initialize(inspec) @inspec = inspec end |
Instance Attribute Details
#inspec ⇒ Object (readonly)
Returns the value of attribute inspec.
89 90 91 |
# File 'lib/resources/iis_site.rb', line 89 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
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/resources/iis_site.rb', line 96 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| "#{k['protocol']} #{k['bindingInformation']}#{k['protocol'] == 'https' ? " sslFlags=#{k['sslFlags']}" : ''}" } # 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 |