inspec-core 4.18.51 → 4.18.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +61 -0
  3. data/README.md +3 -3
  4. data/inspec-core.gemspec +51 -0
  5. data/lib/bundles/inspec-supermarket/cli.rb +1 -0
  6. data/lib/inspec/backend.rb +49 -47
  7. data/lib/inspec/base_cli.rb +2 -2
  8. data/lib/inspec/cached_fetcher.rb +4 -0
  9. data/lib/inspec/cli.rb +5 -0
  10. data/lib/inspec/config.rb +1 -1
  11. data/lib/inspec/control_eval_context.rb +131 -199
  12. data/lib/inspec/dependencies/requirement.rb +1 -1
  13. data/lib/inspec/dependencies/resolver.rb +46 -0
  14. data/lib/inspec/dsl_shared.rb +25 -3
  15. data/lib/inspec/fetcher.rb +0 -3
  16. data/lib/inspec/fetcher/git.rb +4 -0
  17. data/lib/inspec/fetcher/url.rb +1 -2
  18. data/lib/inspec/file_provider.rb +4 -2
  19. data/lib/inspec/library_eval_context.rb +37 -37
  20. data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +27 -0
  21. data/lib/inspec/plugin/v1/plugins.rb +0 -1
  22. data/lib/inspec/profile.rb +8 -6
  23. data/lib/inspec/profile_context.rb +74 -9
  24. data/lib/inspec/profile_vendor.rb +48 -3
  25. data/lib/inspec/resource.rb +192 -41
  26. data/lib/inspec/resources/aide_conf.rb +1 -1
  27. data/lib/inspec/resources/apache_conf.rb +15 -31
  28. data/lib/inspec/resources/command.rb +1 -1
  29. data/lib/inspec/resources/crontab.rb +56 -56
  30. data/lib/inspec/resources/etc_fstab.rb +1 -1
  31. data/lib/inspec/resources/etc_group.rb +1 -1
  32. data/lib/inspec/resources/etc_hosts.rb +2 -3
  33. data/lib/inspec/resources/etc_hosts_allow_deny.rb +1 -1
  34. data/lib/inspec/resources/file.rb +2 -2
  35. data/lib/inspec/resources/filesystem.rb +4 -4
  36. data/lib/inspec/resources/groups.rb +16 -2
  37. data/lib/inspec/resources/iis_app.rb +1 -1
  38. data/lib/inspec/resources/ini.rb +1 -2
  39. data/lib/inspec/resources/mount.rb +2 -2
  40. data/lib/inspec/resources/oracledb_session.rb +1 -1
  41. data/lib/inspec/resources/package.rb +22 -0
  42. data/lib/inspec/resources/passwd.rb +1 -1
  43. data/lib/inspec/resources/platform.rb +36 -36
  44. data/lib/inspec/resources/port.rb +1 -1
  45. data/lib/inspec/resources/postfix_conf.rb +1 -1
  46. data/lib/inspec/resources/service.rb +23 -15
  47. data/lib/inspec/resources/users.rb +3 -3
  48. data/lib/inspec/resources/virtualization.rb +15 -11
  49. data/lib/inspec/resources/x509_certificate.rb +18 -4
  50. data/lib/inspec/resources/xinetd_conf.rb +1 -1
  51. data/lib/inspec/resources/xml.rb +1 -2
  52. data/lib/inspec/rspec_extensions.rb +12 -0
  53. data/lib/inspec/rule.rb +63 -22
  54. data/lib/inspec/utils/filter.rb +2 -0
  55. data/lib/inspec/utils/parser.rb +244 -240
  56. data/lib/inspec/utils/simpleconfig.rb +1 -1
  57. data/lib/inspec/version.rb +1 -1
  58. data/lib/matchers/matchers.rb +11 -10
  59. data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +3 -0
  60. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +2 -2
  61. data/lib/plugins/inspec-init/templates/profiles/aws/README.md +192 -0
  62. data/lib/plugins/inspec-init/templates/profiles/aws/attributes.yml +2 -0
  63. data/lib/plugins/inspec-init/templates/profiles/aws/controls/example.rb +39 -0
  64. data/lib/plugins/inspec-init/templates/profiles/aws/inspec.yml +22 -0
  65. data/lib/plugins/inspec-init/templates/profiles/azure/README.md +56 -0
  66. data/lib/plugins/inspec-init/templates/profiles/azure/controls/example.rb +14 -0
  67. data/lib/plugins/inspec-init/templates/profiles/azure/inspec.yml +14 -0
  68. data/lib/plugins/inspec-init/templates/profiles/gcp/README.md +66 -0
  69. data/lib/plugins/inspec-init/templates/profiles/gcp/attributes.yml +2 -0
  70. data/lib/plugins/inspec-init/templates/profiles/gcp/controls/example.rb +27 -0
  71. data/lib/plugins/inspec-init/templates/profiles/gcp/inspec.yml +19 -0
  72. data/lib/source_readers/inspec.rb +1 -1
  73. metadata +87 -74
  74. data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
  75. data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
