inspec-iggy 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 937720e2817669251c145140bb5a1a7c168fd2afa66a02fe3313028facbee416
4
- data.tar.gz: 787196902a3ce2826b11498a38b7ddad33ba7f28e73f37d32c1924889fd51f48
3
+ metadata.gz: 0c6c518efc4c73cf153954ef3080635ce8c026675e910e0a42418f769b252bd7
4
+ data.tar.gz: ff777a9136a432e0dcd0fe38b2117199f68ca8b1742d95e5ced6b4393e0628af
5
5
  SHA512:
6
- metadata.gz: 0e10cdd048643efe66f40c294f97297eaad4f0652d59951f7a77afa7859d27990e32feee91cc841e261a9b30b5af1b1b12a8b712f412ad02011faf5826478907
7
- data.tar.gz: bc13bd1ab48457f3c335f839454aa4605aa146c8e0c0393da051709af8fb8b92f0e5ecc8c1d7c286bb54d78b5efe36a40e63f44cbd236a97a0af137dcfac5289
6
+ metadata.gz: c39d8c8a9b84232b63994e5622198c3e3961652e745eaaebd837908c91ecfca57ecdcd036edc2c9171ac8a0148503b14ff50e42bbc0cae6287b17bb57bc31ed3
7
+ data.tar.gz: 69103758e44b2f3de34ed4506f806d443f576ae36716bbe03864cd1fae56d158091bc7efc1bb9b16f8e6dbaa7df588fe80809d39dd77109abb92a34384bf8065
data/Gemfile CHANGED
@@ -1,32 +1,15 @@
1
1
  # encoding: utf-8
2
- source 'http://rubygems.org'
2
+ source "http://rubygems.org"
3
3
 
4
4
  gemspec
5
5
 
6
6
  # follows InSpec's versions
7
7
  group :test do
8
- gem 'minitest', '~> 5.5'
9
- gem 'rake', '>= 10'
10
- gem 'rubocop', '= 0.49.1'
11
- gem 'm'
12
- gem 'pry-byebug'
13
- end
14
-
15
- group :aws do
16
- # gem 'aws-sdk', '~> 3'
17
- gem 'aws-sdk-autoscaling', '~> 1'
18
- gem 'aws-sdk-cloudtrail', '~> 1'
19
- gem 'aws-sdk-cloudwatch', '~> 1'
20
- gem 'aws-sdk-cloudwatchlogs', '~> 1'
21
- gem 'aws-sdk-configservice', '~> 1'
22
- gem 'aws-sdk-ec2', '~> 1'
23
- gem 'aws-sdk-ecs', '~> 1'
24
- gem 'aws-sdk-eks', '~> 1'
25
- gem 'aws-sdk-elasticloadbalancing', '~> 1'
26
- gem 'aws-sdk-iam', '~> 1'
27
- gem 'aws-sdk-organizations', '~> 1'
28
- gem 'aws-sdk-rds', '~> 1'
29
- gem 'aws-sdk-s3', '~> 1'
30
- gem 'aws-sdk-sns', '~> 1'
31
- gem 'aws-sdk-sqs', '~> 1'
8
+ gem "inspec-bin", ">=3", "<5"
9
+ gem "chefstyle", "~> 0.13.0"
10
+ gem "minitest", "~> 5.5"
11
+ gem "rake", ">= 10"
12
+ gem "m"
13
+ gem "pry", "~> 0.10"
14
+ gem "pry-byebug"
32
15
  end
data/README.md CHANGED
@@ -26,13 +26,13 @@ InSpec-Iggy is a community-driven plugin that is not officially supported by Che
26
26
 
27
27
  # Requirements <a name="requirements"></a>
28
28
 
29
- Iggy generates compliance profiles for InSpec 2.3 and later, which includes the AWS and Azure resources. Because resources are continuing to be added to InSpec, you may want the latest version to support as much resource coverage as possible. It has currently been tested primarily with AWS but other InSpec-supported platforms should work as well.
29
+ Iggy generates compliance profiles for InSpec 3 and later, requiring external resource packs for the AWS, Azure, and GCP resources. Because resources are continuing to be added to InSpec, you may want the latest version to support as much resource coverage as possible.
30
30
 
31
- Written and tested with Ruby 2.6.
31
+ Written and tested with Ruby 2.6 and InSpec 4.
32
32
 
33
33
  # Installation <a name="installation"></a>
34
34
 
35
- `inspec-iggy` is a plugin for InSpec. InSpec 2.3 or later is required. To install, use:
35
+ `inspec-iggy` is a plugin for InSpec. InSpec 3 or later is required. To install, use:
36
36
 
37
37
  $ inspec plugin install inspec-iggy
38
38
 
@@ -61,7 +61,7 @@ Iggy dynamically pulls the available Cloud resources from InSpec and attempts to
61
61
  [--log-location=LOG_LOCATION] Location to send diagnostic log messages to. (default: STDOUT or Inspec::Log.error)
62
62
  [--platform=gcp|aws|azure] Cloud provider name
