2018-02-06 13:40:21 -05:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'resources/azure/azure_backend'
|
|
|
|
require 'utils/filter'
|
|
|
|
|
|
|
|
module Inspec::Resources
|
|
|
|
class AzureGenericResource < AzureResourceBase
|
|
|
|
name 'azure_generic_resource'
|
|
|
|
|
|
|
|
desc '
|
2018-10-15 09:09:46 -07:00
|
|
|
InSpec Resource to interrogate any Resource type in Azure
|
2018-02-06 13:40:21 -05:00
|
|
|
'
|
|
|
|
|
2018-02-09 10:22:56 -05:00
|
|
|
supports platform: 'azure'
|
|
|
|
|
2018-02-06 13:40:21 -05:00
|
|
|
attr_accessor :filter, :total, :counts, :name, :type, :location, :probes
|
|
|
|
|
|
|
|
def initialize(opts = {})
|
2019-02-21 17:24:19 +00:00
|
|
|
Inspec.deprecate(:resource_azure_generic_resource)
|
2018-06-15 14:44:19 +02:00
|
|
|
|
2018-02-06 13:40:21 -05:00
|
|
|
# Call the parent class constructor
|
|
|
|
super(opts)
|
|
|
|
|
|
|
|
# Get the resource group
|
|
|
|
resource_group
|
|
|
|
|
|
|
|
# Get the resources
|
|
|
|
resources
|
|
|
|
|
|
|
|
# Create the tag methods
|
|
|
|
create_tag_methods
|
|
|
|
end
|
|
|
|
|
|
|
|
# Define the filter table so that it can be interrogated
|
|
|
|
@filter = FilterTable.create
|
2018-06-26 15:14:21 -04:00
|
|
|
@filter.register_filter_method(:contains)
|
|
|
|
.register_column(:type, field: 'type')
|
|
|
|
.register_column(:name, field: 'name')
|
|
|
|
.register_column(:location, field: 'location')
|
|
|
|
.register_column(:properties, field: 'properties')
|
|
|
|
|
|
|
|
@filter.install_filter_methods_on_resource(self, :probes)
|
2018-02-06 13:40:21 -05:00
|
|
|
|
|
|
|
def parse_resource(resource)
|
|
|
|
# return a hash of information
|
|
|
|
parsed = {
|
|
|
|
'location' => resource.location,
|
|
|
|
'name' => resource.name,
|
|
|
|
'type' => resource.type,
|
|
|
|
'exist?' => true,
|
|
|
|
'properties' => AzureResourceProbe.new(resource.properties),
|
|
|
|
}
|
|
|
|
|
|
|
|
parsed
|
|
|
|
end
|
2017-12-12 18:20:22 +00:00
|
|
|
end
|
|
|
|
end
|