@@ -4,7 +4,7 @@ require "inspec/utils/parser"
4
4
  require "hashie"
5
5
 
6
6
  class SimpleConfig
7
- include CommentParser
7
+ include Inspec::Utils::CommentParser
8
8
 
9
9
  attr_reader :params, :groups
10
10
  def initialize(raw_data, opts = {})
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.18.51".freeze
2
+ VERSION = "4.18.85".freeze
3
3
  end
@@ -221,9 +221,7 @@ RSpec::Matchers.define :cmp do |first_expected| # rubocop:disable Metrics/BlockL
221
221
  end
222
222
 
223
223
  def octal?(value)
224
- return false unless value.is_a?(String)
225
-
226
- !(value =~ /\A0+[0-7]+\Z/).nil?
224
+ value.is_a?(String) && (value =~ /\A0+[0-7]+\Z/)
227
225
  end
228
226
 
229
227
  def boolean?(value)
@@ -288,25 +286,28 @@ RSpec::Matchers.define :cmp do |first_expected| # rubocop:disable Metrics/BlockL
288
286
  end
289
287
  end
290
288
 
289
+ def format_actual(actual)
290
+ actual = "0%o" % actual if octal?(@expected)
291
+ "\n%s\n got: %s\n\n(compared using `cmp` matcher)\n" % [format_expectation(false), actual]
292
+ end
293
+
291
294
  def format_expectation(negate)
292
- return "expected: " + @expected.inspect if @operation == :== && !negate
295
+ return "expected: %s" % [@expected] if @operation == :== && !negate
293
296
 
294
297
  negate_str = negate ? "not " : ""
295
- "expected it #{negate_str}to be #{@operation} #{@expected.inspect}"
298
+ "expected it %sto be %s %p" % [negate_str, @operation, @expected]
296
299
  end
297
300
 
298
301
  failure_message do |actual|
299
- actual = ("0" + actual.to_s(8)) if octal?(@expected)
300
- "\n" + format_expectation(false) + "\n got: #{actual.inspect}\n\n(compared using `cmp` matcher)\n"
302
+ format_actual actual
301
303
  end
302
304
 
303
305
  failure_message_when_negated do |actual|
304
- actual = ("0" + actual.to_s(8)).inspect if octal?(@expected)
305
- "\n" + format_expectation(true) + "\n got: #{actual.inspect}\n\n(compared using `cmp` matcher)\n"
306
+ format_actual actual
306
307
  end
307
308
 
308
309
  description do
309
- "cmp #{@operation} #{@expected.inspect}"
310
+ "cmp %s %p" % [@operation, @expected]
310
311
  end
311
312
  end
312
313
 
@@ -8,5 +8,8 @@ module InspecPlugins
8
8
  InspecPlugins::Compliance::CLI
9
9
  end