63
63
  [--resourcepath=INSPEC_CLOUD_RESOURCE_PATH] Location of inspec-gcp|inspec-aws|inspec-azure resources
64
- Note: --resourcepath should point to the directory where inspec-<cloud_provider> resource pack is downloaded/cloned from Github.
64
+ Note: --resourcepath should point to the directory where inspec-<cloud_provider> resource pack is downloaded/cloned from GitHub.
65
65
 
66
66
  # InSpec Terraform Negative<a name="itn"></a>
67
67
 
@@ -88,7 +88,7 @@ Iggy dynamically pulls the available Cloud resources from InSpec and attempts to
88
88
  [--log-location=LOG_LOCATION] Location to send diagnostic log messages to. (default: STDOUT or Inspec::Log.error)
89
89
  [--platform=gcp|aws|azure] Cloud provider name
90
90
  [--resourcepath=INSPEC_CLOUD_RESOURCE_PATH] Location of inspec-gcp|inspec-aws|inspec-azure resources
91
- Note: --resourcepath should point to the directory where inspec-<cloud_provider> resource pack is downloaded/cloned from Github.
91
+ Note: --resourcepath should point to the directory where inspec-<cloud_provider> resource pack is downloaded/cloned from GitHub.
92
92
 
93
93
  # InSpec CloudFormation Generate<a name="icg"></a>
94
94
 
