class Inspec::Resources::IisApp
def application_pool
def application_pool iis_app[:application_pool] end
def exists?
def exists? !iis_app[:path].empty? end
def has_application_pool?(application_pool)
def has_application_pool?(application_pool) iis_app[:application_pool] == application_pool end
def has_path?(path)
def has_path?(path) iis_app[:path] == path end
def has_physical_path?(physical_path)
def has_physical_path?(physical_path) iis_app[:physical_path] == physical_path end
def has_protocol?(protocol)
def has_protocol?(protocol) iis_app[:protocols].include?(protocol) end
def has_site_name?(site_name)
def has_site_name?(site_name) iis_app[:site_name] == site_name end
def iis_app
def iis_app return @cache unless @cache.nil? command = "Import-Module WebAdministration; Get-WebApplication -Name '#{@path}' -Site '#{@site_name}' | Select-Object * | ConvertTo-Json" cmd = @inspec.command(command) begin app = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e return {} end # map our values to a hash table info = { site_name: @site_name, path: @path, application_pool: app['applicationPool'], physical_path: app['PhysicalPath'], protocols: app['enabledProtocols'], } @cache = info unless info.nil? end
def initialize(path, site_name)
def initialize(path, site_name) @path = path @site_name = site_name @cache = nil @inspec = inspec end
def path
def path iis_app[:path] end
def physical_path
def physical_path iis_app[:physical_path] end
def protocols
def protocols iis_app[:protocols] end
def site_name
def site_name iis_app[:site_name] end
def to_s
def to_s "iis_app '#{@site_name}#{@path}'" end