10
10
  end
11
+
12
+ autoload :Configuration, "plugins/inspec-compliance/lib/inspec-compliance/configuration"
13
+ autoload :API, "plugins/inspec-compliance/lib/inspec-compliance/api"
11
14
  end
12
15
  end
@@ -9,7 +9,7 @@ module InspecPlugins
9
9
  class Profile
10
10
  include Inspec::Dist
11
11
 
12
- attr_reader :logger
12
+ attr_reader :logger, :options
13
13
  def initialize(path, options = {})
14
14
  @path = path
15
15
  @options = options
@@ -149,7 +149,7 @@ module InspecPlugins
149
149
  "vendor process.")
150
150
  else
151
151
  logger.debug("Vendoring the profile's dependencies...")
152
- profile_vendor.vendor!
152
+ profile_vendor.vendor!(options)
153
153
 
154
154
  logger.debug("Ensuring all vendored content has read permissions...")
155
155
  profile_vendor.make_readable
@@ -0,0 +1,192 @@
1
+ # Example InSpec Profile For AWS
2
+
3
+ This example shows the implementation of an InSpec profile for AWS.
4
+
5
+ ## Create a profile
6
+
7
+ ```
8
+ $ inspec init profile --platform aws my-profile
9
+
10
+ ─────────────────────────── InSpec Code Generator ───────────────────────────
11
+
12
+ Creating new profile at /Users/spaterson/my-profile
13
+ • Creating directory libraries
14
+ • Creating file README.md
15
+ • Creating directory controls
16
+ • Creating file controls/example.rb
17
+ • Creating file inspec.yml
18
+ • Creating file attributes.yml
19
+ • Creating file libraries/.gitkeep
20
+
21
+ ```
22
+
23
+ ## Optionally update `attributes.yml` to point to your custom VPC
24
+
25
+ ```
26
+ aws_vpc_id: 'custom-vpc-id'
27
+ ```
28
+
29
+ The related control will simply be skipped if this is not provided. See the [InSpec DSL documentation](https://www.inspec.io/docs/reference/dsl_inspec/) for more details on conditional execution using `only_if`.
30
+
31
+ ## Run the tests
32
+
33
+ ### With a VPC Identifier
34
+
35
+ With a supplied VPC identifier in `attributes.yml` both of the example controls will run. The 'aws-single-vpc-exists-check' control will only check for a VPC identifier in the currently configured AWS SDK region e.g. `eu-west-2` in the below:
36
+
37
+ ```
38
+ $ cd my-profile/
39
+ $ inspec exec . -t aws:// --attrs attributes.yml
40
+
41
+ Profile: AWS InSpec Profile (my-profile)
42
+ Version: 0.1.0
43
+ Target: aws://eu-west-2
44
+
45
+ ✔ aws-single-vpc-exists-check: Check to see if custom VPC exists.
46
+ ✔ VPC vpc-1ea06476 should exist
47
+ ✔ aws-vpcs-check: Check in all the VPCs for default sg not allowing 22 inwards
48
+ ✔ EC2 Security Group sg-067cd21e928c3a2f1 should allow in {:port=>22}
49
+ ✔ EC2 Security Group sg-9bb3b9f3 should allow in {:port=>22}
50
+ ✔ aws-vpcs-multi-region-status-check: Check AWS VPCs in all regions have status "available"
51
+ ✔ VPC vpc-6458b70d in eu-north-1 should exist
52
+ ✔ VPC vpc-6458b70d in eu-north-1 should be available
53
+ ✔ VPC vpc-8d1390e5 in ap-south-1 should exist
54
+ ✔ VPC vpc-8d1390e5 in ap-south-1 should be available
55
+ ✔ VPC vpc-07a71d6e in eu-west-3 should exist
56
+ ✔ VPC vpc-07a71d6e in eu-west-3 should be available
57
+ ✔ VPC vpc-021630e2e767412b5 in eu-west-2 should exist
58
+ ✔ VPC vpc-021630e2e767412b5 in eu-west-2 should be available
59
+ ✔ VPC vpc-1ea06476 in eu-west-2 should exist
60
+ ✔ VPC vpc-1ea06476 in eu-west-2 should be available
61
+ ✔ VPC vpc-169dee70 in eu-west-1 should exist
62
+ ✔ VPC vpc-169dee70 in eu-west-1 should be available
63
+ ✔ VPC vpc-01ac7ba0be447a1c4 in eu-west-1 should exist
64
+ ✔ VPC vpc-01ac7ba0be447a1c4 in eu-west-1 should be available
65
+ ✔ VPC vpc-09ff83d71da9d2b6e in eu-west-1 should exist
66
+ ✔ VPC vpc-09ff83d71da9d2b6e in eu-west-1 should be available
67
+ ✔ VPC vpc-0ebccac2337a90f13 in eu-west-1 should exist
68
+ ✔ VPC vpc-0ebccac2337a90f13 in eu-west-1 should be available
69
+ ✔ VPC vpc-c2a53da4 in eu-west-1 should exist
70
+ ✔ VPC vpc-c2a53da4 in eu-west-1 should be available
71
+ ✔ VPC vpc-4fb3f127 in ap-northeast-2 should exist
72
+ ✔ VPC vpc-4fb3f127 in ap-northeast-2 should be available
73
+ ✔ VPC vpc-0804856f in ap-northeast-1 should exist
74
+ ✔ VPC vpc-0804856f in ap-northeast-1 should be available
75
+ ✔ VPC vpc-ccb917ab in sa-east-1 should exist
76
+ ✔ VPC vpc-ccb917ab in sa-east-1 should be available
77
+ ✔ VPC vpc-0afcc60c70a30a615 in ca-central-1 should exist
78
+ ✔ VPC vpc-0afcc60c70a30a615 in ca-central-1 should be available
79
+ ✔ VPC vpc-20a25048 in ca-central-1 should exist
80
+ ✔ VPC vpc-20a25048 in ca-central-1 should be available
81
+ ✔ VPC vpc-5896143f in ap-southeast-1 should exist
82
+ ✔ VPC vpc-5896143f in ap-southeast-1 should be available
83
+ ✔ VPC vpc-47972220 in ap-southeast-2 should exist
84
+ ✔ VPC vpc-47972220 in ap-southeast-2 should be available
85
+ ✔ VPC vpc-071b6f0c69d1d0311 in eu-central-1 should exist
86
+ ✔ VPC vpc-071b6f0c69d1d0311 in eu-central-1 should be available
87
+ ✔ VPC vpc-807dfdeb in eu-central-1 should exist
88
+ ✔ VPC vpc-807dfdeb in eu-central-1 should be available
89
+ ✔ VPC vpc-0be54a71311bc362d in eu-central-1 should exist
90
+ ✔ VPC vpc-0be54a71311bc362d in eu-central-1 should be available
91
+ ✔ VPC vpc-f060cd8b in us-east-1 should exist
92
+ ✔ VPC vpc-f060cd8b in us-east-1 should be available
93
+ ✔ VPC vpc-0c3a7e116c58d714b in us-east-1 should exist
94
+ ✔ VPC vpc-0c3a7e116c58d714b in us-east-1 should be available
95
+ ✔ VPC vpc-047bff6c in us-east-2 should exist
96
+ ✔ VPC vpc-047bff6c in us-east-2 should be available
97
+ ✔ VPC vpc-93dd6ef4 in us-west-1 should exist
98
+ ✔ VPC vpc-93dd6ef4 in us-west-1 should be available
99
+ ✔ VPC vpc-2c0a6a55 in us-west-2 should exist
100
+ ✔ VPC vpc-2c0a6a55 in us-west-2 should be available
101
+
102
+
103
+ Profile: Amazon Web Services Resource Pack (inspec-aws)
104
+ Version: 0.1.0
105
+ Target: aws://eu-west-2
106
+
107
+ No tests executed.
108
+
109
+ Profile Summary: 3 successful controls, 0 control failures, 0 controls skipped
110
+ Test Summary: 53 successful, 0 failures, 0 skipped
111
+ ```
112
+
113
+
114
+ ### Without Supplying a VPC Identifier
115
+
116
+ If no VPC identifier is supplied, the 'aws-single-vpc-exists-check' control is skipped and the other control runs. The `attributes.yml` file does not have to be specified to InSpec in this case.
117
+
118
+ ```
119
+ $ cd my-profile/
120
+ $ inspec exec . -t aws://
121
+
122
+ Profile: AWS InSpec Profile (my-profile)
123
+ Version: 0.1.0
124
+ Target: aws://eu-west-2
125
+
126
+ ↺ aws-single-vpc-exists-check: Check to see if custom VPC exists.
127
+ ↺ Skipped control due to only_if condition.
128
+ ✔ aws-vpcs-check: Check in all the VPCs for default sg not allowing 22 inwards
129
+ ✔ EC2 Security Group sg-067cd21e928c3a2f1 should allow in {:port=>22}
130
+ ✔ EC2 Security Group sg-9bb3b9f3 should allow in {:port=>22}
131
+ ✔ aws-vpcs-multi-region-status-check: Check AWS VPCs in all regions have status "available"
132
+ ✔ VPC vpc-6458b70d in eu-north-1 should exist
133
+ ✔ VPC vpc-6458b70d in eu-north-1 should be available
134
+ ✔ VPC vpc-8d1390e5 in ap-south-1 should exist
135
+ ✔ VPC vpc-8d1390e5 in ap-south-1 should be available
136
+ ✔ VPC vpc-07a71d6e in eu-west-3 should exist
137
+ ✔ VPC vpc-07a71d6e in eu-west-3 should be available
138
+ ✔ VPC vpc-021630e2e767412b5 in eu-west-2 should exist
139
+ ✔ VPC vpc-021630e2e767412b5 in eu-west-2 should be available
140
+ ✔ VPC vpc-1ea06476 in eu-west-2 should exist
141
+ ✔ VPC vpc-1ea06476 in eu-west-2 should be available
142
+ ✔ VPC vpc-169dee70 in eu-west-1 should exist
143
+ ✔ VPC vpc-169dee70 in eu-west-1 should be available
144
+ ✔ VPC vpc-01ac7ba0be447a1c4 in eu-west-1 should exist
145
+ ✔ VPC vpc-01ac7ba0be447a1c4 in eu-west-1 should be available
146
+ ✔ VPC vpc-09ff83d71da9d2b6e in eu-west-1 should exist
147
+ ✔ VPC vpc-09ff83d71da9d2b6e in eu-west-1 should be available
148
+ ✔ VPC vpc-0ebccac2337a90f13 in eu-west-1 should exist
149
+ ✔ VPC vpc-0ebccac2337a90f13 in eu-west-1 should be available
150
+ ✔ VPC vpc-c2a53da4 in eu-west-1 should exist
151
+ ✔ VPC vpc-c2a53da4 in eu-west-1 should be available
152
+ ✔ VPC vpc-4fb3f127 in ap-northeast-2 should exist
153
+ ✔ VPC vpc-4fb3f127 in ap-northeast-2 should be available
154
+ ✔ VPC vpc-0804856f in ap-northeast-1 should exist
155
+ ✔ VPC vpc-0804856f in ap-northeast-1 should be available
156
+ ✔ VPC vpc-ccb917ab in sa-east-1 should exist
157
+ ✔ VPC vpc-ccb917ab in sa-east-1 should be available
158
+ ✔ VPC vpc-0afcc60c70a30a615 in ca-central-1 should exist
159
+ ✔ VPC vpc-0afcc60c70a30a615 in ca-central-1 should be available
160
+ ✔ VPC vpc-20a25048 in ca-central-1 should exist
161
+ ✔ VPC vpc-20a25048 in ca-central-1 should be available
162
+ ✔ VPC vpc-5896143f in ap-southeast-1 should exist
163
+ ✔ VPC vpc-5896143f in ap-southeast-1 should be available
164
+ ✔ VPC vpc-47972220 in ap-southeast-2 should exist
165
+ ✔ VPC vpc-47972220 in ap-southeast-2 should be available
166
+ ✔ VPC vpc-071b6f0c69d1d0311 in eu-central-1 should exist
167
+ ✔ VPC vpc-071b6f0c69d1d0311 in eu-central-1 should be available
168
+ ✔ VPC vpc-807dfdeb in eu-central-1 should exist
169
+ ✔ VPC vpc-807dfdeb in eu-central-1 should be available
170
+ ✔ VPC vpc-0be54a71311bc362d in eu-central-1 should exist
171
+ ✔ VPC vpc-0be54a71311bc362d in eu-central-1 should be available
172
+ ✔ VPC vpc-f060cd8b in us-east-1 should exist
173
+ ✔ VPC vpc-f060cd8b in us-east-1 should be available
174
+ ✔ VPC vpc-0c3a7e116c58d714b in us-east-1 should exist
175
+ ✔ VPC vpc-0c3a7e116c58d714b in us-east-1 should be available
176
+ ✔ VPC vpc-047bff6c in us-east-2 should exist
177
+ ✔ VPC vpc-047bff6c in us-east-2 should be available
178
+ ✔ VPC vpc-93dd6ef4 in us-west-1 should exist
179
+ ✔ VPC vpc-93dd6ef4 in us-west-1 should be available
180
+ ✔ VPC vpc-2c0a6a55 in us-west-2 should exist
181
+ ✔ VPC vpc-2c0a6a55 in us-west-2 should be available
182
+
183
+
184
+ Profile: Amazon Web Services Resource Pack (inspec-aws)
185
+ Version: 0.1.0
186
+ Target: aws://eu-west-2
187
+
188
+ No tests executed.
189
+
190
+ Profile Summary: 2 successful controls, 0 control failures, 1 control skipped
191
+ Test Summary: 52 successful, 0 failures, 1 skipped
192
+ ```
@@ -0,0 +1,2 @@
1
+ # Below is to be uncommented and set with your AWS Custom VPC ID:
2
+ # aws_vpc_id: 'vpc-xxxxxxx'
@@ -0,0 +1,39 @@
1
+ # copyright: 2018, The Authors
2
+
3
+ title "Sample Section"
4
+
5
+ aws_vpc_id = attribute("aws_vpc_id", default: "", description: "Optional AWS VPC identifier.")
6
+
7
+ # You add controls here
8
+ control "aws-single-vpc-exists-check" do # A unique ID for this control.
9
+ only_if { aws_vpc_id != "" } # Only run this control if the `aws_vpc_id` attribute is provided.
10
+ impact 1.0 # The criticality, if this control fails.
11
+ title "Check to see if custom VPC exists." # A human-readable title.
12
+ describe aws_vpc(aws_vpc_id) do # The test itself.
13
+ it { should exist }
14
+ end
15
+ end
16
+
17
+ # Plural resources can be inspected to check for specific resource details.
18
+ control "aws-vpcs-check" do
19
+ impact 1.0
20
+ title "Check in all the VPCs for default sg not allowing 22 inwards"
21
+ aws_vpcs.vpc_ids.each do |vpc_id|
22
+ describe aws_security_group(vpc_id: vpc_id, group_name: "default") do
23
+ it { should allow_in(port: 22) }
24
+ end
25
+ end
26
+ end
27
+
28
+ control "aws-vpcs-multi-region-status-check" do # A unique ID for this control.
29
+ impact 1.0 # The criticality, if this control fails.
30
+ title 'Check AWS VPCs in all regions have status "available"' # A human-readable title.
31
+ aws_regions.region_names.each do |region| # Loop over all available AWS regions
32
+ aws_vpcs(aws_region: region).vpc_ids.each do |vpc| # Find all VPCs in a single AWS region
33
+ describe aws_vpc(aws_region: region, vpc_id: vpc) do # The test itself.
34
+ it { should exist } # Confirms AWS VPC exists
35
+ it { should be_available } # Confirms AWS VPC has status "available"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ name: <%= name %>
2
+ title: AWS InSpec Profile
3
+ maintainer: The Authors
4
+ copyright: The Authors
5
+ copyright_email: you@example.com
6
+ license: Apache-2.0
7
+ summary: An InSpec Compliance Profile For AWS
8
+ version: 0.1.0
9
+ inspec_version: '~> 4'
10
+ attributes:
11
+ - name: aws_vpc_id
12
+ required: false
13
+ # Below is deliberately left as a default empty string to allow the profile to run when this is not provided.
14
+ # Please see the README for more details.
15
+ default: ''
16
+ description: 'Optional Custom AWS VPC Id'
17
+ type: string
18
+ depends:
19
+ - name: inspec-aws
20
+ url: https://github.com/inspec/inspec-aws/archive/master.tar.gz
21
+ supports:
22
+ - platform: aws
@@ -0,0 +1,56 @@
1
+ # Example InSpec Profile For Azure
2
+
3
+ This example shows the implementation of an InSpec profile for Azure. See [https://github.com/inspec/inspec-azure](https://github.com/inspec/inspec-azure) for details on how to configure credentials for your subscription.
4
+
5
+ ## Create a profile
6
+
7
+ ```
8
+ $ inspec init profile --platform azure my-profile
9
+
10
+ ─────────────────────────── InSpec Code Generator ───────────────────────────
11
+
12
+ Creating new profile at /Users/spaterson/my-profile
13
+ • Creating directory libraries
14
+ • Creating file README.md
15
+ • Creating directory controls
16
+ • Creating file controls/example.rb
17
+ • Creating file inspec.yml
18
+ • Creating file libraries/.gitkeep
19
+
20
+ ```
21
+
22
+ ## Run the tests
23
+
24
+ ```
25
+ $ cd my-profile/
26
+ $ inspec exec . -t azure://
27
+
28
+
29
+ Profile: Azure InSpec Profile (my-profile)
30
+ Version: 0.1.0
31
+ Target: azure://12345abc-987d-654e-fg21-abcdef23324r
32
+
33
+ × azure-virtual-machines-exist-check: Check resource groups to see if any VMs exist. (4 failed)
34
+ × Azure Virtual Machines should exist
35
+ expected Azure Virtual Machines to exist
36
+ × Azure Virtual Machines should exist
37
+ expected Azure Virtual Machines to exist
38
+ × Azure Virtual Machines should exist
39
+ expected Azure Virtual Machines to exist
40
+ × Azure Virtual Machines should exist
41
+ expected Azure Virtual Machines to exist
42
+ ✔ Azure Virtual Machines should exist
43
+ ✔ Azure Virtual Machines should exist
44
+ ✔ Azure Virtual Machines should exist
45
+
46
+
47
+ Profile: Azure Resource Pack (inspec-azure)
48
+ Version: 1.2.0
49
+ Target: azure://12345abc-987d-654e-fg21-abcdef23324r
50
+
51
+ No tests executed.
52
+
53
+ Profile Summary: 0 successful controls, 1 control failure, 0 controls skipped
54
+ Test Summary: 3 successful, 4 failures, 0 skipped
55
+
56
+ ```
@@ -0,0 +1,14 @@
1
+ # copyright: 2018, The Authors
2
+
3
+ title "Sample Section"
4
+
5
+ # you add controls here
6
+ control "azure-virtual-machines-exist-check" do # A unique ID for this control.
7
+ impact 1.0 # The criticality, if this control fails.
8
+ title "Check resource groups to see if any VMs exist." # A human-readable title
9
+ azurerm_resource_groups.names.each do |resource_group_name| # Plural resources can be leveraged to loop across many resources
10
+ describe azurerm_virtual_machines(resource_group: resource_group_name) do
11
+ it { should exist } # The test itself.
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ name: <%= name %>
2
+ title: Azure InSpec Profile
3
+ maintainer: The Authors
4
+ copyright: The Authors
5
+ copyright_email: you@example.com
6
+ license: Apache-2.0
7
+ summary: An InSpec Compliance Profile For Azure
8
+ version: 0.1.0
9
+ inspec_version: '>= 2.2.7'
10
+ depends:
11
+ - name: inspec-azure
12
+ url: https://github.com/inspec/inspec-azure/archive/master.tar.gz
13
+ supports:
14
+ - platform: azure
@@ -0,0 +1,66 @@
1
+ # Example InSpec Profile For GCP
2
+
3
+ This example shows the implementation of an InSpec profile for GCP that depends on the [InSpec GCP Resource Pack](https://github.com/inspec/inspec-gcp). See the [README](https://github.com/inspec/inspec-gcp) for instructions on setting up appropriate GCP credentials.
4
+
5
+ ## Create a profile
6
+
7
+ ```
8
+ $ inspec init profile --platform gcp my-profile
9
+ Create new profile at /Users/spaterson/my-profile
10
+ * Create directory libraries
11
+ * Create file README.md
12
+ * Create directory controls
13
+ * Create file controls/example.rb
14
+ * Create file inspec.yml
15
+ * Create file attributes.yml
16
+ * Create file libraries/.gitkeep
17
+
18
+ ```
19
+
20
+ ## Update `attributes.yml` to point to your project
21
+
22
+ ```
23
+ gcp_project_id: 'my-gcp-project'
24
+ ```
25
+
26
+ ## Run the tests
27
+
28
+ ```
29
+ $ cd gcp-profile/
30
+ $ inspec exec . -t gcp:// --attrs attributes.yml
31
+
32
+ Profile: GCP InSpec Profile (my-profile)
33
+ Version: 0.1.0
34
+ Target: gcp://local-service-account@my-gcp-project.iam.gserviceaccount.com
35
+
36
+ ✔ gcp-single-region-1.0: Ensure single region has the correct properties.
37
+ ✔ Region europe-west2 zone_names should include "europe-west2-a"
38
+ ✔ gcp-regions-loop-1.0: Ensure regions have the correct properties in bulk.
39
+ ✔ Region asia-east1 should be up
40
+ ✔ Region asia-northeast1 should be up
41
+ ✔ Region asia-south1 should be up
42
+ ✔ Region asia-southeast1 should be up
43
+ ✔ Region australia-southeast1 should be up
44
+ ✔ Region europe-north1 should be up
45
+ ✔ Region europe-west1 should be up
46
+ ✔ Region europe-west2 should be up
47
+ ✔ Region europe-west3 should be up
48
+ ✔ Region europe-west4 should be up
49
+ ✔ Region northamerica-northeast1 should be up
50
+ ✔ Region southamerica-east1 should be up
51
+ ✔ Region us-central1 should be up
52
+ ✔ Region us-east1 should be up
53
+ ✔ Region us-east4 should be up
54
+ ✔ Region us-west1 should be up
55
+ ✔ Region us-west2 should be up
56
+
57
+
58
+ Profile: Google Cloud Platform Resource Pack (inspec-gcp)
59
+ Version: 0.5.0
60
+ Target: gcp://local-service-account@my-gcp-project.iam.gserviceaccount.com
61
+
62
+ No tests executed.
63
+
64
+ Profile Summary: 2 successful controls, 0 control failures, 0 controls skipped
65
+ Test Summary: 18 successful, 0 failures, 0 skipped
66
+ ```