data/inspec-iggy.gemspec CHANGED
@@ -1,26 +1,26 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('lib', __dir__)
2
+ lib = File.expand_path("lib", __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
- require 'inspec-iggy/version'
5
+ require "inspec-iggy/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'inspec-iggy'
8
+ spec.name = "inspec-iggy"
9
9
  spec.version = InspecPlugins::Iggy::VERSION
10
- spec.authors = ['Matt Ray']
11
- spec.email = ['matt@chef.io']
12
- spec.summary = 'InSpec plugin to generate InSpec compliance profiles from Terraform and CloudFormation.'
13
- spec.description = 'InSpec plugin to generate InSpec profiles from Terraform and CloudFormation to ensure automatic compliance coverage.'
14
- spec.homepage = 'https://github.com/mattray/inspec-iggy'
15
- spec.license = 'Apache-2.0'
10
+ spec.authors = ["Matt Ray"]
11
+ spec.email = ["matt@chef.io"]
12
+ spec.summary = "InSpec plugin to generate InSpec compliance profiles from Terraform and CloudFormation."
13
+ spec.description = "InSpec plugin to generate InSpec profiles from Terraform and CloudFormation to ensure automatic compliance coverage."
14
+ spec.homepage = "https://github.com/mattray/inspec-iggy"
15
+ spec.license = "Apache-2.0"
16
16
 
17
17
  spec.files = %w{
18
18
  README.md inspec-iggy.gemspec Gemfile
19
19
  } + Dir.glob(
20
- '{bin,docs,examples,lib,tasks}/**/*', File::FNM_DOTMATCH
20
+ "{bin,docs,examples,lib,tasks}/**/*", File::FNM_DOTMATCH
21
21
  ).reject { |f| File.directory?(f) }
22
22
 
23
- spec.require_paths = ['lib']
23
+ spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency 'inspec', '>=2.3', '<5'
25
+ spec.add_dependency "inspec", ">=3", "<5"
26
26
  end
data/lib/inspec-iggy.rb CHANGED
@@ -5,4 +5,4 @@
5
5
  libdir = File.dirname(__FILE__)
6
6
  $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
7
7
 
8
- require 'inspec-iggy/plugin'
8
+ require "inspec-iggy/plugin"
@@ -1,79 +1,70 @@
1
1
  # CloudFormation CLI command and options
2
2
 
3
- require 'inspec/plugin/v2'
3
+ require "inspec/plugin/v2"
4
4
 
5
- require 'inspec-iggy/version'
6
- require 'inspec-iggy/profile_helper'
7
- require 'inspec-iggy/cloudformation/generate'
5
+ require "inspec-iggy/version"
6
+ require "inspec-iggy/profile_helper"
7
+ require "inspec-iggy/cloudformation/generate"
8
8
 
9
9
  module InspecPlugins::Iggy
10
10
  module CloudFormation
11
11
  class CliCommand < Inspec.plugin(2, :cli_command)
12
- subcommand_desc 'cloudformation SUBCOMMAND ...', 'Generate an InSpec profile from CloudFormation'
13
-
14
- # Thor.map(Hash) allows you to make aliases for commands.
15
- map('-v' => 'version') # Treat `inspec terraform -v`` as `inspec terraform version`
16
- map('--version' => 'version') # Treat `inspec terraform -version`` as `inspec terraform version`
17
-
18
- desc 'version', 'Display version information', hide: true
19
- def version
20
- say("Iggy v#{InspecPlugins::Iggy::VERSION}")
21
- end
12
+ subcommand_desc "cloudformation SUBCOMMAND ...", "Generate an InSpec profile from CloudFormation"
22
13
 
23
14
  option :debug,
24
- desc: 'Verbose debugging messages',
15
+ desc: "Verbose debugging messages",
25
16
  type: :boolean,
26
17
  default: false
27
18
 
28
19
  option :copyright,
29
- desc: 'Name of the copyright holder',
30
- default: 'The Authors'
20
+ desc: "Name of the copyright holder",
21
+ default: "The Authors"
31
22
 
32
23
  option :email,
33
- desc: 'Email address of the author',
34
- default: 'you@example.com'
24
+ desc: "Email address of the author",
25
+ default: "you@example.com"
35
26
 
36
27
  option :license,
37
- desc: 'License for the profile',
38
- default: 'Apache-2.0'
28
+ desc: "License for the profile",
29
+ default: "Apache-2.0"
39
30
 
40
31
  option :maintainer,
41
- desc: 'Name of the copyright holder',
42
- default: 'The Authors'
32
+ desc: "Name of the copyright holder",
33
+ default: "The Authors"
43
34
 
44
35
  option :summary,
45
- desc: 'One line summary for the profile',
46
- default: 'An InSpec Compliance Profile'
36
+ desc: "One line summary for the profile",
37
+ default: "An InSpec Compliance Profile"
47
38
 
48
39
  option :title,
49
- desc: 'Human-readable name for the profile',
50
- default: 'InSpec Profile'
40
+ desc: "Human-readable name for the profile",
41
+ default: "InSpec Profile"
51
42
 
52
43
  option :version,
53
- desc: 'Specify the profile version',
54
- default: '0.1.0'
44
+ desc: "Specify the profile version",
45
+ default: "0.1.0"
55
46
 
56
47
  option :overwrite,
57
- desc: 'Overwrites existing profile directory',
48
+ desc: "Overwrites existing profile directory",
58
49
  type: :boolean,
59
50
  default: false
60
51
 
61
52
  option :name,
62
- aliases: '-n',
53
+ aliases: "-n",
63
54
  required: true,
64
- desc: 'Name of profile to be generated'
55
+ desc: "Name of profile to be generated"
65
56
 
66
57
  option :stack,
67
- aliases: '-s',
58
+ aliases: "-s",
68
59
  required: true,
69
- desc: 'Specify stack name or unique stack ID associated with the CloudFormation template'
60
+ desc: "Specify stack name or unique stack ID associated with the CloudFormation template"
70
61
 
71
62
  option :template,
72
- aliases: '-t',
63
+ aliases: "-t",
73
64
  required: true,
74
- desc: 'Specify path to the input CloudFormation template'
65
+ desc: "Specify path to the input CloudFormation template"
75
66
 
76
- desc 'generate [options]', 'Generate InSpec compliance controls from CloudFormation template'
67
+ desc "generate [options]", "Generate InSpec compliance controls from CloudFormation template"
77
68
  def generate
78
69
  Inspec::Log.level = :debug if options[:debug]
79
70
  # hash of generated controls
@@ -1,11 +1,11 @@
1
1
  # parses CloudFormation JSON files
2
2
 
3
- require 'inspec/objects/control'
4
- require 'inspec/objects/ruby_helper'
5
- require 'inspec/objects/describe'
3
+ require "inspec/objects/control"
4
+ require "inspec/objects/ruby_helper"
5
+ require "inspec/objects/describe"
6
6
 
7
- require 'inspec-iggy/file_helper'
8
- require 'inspec-iggy/inspec_helper'
7
+ require "inspec-iggy/file_helper"
8
+ require "inspec-iggy/inspec_helper"
9
9
 
10
10
  module InspecPlugins::Iggy::CloudFormation
11
11
  class Generate
@@ -18,12 +18,12 @@ module InspecPlugins::Iggy::CloudFormation
18
18
  generated_controls = []
19
19
 
20
20
  # iterate over the resources
21
- cfn_resources = template['Resources']
21
+ cfn_resources = template["Resources"]
22
22
  cfn_resources.keys.each do |cfn_res|
23
23
  # split out the last ::, these are all AWS
24
- cfn_resource = cfn_resources[cfn_res]['Type'].split('::').last
24
+ cfn_resource = cfn_resources[cfn_res]["Type"].split("::").last
25
25
  # split camelcase and join with underscores
26
- cfn_res_type = 'aws_' + cfn_resource.split(/(?=[A-Z])/).join('_').downcase
26
+ cfn_res_type = "aws_" + cfn_resource.split(/(?=[A-Z])/).join("_").downcase
27
27
 
28
28
  # add translation layer
29
29
  if InspecPlugins::Iggy::InspecHelper::TRANSLATED_RESOURCES.key?(cfn_res_type)
@@ -39,42 +39,42 @@ module InspecPlugins::Iggy::CloudFormation
39
39
  ctrl = Inspec::Control.new
40
40
  ctrl.id = "#{cfn_res_type}::#{cfn_res}"
41
41
  ctrl.title = "InSpec-Iggy #{cfn_res_type}::#{cfn_res}"
42
- ctrl.descriptions['default'] = "#{cfn_res_type}::#{cfn_res} from the source file #{absolutename}\nGenerated by InSpec-Iggy v#{InspecPlugins::Iggy::VERSION}"
43
- ctrl.impact = '1.0'
42
+ ctrl.descriptions["default"] = "#{cfn_res_type}::#{cfn_res} from the source file #{absolutename}\nGenerated by InSpec-Iggy v#{InspecPlugins::Iggy::VERSION}"
43
+ ctrl.impact = "1.0"
44
44
 
45
45
  describe = Inspec::Describe.new
46
46
  # describes the resource with the logical_resource_id as argument, replaced at inspec exec
47
47
  describe.qualifier.push([cfn_res_type, "resources[#{cfn_res}]"])
48
48
 
49
49
  # ensure the resource exists
50
- describe.add_test(nil, 'exist', nil)
50
+ describe.add_test(nil, "exist", nil)
51
51
 
52
52
  # EC2 instances should be running
53
- describe.add_test(nil, 'be_running', nil) if cfn_res_type.eql?('aws_ec2_instance')
53
+ describe.add_test(nil, "be_running", nil) if cfn_res_type.eql?("aws_ec2_instance")
54
54
 
55
55
  # if there's a match, see if there are matching InSpec properties
56
- inspec_properties = InspecPlugins::Iggy::InspecHelper.resource_properties(cfn_res_type, 'aws')
57
- cfn_resources[cfn_res]['Properties'].keys.each do |attr|
56
+ inspec_properties = InspecPlugins::Iggy::InspecHelper.resource_properties(cfn_res_type, "aws")
57
+ cfn_resources[cfn_res]["Properties"].keys.each do |attr|
58
58
  # insert '_' on the CamelCase to get camel_case
59
59
  attr_split = attr.split(/(?=[A-Z])/)
60
- property = attr_split.join('_').downcase
60
+ property = attr_split.join("_").downcase
61
61
  if inspec_properties.member?(property)
62
62
  Inspec::Log.debug "CloudFormation::Generate.parse_generate #{cfn_res_type} inspec_property = #{property} MATCHED"
63
- value = cfn_resources[cfn_res]['Properties'][attr]
63
+ value = cfn_resources[cfn_res]["Properties"][attr]
64
64
  if (value.is_a? Hash) || (value.is_a? Array)
65
65
  # these get replaced at inspec exec
66
- if property.eql?('vpc_id') # rubocop:disable Metrics/BlockNesting
67
- vpc = cfn_resources[cfn_res]['Properties'][attr].values.first
66
+ if property.eql?("vpc_id") # rubocop:disable Metrics/BlockNesting
67
+ vpc = cfn_resources[cfn_res]["Properties"][attr].values.first
68
68
  # https://github.com/inspec/inspec/issues/3173
69
- describe.add_test(property, 'cmp', "resources[#{vpc}]") unless cfn_res_type.eql?('aws_route_table') # rubocop:disable Metrics/BlockNesting
69
+ describe.add_test(property, "cmp", "resources[#{vpc}]") unless cfn_res_type.eql?("aws_route_table") # rubocop:disable Metrics/BlockNesting
70
70
  # AMI is a Ref into Parameters
71
- elsif property.eql?('image_id') # rubocop:disable Metrics/BlockNesting
72
- amiref = cfn_resources[cfn_res]['Properties'][attr].values.first
73
- ami = template['Parameters'][amiref]['Default']
74
- describe.add_test(property, 'cmp', ami)
71
+ elsif property.eql?("image_id") # rubocop:disable Metrics/BlockNesting
72
+ amiref = cfn_resources[cfn_res]["Properties"][attr].values.first
73
+ ami = template["Parameters"][amiref]["Default"]
74
+ describe.add_test(property, "cmp", ami)
75
75
  end
76
76
  else
77
- describe.add_test(property, 'cmp', value)
77
+ describe.add_test(property, "cmp", value)
78
78
  end
79
79
  else
80
80
  Inspec::Log.debug "CloudFormation::Generate.parse_generate #{cfn_res_type} inspec_property = #{property} SKIPPED"
@@ -1,7 +1,7 @@
1
1
  # helper methods for retrieving and parsing files
2
2
 
3
- require 'json'
4
- require 'open-uri'
3
+ require "json"
4
+ require "open-uri"
5
5
 
6
6
  module InspecPlugins
7
7
  module Iggy
@@ -0,0 +1,18 @@
1
+ # CloudFormation CLI command and options
2
+
3
+ require "inspec/plugin/v2"
4
+
5
+ require "inspec-iggy/version"
6
+
7
+ module InspecPlugins
8
+ module Iggy
9
+ class CliCommand < Inspec.plugin(2, :cli_command)
10
+ subcommand_desc "iggy", "Use 'inspec cloudformation' or 'inspec terraform'"
11
+
12
+ desc "version", "Display version information"
13
+ def version
14
+ say("Iggy v#{InspecPlugins::Iggy::VERSION}")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,10 +1,10 @@
1
1
  # constants and helpers for working with InSpec
2
2
 
3
- require 'inspec'
3
+ require "inspec"
4
4
 
5
- require 'inspec-iggy/platforms/aws_helper'
6
- require 'inspec-iggy/platforms/azure_helper'
7
- require 'inspec-iggy/platforms/gcp_helper'
5
+ require "inspec-iggy/platforms/aws_helper"
6
+ require "inspec-iggy/platforms/azure_helper"
7
+ require "inspec-iggy/platforms/gcp_helper"
8
8
 
9
9
  module InspecPlugins
10
10
  module Iggy
@@ -18,116 +18,138 @@ module InspecPlugins
18
18
 
19
19
  # translate Terraform resource name to InSpec
20
20
  TRANSLATED_RESOURCES = {
21
- 'aws_instance' => 'aws_ec2_instance',
22
- 'aws_v_p_c' => 'aws_vpc', # CFN
23
- 'azurerm_resource_group' => 'azure_resource_group',
24
- 'azurerm_virtual_machine' => 'azure_virtual_machine'
21
+ "aws_instance" => "aws_ec2_instance",
22
+ "aws_v_p_c" => "aws_vpc", # CFN
23
+ "azurerm_resource_group" => "azure_resource_group",
24
+ "azurerm_virtual_machine" => "azure_virtual_machine",
25
25
  # "azure_virtual_machine_data_disk",
26
26
  # 'aws_route' => 'aws_route_table' # needs route_table_id instead of id
27
27
  }.freeze
28
28
 
29
29
  def self.available_resource_qualifiers(platform)
30
30
  case platform
31
- when 'aws'
31
+ when "aws"
32
32
  InspecPlugins::Iggy::Platforms::AwsHelper::AWS_RESOURCE_QUALIFIERS
33
- when 'azure'
33
+ when "azure"
34
34
  InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_RESOURCE_QUALIFIERS
35
- when 'gcp'
35
+ when "gcp"
36
36
  InspecPlugins::Iggy::Platforms::GcpHelper::GCP_RESOURCE_QUALIFIERS
37
37
  end
38
38
  end
39
39
 
40
40
  def self.available_resource_iterators(platform)
41
41
  case platform
42
- when 'aws'
42
+ when "aws"
43
43
  InspecPlugins::Iggy::Platforms::AwsHelper::AWS_RESOURCE_ITERATORS
44
- when 'azure'
44
+ when "azure"
45
45
  InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_RESOURCE_ITERATORS
46
- when 'gcp'
46
+ when "gcp"
47
47
  InspecPlugins::Iggy::Platforms::GcpHelper::GCP_RESOURCE_ITERATORS
48
48
  end
49
49
  end
50
50
 
51
+ def self.available_translated_resource_properties(platform, resource)
52
+ case platform
53
+ when "aws"
54
+ InspecPlugins::Iggy::Platforms::AwsHelper::AWS_TRANSLATED_RESOURCE_PROPERTIES[resource]
55
+ when "azure"
56
+ InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_TRANSLATED_RESOURCE_PROPERTIES[resource]
57
+ when "gcp"
58
+ InspecPlugins::Iggy::Platforms::GcpHelper::GCP_TRANSLATED_RESOURCE_PROPERTIES[resource]
59
+ end
60
+ end
61
+
62
+ def self.translated_resource_property(platform, resource, property)
63
+ translated_resource = available_translated_resource_properties(platform, resource)
64
+ translated_property = translated_resource[property] if translated_resource
65
+ if translated_property
66
+ Inspec::Log.debug "InspecHelper.translated_resource_property #{platform}:#{resource}:#{property} = #{translated_property} TRANSLATED"
67
+ translated_property
68
+ else
69
+ property
70
+ end
71
+ end
72
+
51
73
  # manually maintained common methods we don't want to test InSpec properties
52
- REMOVED_COMMON_PROPERTIES = [
53
- :!,
54
- :!=,
55
- :!~,
56
- :<=>,
57
- :==,
58
- :===,
59
- :=~,
60
- :__binding__,
61
- :__id__,
62
- :__send__,
63
- :check_supports,
64
- :class,
65
- :clone,
66
- :dclone,
67
- :define_singleton_method,
68
- :display,
69
- :dup,
70
- :enum_for,
71
- :eql?,
72
- :equal?,
73
- :extend,
74
- :fail_resource,
75
- :freeze,
76
- :frozen?,
77
- :hash,
78
- :inspec,
79
- :inspect,
80
- :instance_eval,
81
- :instance_exec,
82
- :instance_of?,
83
- :instance_variable_defined?,
84
- :instance_variable_get,
85
- :instance_variable_set,
86
- :instance_variables,
87
- :is_a?,
88
- :itself,
89
- :kind_of?,
90
- :method,
91
- :methods,
92
- :nil?,
93
- :object_id,
94
- :pretty_inspect,
95
- :pretty_print,
96
- :pretty_print_cycle,
97
- :pretty_print_inspect,
98
- :pretty_print_instance_variables,
99
- :private_methods,
100
- :protected_methods,
101
- :pry,
102
- :public_method,
103
- :public_methods,
104
- :public_send,
105
- :remove_instance_variable,
106
- :resource_exception_message,
107
- :resource_failed?,
108
- :resource_skipped?,
109
- :respond_to?,
110
- :send,
111
- :should,
112
- :should_not,
113
- :singleton_class,
114
- :singleton_method,
115
- :singleton_methods,
116
- :skip_resource,
117
- :taint,
118
- :tainted?,
119
- :tap,
120
- :then,
121
- :to_enum,
122
- :to_json,
123
- :to_s,
124
- :to_yaml,
125
- :trust,
126
- :untaint,
127
- :untrust,
128
- :untrusted?,
129
- :yield_self
130
- ].freeze
74
+ REMOVED_COMMON_PROPERTIES = %i{
75
+ !
76
+ !=
77
+ !~
78
+ <=>
79
+ ==
80
+ ===
81
+ =~
82
+ __binding__
83
+ __id__
84
+ __send__
85
+ check_supports
86
+ class
87
+ clone
88
+ dclone
89
+ define_singleton_method
90
+ display
91
+ dup
92
+ enum_for
93
+ eql?
94
+ equal?
95
+ extend
96
+ fail_resource
97
+ freeze
98
+ frozen?
99
+ hash
100
+ inspec
101
+ inspect
102
+ instance_eval
103
+ instance_exec
104
+ instance_of?
105
+ instance_variable_defined?
106
+ instance_variable_get
107
+ instance_variable_set
108
+ instance_variables
109
+ is_a?
110
+ itself
111
+ kind_of?
112
+ method
113
+ methods
114
+ nil?
115
+ object_id
116
+ pretty_inspect
117
+ pretty_print
118
+ pretty_print_cycle
119
+ pretty_print_inspect
120
+ pretty_print_instance_variables
121
+ private_methods
122
+ protected_methods
123
+ pry
124
+ public_method
125
+ public_methods
126
+ public_send
127
+ remove_instance_variable
128
+ resource_exception_message
129
+ resource_failed?
130
+ resource_skipped?
131
+ respond_to?
132
+ send
133
+ should
134
+ should_not
135
+ singleton_class
136
+ singleton_method
137
+ singleton_methods
138
+ skip_resource
139
+ taint
140
+ tainted?
141
+ tap
142
+ then
143
+ to_enum
144
+ to_json
145
+ to_s
146
+ to_yaml
147
+ trust
148
+ untaint
149
+ untrust
150
+ untrusted?
151
+ yield_self
152
+ }.freeze
131
153
 
132
154
  # properties are often dynamically generated, making it hard to determine
133
155
  # their existence without instantiating them. Because of this, we will
@@ -137,23 +159,26 @@ module InspecPlugins
137
159
  # :id, #disabled for GCP
138
160
  # :ip_version, # documented but undefined
139
161
  # :network, # documented but undefined
140
- # :subnetwork, # documented but undefined
141
162
  :addons_config,
142
- :address_type,
143
163
  :address,
164
+ :address_type,
144
165
  :aggregation_alignment_period,
145
166
  :aggregation_cross_series_reducer,
146
167
  :aggregation_per_series_aligner,
147
168
  :allowed,
148
169
  :archive_size_bytes,
149
170
  :auto_create_subnetworks,
171
+ :availability_zone,
172
+ :availability_zones,
150
173
  :available_cpu_platforms,
174
+ :available_ip_address_count,
151
175
  :available_memory_mb,
152
176
  :backend_service,
153
177
  :backup_pool,
154
178
  :base_instance_name,
155
179
  :can_ip_forward,
156
180
  :check_interval_sec,
181
+ :cidr_block,
157
182
  :cluster_ipv4_cidr,
158
183
  :combiner,
159
184
  :common_instance_metadata,
@@ -161,11 +186,11 @@ module InspecPlugins
161
186
  :conditions,
162
187
  :config,
163
188
  :cpu_platform,
164
- :create_time_date,
165
189
  :create_time,
190
+ :create_time_date,
166
191
  :creation_record,
167
- :creation_timestamp_date,
168
192
  :creation_timestamp,
193
+ :creation_timestamp_date,
169
194
  :crypto_key_name,
170
195
  :crypto_key_url,
171
196
  :current_actions,
@@ -173,14 +198,15 @@ module InspecPlugins
173
198
  :current_node_count,
174
199
  :current_node_version,
175
200
  :custom_features,
176
- :dataset_id,
177
201
  :dataset,
202
+ :dataset_id,
178
203
  :default_exempted_members,
179
204
  :default_service_account,
180
205
  :default_types,
181
206
  :deletion_protection,
182
207
  :description,
183
208
  :detailed_status,
209
+ :dhcp_options_id,
184
210
  :direction,
185
211
  :disabled,
186
212
  :disk_encryption_key,
@@ -189,13 +215,15 @@ module InspecPlugins
189
215
  :display_name,
190
216
  :dns_name,
191
217
  :dnssec_config,
192
- :enabled_features,
218
+ :ebs_volumes,
193
219
  :enabled,
220
+ :enabled_features,
194
221
  :endpoint,
195
222
  :entry_point,
196
223
  :environment_variables,
197
224
  :etag,
198
225
  :expire_time,
226
+ :external_ports,
199
227
  :failover_ratio,
200
228
  :family,
201
229
  :filename,
@@ -203,6 +231,8 @@ module InspecPlugins
203
231
  :fingerprint,
204
232
  :friendly_name,
205
233
  :gateway_address,
234
+ :group_id,
235
+ :group_name,
206
236
  :guest_accelerators,
207
237
  :guest_os_features,
208
238
  :health_check,
@@ -210,70 +240,19 @@ module InspecPlugins
210
240
  :host,
211
241
  :ignored_files,
212
242
  :ike_version,
243
+ :image_id,
244
+ :inbound_rules,
245
+ :inbound_rules_count,
213
246
  :included_files,
214
247
  :included_permissions,
215
248
  :initial_cluster_version,
216
249
  :initial_node_count,
217
- :instance_group_urls,
218
250
  :instance_group,
219
- :instance_template,
220
- :ip_address,
221
- :ip_cidr_range,
222
- :ip_protocol,
223
- :ip_version,
224
- :key_ring_name,
225
- :key_ring_url,
226
- :key_signing_key_algorithm,
227
- :kind,
228
- :kms_key_name,
229
- :label_fingerprint,
230
- :label_value_by_key,
231
- :labels_keys,
232
- :labels_values,
233
- :labels,
234
- :last_attach_timestamp,
235
- :last_detach_timestamp,
236
- :last_modified_time,
237
- :legacy_abac,
238
- :licenses,
239
- :lifecycle_state,
240
- :load_balancing_scheme,
241
- :local_traffic_selector,
242
- :location,
243
- :logging_service,
244
- :machine_type,
245
- :managed_zone,
246
- :management,
247
- :master_auth,
248
- :members,
249
- :metadata_keys,
250
- :metadata_value_by_key,
251
- :metadata_values,
252
- :metadata,
253
- :min_cpu_platform,
254
- :monitoring_service,
255
- :mutation_record,
256
- :name_servers,
257
- :family,
258
- :filename,
259
- :filter,
260
- :fingerprint,
261
- :friendly_name,
262
- :gateway_address,
263
- :guest_accelerators,
264
- :guest_os_features,
265
- :health_check,
266
- :healthy_threshold,
267
- :host,
268
- :ignored_files,
269
- :ike_version,
270
- :included_files,
271
- :included_permissions,
272
- :initial_cluster_version,
273
- :initial_node_count,
274
251
  :instance_group_urls,
275
- :instance_group,
252
+ :instance_ids,
276
253
  :instance_template,
254
+ :instance_tenancy,
255
+ :internal_ports,
277
256
  :ip_address,
278
257
  :ip_cidr_range,
279
258
  :ip_protocol,
@@ -285,12 +264,13 @@ module InspecPlugins
285
264
  :kms_key_name,
286
265
  :label_fingerprint,
287
266
  :label_value_by_key,
267
+ :labels,
288
268
  :labels_keys,
289
269
  :labels_values,
290
- :labels,
291
270
  :last_attach_timestamp,
292
271
  :last_detach_timestamp,
293
272
  :last_modified_time,
273
+ :launch_time,
294
274
  :legacy_abac,
295
275
  :licenses,
296
276
  :lifecycle_state,
@@ -303,37 +283,39 @@ module InspecPlugins
303
283
  :management,
304
284
  :master_auth,
305
285
  :members,
286
+ :metadata,
306
287
  :metadata_keys,
307
288
  :metadata_value_by_key,
308
289
  :metadata_values,
309
- :metadata,
310
290
  :min_cpu_platform,
311
291
  :monitoring_service,
312
292
  :mutation_record,
313
- :name_servers,
314
293
  :name,
294
+ :name_servers,
315
295
  :named_ports,
316
- :network_interfaces,
317
296
  :network,
297
+ :network_interfaces,
318
298
  :next_hop_gateway,
319
299
  :next_hop_instance,
320
300
  :next_hop_ip,
321
301
  :next_hop_network,
322
302
  :next_hop_vpn_tunnel,
323
- :next_rotation_time_date,
324
303
  :next_rotation_time,
304
+ :next_rotation_time_date,
325
305
  :node_config,
326
306
  :node_ipv4_cidr_size,
327
307
  :node_pools,
328
308
  :num_bytes,
329
309
  :num_long_term_bytes,
330
310
  :num_rows,
311
+ :outbound_rules,
312
+ :outbound_rules_count,
331
313
  :output_version_format,
332
314
  :parent,
333
315
  :peer_ip,
334
316
  :physical_block_size_bytes,
335
- :port_range,
336
317
  :port,
318
+ :port_range,
337
319
  :ports,
338
320
  :primary_create_time,
339
321
  :primary_create_time_date,
@@ -352,8 +334,8 @@ module InspecPlugins
352
334
  :quotas,
353
335
  :raw_disk,
354
336
  :raw_key,
355
- :region_name,
356
337
  :region,
338
+ :region_name,
357
339
  :remote_traffic_selector,
358
340
  :request_path,
359
341
  :rotation_period,
@@ -361,45 +343,50 @@ module InspecPlugins
361
343
  :routing_config,
362
344
  :runtime,
363
345
  :scheduling,
346
+ :security_group_ids,
347
+ :security_groups,
364
348
  :self_link,
349
+ :service,
365
350
  :service_account_email,
366
351
  :service_accounts,
367
- :service,
368
352
  :services_ipv4_cidr,
369
353
  :session_affinity,
370
354
  :sha256,
371
- :shared_secret_hash,
372
355
  :shared_secret,
356
+ :shared_secret_hash,
373
357
  :size_gb,
374
358
  :source_archive_url,
375
359
  :source_disk,
360
+ :source_image,
376
361
  :source_image_encryption_key,
377
362
  :source_image_id,
378
- :source_image,
379
363
  :source_ranges,
364
+ :source_snapshot,
380
365
  :source_snapshot_encryption_key,
381
366
  :source_snapshot_id,
382
- :source_snapshot,
383
367
  :source_type,
384
368
  :source_upload_url,
385
369
  :ssl_certificates,
386
370
  :ssl_policy,
387
371
  :stage,
388
372
  :start_restricted,
373
+ :state,
389
374
  :status,
390
375
  :storage_bytes,
376
+ :subnet_id,
377
+ :subnet_ids,
391
378
  :subnetwork,
392
379
  :substitutions,
393
380
  :table_id,
394
381
  :table_reference,
395
382
  :tags,
383
+ :target,
396
384
  :target_pools,
397
385
  :target_size,
398
386
  :target_tags,
399
387
  :target_vpn_gateway,
400
- :target,
401
- :timeout_sec,
402
388
  :timeout,
389
+ :timeout_sec,
403
390
  :title,
404
391
  :ttl,
405
392
  :type,
@@ -407,21 +394,22 @@ module InspecPlugins
407
394
  :update_time,
408
395
  :url_map,
409
396
  :users,
410
- :version_id,
411
397
  :version,
398
+ :version_id,
399
+ :vpc_id,
412
400
  :writer_identity,
413
401
  :xpn_project_status,
402
+ :zone,
414
403
  :zone_signing_key_algorithm,
415
- :zone
416
404
  ].freeze
