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 +4 -4
- data/Gemfile +8 -25
- data/README.md +5 -5
- data/inspec-iggy.gemspec +12 -12
- data/lib/inspec-iggy.rb +1 -1
- data/lib/inspec-iggy/cloudformation/cli_command.rb +28 -37
- data/lib/inspec-iggy/cloudformation/generate.rb +24 -24
- data/lib/inspec-iggy/file_helper.rb +2 -2
- data/lib/inspec-iggy/iggy_cli_command.rb +18 -0
- data/lib/inspec-iggy/inspec_helper.rb +166 -178
- data/lib/inspec-iggy/platforms/aws_helper.rb +28 -11
- data/lib/inspec-iggy/platforms/azure_helper.rb +10 -7
- data/lib/inspec-iggy/platforms/gcp_helper.rb +127 -126
- data/lib/inspec-iggy/plugin.rb +9 -3
- data/lib/inspec-iggy/profile_helper.rb +27 -27
- data/lib/inspec-iggy/terraform/cli_command.rb +37 -46
- data/lib/inspec-iggy/terraform/generate.rb +56 -36
- data/lib/inspec-iggy/terraform/negative.rb +42 -23
- data/lib/inspec-iggy/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c6c518efc4c73cf153954ef3080635ce8c026675e910e0a42418f769b252bd7
|
4
|
+
data.tar.gz: ff777a9136a432e0dcd0fe38b2117199f68ca8b1742d95e5ced6b4393e0628af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c39d8c8a9b84232b63994e5622198c3e3961652e745eaaebd837908c91ecfca57ecdcd036edc2c9171ac8a0148503b14ff50e42bbc0cae6287b17bb57bc31ed3
|
7
|
+
data.tar.gz: 69103758e44b2f3de34ed4506f806d443f576ae36716bbe03864cd1fae56d158091bc7efc1bb9b16f8e6dbaa7df588fe80809d39dd77109abb92a34384bf8065
|
data/Gemfile
CHANGED
@@ -1,32 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
source
|
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
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
|
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
|
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
|
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
|
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
|
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(
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
require
|
5
|
+
require "inspec-iggy/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "inspec-iggy"
|
9
9
|
spec.version = InspecPlugins::Iggy::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
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
|
-
|
20
|
+
"{bin,docs,examples,lib,tasks}/**/*", File::FNM_DOTMATCH
|
21
21
|
).reject { |f| File.directory?(f) }
|
22
22
|
|
23
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency "inspec", ">=3", "<5"
|
26
26
|
end
|
data/lib/inspec-iggy.rb
CHANGED
@@ -1,79 +1,70 @@
|
|
1
1
|
# CloudFormation CLI command and options
|
2
2
|
|
3
|
-
require
|
3
|
+
require "inspec/plugin/v2"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
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
|
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:
|
15
|
+
desc: "Verbose debugging messages",
|
25
16
|
type: :boolean,
|
26
17
|
default: false
|
27
18
|
|
28
19
|
option :copyright,
|
29
|
-
desc:
|
30
|
-
default:
|
20
|
+
desc: "Name of the copyright holder",
|
21
|
+
default: "The Authors"
|
31
22
|
|
32
23
|
option :email,
|
33
|
-
desc:
|
34
|
-
default:
|
24
|
+
desc: "Email address of the author",
|
25
|
+
default: "you@example.com"
|
35
26
|
|
36
27
|
option :license,
|
37
|
-
desc:
|
38
|
-
default:
|
28
|
+
desc: "License for the profile",
|
29
|
+
default: "Apache-2.0"
|
39
30
|
|
40
31
|
option :maintainer,
|
41
|
-
desc:
|
42
|
-
default:
|
32
|
+
desc: "Name of the copyright holder",
|
33
|
+
default: "The Authors"
|
43
34
|
|
44
35
|
option :summary,
|
45
|
-
desc:
|
46
|
-
default:
|
36
|
+
desc: "One line summary for the profile",
|
37
|
+
default: "An InSpec Compliance Profile"
|
47
38
|
|
48
39
|
option :title,
|
49
|
-
desc:
|
50
|
-
default:
|
40
|
+
desc: "Human-readable name for the profile",
|
41
|
+
default: "InSpec Profile"
|
51
42
|
|
52
43
|
option :version,
|
53
|
-
desc:
|
54
|
-
default:
|
44
|
+
desc: "Specify the profile version",
|
45
|
+
default: "0.1.0"
|
55
46
|
|
56
47
|
option :overwrite,
|
57
|
-
desc:
|
48
|
+
desc: "Overwrites existing profile directory",
|
58
49
|
type: :boolean,
|
59
50
|
default: false
|
60
51
|
|
61
52
|
option :name,
|
62
|
-
aliases:
|
53
|
+
aliases: "-n",
|
63
54
|
required: true,
|
64
|
-
desc:
|
55
|
+
desc: "Name of profile to be generated"
|
65
56
|
|
66
57
|
option :stack,
|
67
|
-
aliases:
|
58
|
+
aliases: "-s",
|
68
59
|
required: true,
|
69
|
-
desc:
|
60
|
+
desc: "Specify stack name or unique stack ID associated with the CloudFormation template"
|
70
61
|
|
71
62
|
option :template,
|
72
|
-
aliases:
|
63
|
+
aliases: "-t",
|
73
64
|
required: true,
|
74
|
-
desc:
|
65
|
+
desc: "Specify path to the input CloudFormation template"
|
75
66
|
|
76
|
-
desc
|
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
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "inspec/objects/control"
|
4
|
+
require "inspec/objects/ruby_helper"
|
5
|
+
require "inspec/objects/describe"
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
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[
|
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][
|
24
|
+
cfn_resource = cfn_resources[cfn_res]["Type"].split("::").last
|
25
25
|
# split camelcase and join with underscores
|
26
|
-
cfn_res_type =
|
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[
|
43
|
-
ctrl.impact =
|
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,
|
50
|
+
describe.add_test(nil, "exist", nil)
|
51
51
|
|
52
52
|
# EC2 instances should be running
|
53
|
-
describe.add_test(nil,
|
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,
|
57
|
-
cfn_resources[cfn_res][
|
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(
|
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][
|
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?(
|
67
|
-
vpc = cfn_resources[cfn_res][
|
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,
|
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?(
|
72
|
-
amiref = cfn_resources[cfn_res][
|
73
|
-
ami = template[
|
74
|
-
describe.add_test(property,
|
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,
|
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"
|
@@ -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
|
3
|
+
require "inspec"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
31
|
+
when "aws"
|
32
32
|
InspecPlugins::Iggy::Platforms::AwsHelper::AWS_RESOURCE_QUALIFIERS
|
33
|
-
when
|
33
|
+
when "azure"
|
34
34
|
InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_RESOURCE_QUALIFIERS
|
35
|
-
when
|
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
|
42
|
+
when "aws"
|
43
43
|
InspecPlugins::Iggy::Platforms::AwsHelper::AWS_RESOURCE_ITERATORS
|
44
|
-
when
|
44
|
+
when "azure"
|
45
45
|
InspecPlugins::Iggy::Platforms::AzureHelper::AZURE_RESOURCE_ITERATORS
|
46
|
-
when
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
-
:
|
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
|
-
:
|
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?(
|
409
|
+
if resource_path.end_with?("libraries")
|
422
410
|
libpath = resource_path
|
423
411
|
else
|
424
|
-
libpath = resource_path+
|
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
|
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
|
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
|
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?(
|
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|
|