417
405
 
418
406
  # load the resource pack into InSpec::Resource.registry
419
407
  def self.load_resource_pack(resource_path)
420
408
  # find the libraries path in the resource pack
421
- if resource_path.end_with?('libraries')
409
+ if resource_path.end_with?("libraries")
422
410
  libpath = resource_path
423
411
  else
424
- libpath = resource_path+'/libraries'
412
+ libpath = resource_path + "/libraries"
425
413
  end
426
414
  $LOAD_PATH.push(libpath)
427
415
  # find all the classes in the libpath and require them
@@ -429,7 +417,7 @@ module InspecPlugins
429
417
  Dir.glob("#{libpath}/*.rb").each do |x|
430
418
  begin
431
419
  require(x)
432
- rescue Exception =>e # rubocop:disable Lint/RescueException AWS is blowing up for some reason
420
+ rescue Exception => e # rubocop:disable Lint/RescueException AWS is blowing up for some reason
433
421
  puts e
434
422
  end
435
423
  end
@@ -442,11 +430,11 @@ module InspecPlugins
442
430
  inspec_properties = Inspec::Resource.registry[resource].instance_methods + ADDITIONAL_COMMON_PROPERTIES
443
431
  inspec_properties -= REMOVED_COMMON_PROPERTIES
444
432
  case platform
445
- when 'aws'
433
+ when "aws"
446
434
  inspec_properties -= InspecPlugins::Iggy::Platforms::AwsHelper::AWS_REMOVED_PROPERTIES[resource] unless InspecPlugins::Iggy::Platforms::AwsHelper::AWS_REMOVED_PROPERTIES[resource].nil?
447
- when 'azure'
435
+ when "azure"
448
436
  inspec_properties -= InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_REMOVED_PROPERTIES[resource] unless InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_REMOVED_PROPERTIES[resource].nil?
449
- when 'gcp'
437
+ when "gcp"
450
438
  inspec_properties -= InspecPlugins::Iggy::Platforms::GcpHelper::GCP_REMOVED_PROPERTIES[resource] unless InspecPlugins::Iggy::Platforms::GcpHelper::GCP_REMOVED_PROPERTIES[resource].nil?
451
439
  end
452
440
  # get InSpec properties by method names
@@ -459,7 +447,7 @@ module InspecPlugins
459
447
  def self.tf_controls(title, generated_controls, platform)
460
448
  content = "title \"#{title}: generated by Iggy v#{Iggy::VERSION}\"\n"
461
449
 
462
- content += InspecPlugins::Iggy::Platforms::AwsHelper.tf_controls if platform.eql?('aws')
450
+ content += InspecPlugins::Iggy::Platforms::AwsHelper.tf_controls if platform.eql?("aws")
463
451
 
464
452
  # write all controls
465
453
  generated_controls.flatten.each do |control|