inspec 1.17.0 → 1.18.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
  SHA1:
3
- metadata.gz: 2c165a6b8a6e0ec2ed55a4038e82a3bac56ab80b
4
- data.tar.gz: 1a806307865e65cbd266caf0a8f3d0abe2b58257
3
+ metadata.gz: 9379e53ddea254aaf25d826f7f0c6ca5dc8a0f8f
4
+ data.tar.gz: 34abc2d25c9ad4531c8f972f929f2f9c52b153fa
5
5
  SHA512:
6
- metadata.gz: 6b0ed9d55cc66ed12aaa28a51560cd3238970f215d764c56c96a75b329a41d9a05edc6bb2bece49a353b99b011b3168c76067599309d632f7d51b558a8033baa
7
- data.tar.gz: 991eb89677b038a066fac3162685db305f807d1dc67cef40742ec8d778cef8ab6c2cce3c94411c9c6265c46744be37d5b2d09b9edfaf2ecec939fa4885c742c6
6
+ metadata.gz: e79a10bb506d7b6b2f062800a8f70e27456c18dd6c056b5da0c613196ad19b577d00d8836486314fd2773e21740e9507e0479d6b49ea66fabd1e55004ce227b8
7
+ data.tar.gz: ba859c6e85d244fabb94e3ecb6ec8b9eb83e5de1951c4b0c5c2e04fc06aeddf3fcd4c1b4ed0501a4b02365f181e63456644689f3cf08eca0803cf958065ace20
data/CHANGELOG.md CHANGED
@@ -1,24 +1,65 @@
1
1
  # Change Log
2
2
 
3
- ## [1.17.0](https://github.com/chef/inspec/tree/v1.17.0) (2017-03-21)
3
+ ## [v1.18.0](https://github.com/chef/inspec/tree/v1.18.0) (2017-03-30)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.17.0...v1.18.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Requesting x509\_certificate and x509\_private\_key [\#1459](https://github.com/chef/inspec/issues/1459)
9
+ - generate profile CLI command [\#410](https://github.com/chef/inspec/issues/410)
10
+
11
+ **Fixed bugs:**
12
+
13
+ - YAML file extensions support only \(.yml\) [\#1569](https://github.com/chef/inspec/issues/1569)
14
+ - yum.repo with should\_not exist fails with NoMethodError: undefined method `\[\]' for nil:NilClass [\#1553](https://github.com/chef/inspec/issues/1553)
15
+
16
+ **Closed issues:**
17
+
18
+ - port should be\_listening busted in 1.17.0? [\#1602](https://github.com/chef/inspec/issues/1602)
19
+ - inspec fails to install on centos 7 [\#1597](https://github.com/chef/inspec/issues/1597)
20
+ - inspec outputs full hash when testing ini style file option with \[header\] [\#1541](https://github.com/chef/inspec/issues/1541)
21
+ - Add JSON Schema validation [\#884](https://github.com/chef/inspec/issues/884)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - Fix port resource for invalid IP address in netstat output [\#1603](https://github.com/chef/inspec/pull/1603) ([adamleff](https://github.com/adamleff))
26
+ - Remove errant puts in inspec habitat CLI command [\#1601](https://github.com/chef/inspec/pull/1601) ([adamleff](https://github.com/adamleff))
27
+ - Add docs for habitat CLI commands [\#1600](https://github.com/chef/inspec/pull/1600) ([adamleff](https://github.com/adamleff))
28
+ - Require Ruby 2.1 [\#1599](https://github.com/chef/inspec/pull/1599) ([adamleff](https://github.com/adamleff))
29
+ - Extend `gem` to take an optional `gem\_binary` [\#1596](https://github.com/chef/inspec/pull/1596) ([nvwls](https://github.com/nvwls))
30
+ - Feature/fix ability to pass in supermarket url [\#1595](https://github.com/chef/inspec/pull/1595) ([rylarson](https://github.com/rylarson))
31
+ - Support vendored profiles in Habitat-packaged profiles [\#1594](https://github.com/chef/inspec/pull/1594) ([adamleff](https://github.com/adamleff))
32
+ - Yum resource fix for non-existent repos and repo info [\#1593](https://github.com/chef/inspec/pull/1593) ([adamleff](https://github.com/adamleff))
33
+ - Fixing www/docs rake tasks [\#1591](https://github.com/chef/inspec/pull/1591) ([adamleff](https://github.com/adamleff))
34
+ - add tag object [\#1590](https://github.com/chef/inspec/pull/1590) ([chris-rock](https://github.com/chris-rock))
35
+ - Support YAML attributes files ending in .yaml [\#1589](https://github.com/chef/inspec/pull/1589) ([mr-exz](https://github.com/mr-exz))
36
+ - Fix Habitat plan for nokogiri support [\#1587](https://github.com/chef/inspec/pull/1587) ([adamleff](https://github.com/adamleff))
37
+ - x509\_certificate and key\_rsa resource [\#1567](https://github.com/chef/inspec/pull/1567) ([chris-rock](https://github.com/chris-rock))
38
+ - implement JSON schema for `inspec exec` json outputs [\#1564](https://github.com/chef/inspec/pull/1564) ([arlimus](https://github.com/arlimus))
39
+ - Provide a method-based accessor for SimpleConfig hashes [\#1544](https://github.com/chef/inspec/pull/1544) ([adamleff](https://github.com/adamleff))
40
+
41
+ ## [v1.17.0](https://github.com/chef/inspec/tree/v1.17.0) (2017-03-21)
4
42
  [Full Changelog](https://github.com/chef/inspec/compare/v1.16.1...v1.17.0)
5
43
 
6
44
  **Implemented enhancements:**
7
45
 
46
+ - Calendar for Line Chart [\#1558](https://github.com/chef/inspec/issues/1558)
8
47
  - Need better error message for improper inspec.yml formatting [\#1549](https://github.com/chef/inspec/issues/1549)
9
48
 
10
49
  **Fixed bugs:**
11
50
 
12
51
  - cannot load such file -- nokogiri [\#1562](https://github.com/chef/inspec/issues/1562)
13
52
  - Failure to parse tcp6 URI [\#1521](https://github.com/chef/inspec/issues/1521)
14
- - json resource array index access not working [\#1560](https://github.com/chef/inspec/issues/1560)
15
53
 
16
54
  **Closed issues:**
17
55
 
56
+ - json resource array index access not working [\#1560](https://github.com/chef/inspec/issues/1560)
18
57
  - Crontab regex matching [\#1526](https://github.com/chef/inspec/issues/1526)
19
58
 
20
59
  **Merged pull requests:**
21
60
 
61
+ - Move simulator gems to www [\#1585](https://github.com/chef/inspec/pull/1585) ([adamleff](https://github.com/adamleff))
62
+ - release 1.17.0 [\#1583](https://github.com/chef/inspec/pull/1583) ([adamleff](https://github.com/adamleff))
22
63
  - Fix omnibus configuration [\#1579](https://github.com/chef/inspec/pull/1579) ([adamleff](https://github.com/adamleff))
23
64
  - moving the nokogiri reference into the gemspec file [\#1576](https://github.com/chef/inspec/pull/1576) ([jkerry](https://github.com/jkerry))
24
65
  - Hide Event Feature on Homepage [\#1563](https://github.com/chef/inspec/pull/1563) ([hannah-radish](https://github.com/hannah-radish))
data/Gemfile CHANGED
@@ -19,6 +19,7 @@ group :test do
19
19
  gem 'mocha', '~> 1.1'
20
20
  gem 'ruby-progressbar', '~> 1.8'
21
21
  gem 'webmock', '~> 2.3.2'
22
+ gem 'jsonschema', '~> 2.0.2'
22
23
  end
23
24
 
24
25
  group :integration do
data/Rakefile CHANGED
@@ -7,7 +7,6 @@ require 'rake/testtask'
7
7
  require 'rubocop/rake_task'
8
8
  require_relative 'tasks/docs'
9
9
  require_relative 'tasks/maintainers'
10
- require_relative 'tasks/www'
11
10
 
12
11
  # Rubocop
13
12
  desc 'Run Rubocop lint checks'
@@ -186,3 +185,20 @@ task :release_habitat do
186
185
  puts "--> #{cmd}"
187
186
  sh('sh', '-c', cmd)
188
187
  end
188
+
189
+ desc 'Release the website [deprecated]'
190
+ task :www do
191
+ puts 'The Rake tasks for releasing the website are now in the www/ directory.'
192
+ puts 'Run `cd www` and then `rake --tasks` for a list of the www-related tasks available.'
193
+ exit(1)
194
+ end
195
+
196
+ namespace :www do
197
+ desc 'Release the website [deprecated]'
198
+ task :release do
199
+ puts 'The Rake tasks for releasing the website are now in the www/ directory.'
200
+ puts 'Run `cd www` and then `rake --tasks` for a list of the www-related tasks available.'
201
+ exit(1)
202
+ end
203
+ end
204
+
data/docs/habitat.md ADDED
@@ -0,0 +1,192 @@
1
+ ---
2
+ title: InSpec Integration with Habitat
3
+ ---
4
+
5
+ # Habitat Integration
6
+
7
+ InSpec provides an easy method to create an executable Habitat package for an InSpec profile. When run via the Habitat Supervisor, the package will run InSpec with your profile and write out its findings to a JSON file. This provides the ability to ship your compliance controls alongside your Habitat-packaged application and continuously run InSpec, providing you *Continuous Compliance.*
8
+
9
+ ## What is Habitat?
10
+
11
+ Habitat by Chef is our new Application Automation tool that aims to make it easy, safe, and fast to build, deploy, and manage applications. From build dependencies, runtime dependencies, dynamic configuration, and service discovery (just to name a few), Habitat packages the automation with the application instead of relying on an underlying platform.
12
+
13
+ To learn more about Habitat and try our demos and tutorials, visit [https://www.habitat.sh](https://www.habitat.sh).
14
+
15
+ ## Using the Habitat Integration
16
+
17
+ After creating a Habitat package for an InSpec profile (see CLI commands below) and uploading the package to a Habitat Depot or manually distributing to a host, start the Habitat Supervisor with your package:
18
+
19
+ ```bash
20
+ hab start adamleff/inspec-profile-frontend1
21
+ ```
22
+
23
+ The Habitat Supervisor will install InSpec and execute your profile in a loop. By default, the loop runs every 300 seconds but can be changed via the `sleep_time` configuration value:
24
+
25
+ ```bash
26
+ HAB_INSPEC_PROFILE_FRONTEND1="sleep_time = 60" hab start adamleff/inspec-profile-frontend1
27
+ ```
28
+
29
+ The Habitat Supervisor will display output like this:
30
+
31
+ ```
32
+ hab start adamleff/inspec-profile-frontend1
33
+ ∵ Missing package for core/hab-sup/0.17.0
34
+ » Installing core/hab-sup/0.17.0
35
+ ↓ Downloading core/hab-sup/0.17.0/20170214235450
36
+ 1.68 MB / 1.68 MB - [=========================================================================] 100.00 % 7.43 MB/s
37
+
38
+ ... more Habitat output here ...
39
+
40
+ hab-sup(MN): Starting adamleff/inspec-profile-frontend1/0.1.0/20170328173005
41
+ hab-sup(CS): adamleff/inspec-profile-frontend1/0.1.0/20170328173005 is not installed
42
+ ↓ Downloading adamleff-20160617201047 public origin key
43
+ 79 B / 79 B | [===============================================================================] 100.00 % 2.64 MB/s
44
+ ☑ Cached adamleff-20160617201047 public origin key
45
+ ↓ Downloading chef/inspec/1.17.0/20170321214949
46
+ 16.93 MB / 16.93 MB / [======================================================================] 100.00 % 10.49 MB/s
47
+
48
+ ... more Habitat output here ...
49
+
50
+ ★ Install of adamleff/inspec-profile-frontend1/0.1.0/20170328173005 complete with 9 new packages installed.
51
+ hab-sup(MR): Butterfly Member ID d9bd761e18c144469d755b1b97406eb2
52
+ hab-sup(MR): Starting butterfly on 0.0.0.0:9638
53
+ hab-sup(MR): Starting http-gateway on 0.0.0.0:9631
54
+ inspec-profile-frontend1.default(SR): Initializing
55
+ inspec-profile-frontend1.default(SV): Starting process as user=hab, group=hab
56
+ inspec-profile-frontend1.default(O): Executing InSpec for adamleff/inspec-profile-frontend1
57
+ inspec-profile-frontend1.default(O): InSpec run completed successfully.
58
+ inspec-profile-frontend1.default(O): sleeping for 300 seconds
59
+ ```
60
+
61
+ The above sample output shows the supervisor starting, downloading the necessary dependencies for the supervisor and the InSpec profile, and then shows the supervisor running InSpec successfully.
62
+
63
+ InSpec will write a JSON file in the `${svc_var_path}/inspec_results` directory containing the results of the last InSpec run. For example, for the `adamleff/inspec-profile-frontend1` package, the InSpec results will be at:
64
+
65
+ ```
66
+ /hab/svc/inspec-profile-frontend1/var/inspec_results/inspec-profile-frontend1.json
67
+ ```
68
+
69
+ ## InSpec Habitat CLI Commands
70
+
71
+ ### inspec habitat profile create
72
+
73
+ Create a Habitat package for an InSpec profile. InSpec will validate the profile, fetch and vendor any dependencies (if necessary), and build the Habitat package with a dependency on the latest InSpec. The resulting package will be saved to the current working directory.
74
+
75
+ The package file will be named:
76
+
77
+ ```
78
+ HABITAT_ORIGIN-inspec-profile-PROFILE_NAME-PROFILE_VERSION-BUILD_ID-x86_64-linux.hart
79
+ ```
80
+
81
+ For example:
82
+
83
+ ```
84
+ adamleff-inspec-profile-frontend1-0.1.0-20170328173005-x86_64-linux.hart
85
+ ```
86
+
87
+ #### Syntax
88
+
89
+ ```bash
90
+ inspec habitat profile create PROFILE_DIRECTORY
91
+ ```
92
+
93
+ Example:
94
+
95
+ ```bash
96
+ inspec habitat profile create ~/profiles/frontend1
97
+ ```
98
+
99
+ ### inspec habitat profile create
100
+
101
+ Create a Habitat package for an InSpec profile. InSpec will validate the profile, fetch and vendor any dependencies (if necessary), and build the Habitat package with a dependency on the latest InSpec. The resulting package will be saved to the current working directory.
102
+
103
+ The package can then be manually uploaded to a Habitat Depot or manually distributed to a host and installed via `hab pkg install`.
104
+
105
+ The package file will be named:
106
+
107
+ ```
108
+ HABITAT_ORIGIN-inspec-profile-PROFILE_NAME-PROFILE_VERSION-BUILD_ID-x86_64-linux.hart
109
+ ```
110
+
111
+ For example:
112
+
113
+ ```
114
+ adamleff-inspec-profile-frontend1-0.1.0-20170328173005-x86_64-linux.hart
115
+ ```
116
+
117
+ #### Syntax
118
+
119
+ ```bash
120
+ inspec habitat profile create PROFILE_DIRECTORY
121
+ ```
122
+
123
+ #### Example
124
+
125
+ ```bash
126
+ inspec habitat profile create ~/profiles/frontend1
127
+ ```
128
+
129
+ #### Example Output
130
+
131
+ ```
132
+ $ habitat profile create ~/profiles/frontend1
133
+ [2017-03-28T13:29:32-04:00] INFO: Creating a Habitat artifact for profile: /Users/aleff/profiles/frontend1
134
+ [2017-03-28T13:29:32-04:00] INFO: Checking to see if Habitat is installed...
135
+ [2017-03-28T13:29:32-04:00] INFO: Copying profile contents to the work directory...
136
+ [2017-03-28T13:29:32-04:00] INFO: Generating Habitat plan at /var/folders/v5/z54gb76j2rs3wrn65hmtyf1r0000gp/T/inspec-habitat-exporter20170328-4932-kg2ltd/habitat/plan.sh...
137
+ [2017-03-28T13:29:32-04:00] INFO: Generating a Habitat run hook at /var/folders/v5/z54gb76j2rs3wrn65hmtyf1r0000gp/T/inspec-habitat-exporter20170328-4932-kg2ltd/habitat/hooks/run...
138
+ [2017-03-28T13:29:32-04:00] INFO: Generating Habitat's default.toml configuration...
139
+ [2017-03-28T13:29:32-04:00] INFO: Building our Habitat artifact...
140
+ hab-studio: Destroying Studio at /hab/studios/src (default)
141
+ hab-studio: Creating Studio at /hab/studios/src (default)
142
+ hab-studio: Importing adamleff secret origin key
143
+ » Importing origin key from standard input
144
+ ★ Imported secret origin key adamleff-20160617201047.
145
+ » Installing core/hab-backline
146
+ ↓ Downloading core/hab-backline/0.19.0/20170311034116
147
+ 2.17 KB / 2.17 KB / [=========================================================================] 100.00 % 4.33 MB/s
148
+
149
+ ... more Habitat output here...
150
+
151
+ [2017-03-28T13:30:18-04:00] INFO: Copying artifact to /Users/aleff...
152
+ ```
153
+
154
+ ### inspec habitat profile upload
155
+
156
+ Create and then upload a Habitat package for an InSpec profile. Like the `inspec habitat profile create` command, InSpec will validate the profile, fetch and vendor any dependencies (if necessary), and build the Habitat package with a dependency on the latest InSpec. However, instead of saving the package locally to the workstation, InSpec will upload it to the depot defined in the `HAB_DEPOT` environment variable. If `HAB_DEPOT` is not defined, the package will be uploaded to the public Habitat depot at [https://app.habitat.sh](https://app.habitat.sh).
157
+
158
+ #### Syntax
159
+
160
+ ```bash
161
+ inspec habitat profile upload PROFILE_DIRECTORY
162
+ ```
163
+
164
+ #### Example
165
+
166
+ ```bash
167
+ inspec habitat profile upload ~/profiles/frontend1
168
+ ```
169
+
170
+ #### Example Output
171
+ ```
172
+ [2017-03-28T13:29:32-04:00] INFO: Creating a Habitat artifact for profile: /Users/aleff/profiles/frontend1
173
+ [2017-03-28T13:29:32-04:00] INFO: Checking to see if Habitat is installed...
174
+ [2017-03-28T13:29:32-04:00] INFO: Copying profile contents to the work directory...
175
+ [2017-03-28T13:29:32-04:00] INFO: Generating Habitat plan at /var/folders/v5/z54gb76j2rs3wrn65hmtyf1r0000gp/T/inspec-habitat-exporter20170328-4932-kg2ltd/habitat/plan.sh...
176
+ [2017-03-28T13:29:32-04:00] INFO: Generating a Habitat run hook at /var/folders/v5/z54gb76j2rs3wrn65hmtyf1r0000gp/T/inspec-habitat-exporter20170328-4932-kg2ltd/habitat/hooks/run...
177
+ [2017-03-28T13:29:32-04:00] INFO: Generating Habitat's default.toml configuration...
178
+ [2017-03-28T13:29:32-04:00] INFO: Building our Habitat artifact...
179
+ hab-studio: Destroying Studio at /hab/studios/src (default)
180
+ hab-studio: Creating Studio at /hab/studios/src (default)
181
+ hab-studio: Importing adamleff secret origin key
182
+ » Importing origin key from standard input
183
+ ★ Imported secret origin key adamleff-20160617201047.
184
+ » Installing core/hab-backline
185
+ ↓ Downloading core/hab-backline/0.19.0/20170311034116
186
+ 2.17 KB / 2.17 KB / [=========================================================================] 100.00 % 4.33 MB/s
187
+
188
+ ... more Habitat output here...
189
+
190
+ [2017-03-28T13:30:18-04:00] INFO: Uploading the Habitat artifact to our Depot...
191
+ [2017-03-28T13:30:23-04:00] INFO: Upload complete!
192
+ ```
@@ -10,13 +10,14 @@ Use the `gem` InSpec audit resource to test if a global Gem package is installed
10
10
 
11
11
  A `gem` resource block declares a package and (optionally) a package version:
12
12
 
13
- describe gem('gem_package_name') do
13
+ describe gem('gem_package_name', 'gem_binary') do
14
14
  it { should be_installed }
15
15
  end
16
16
 
17
17
  where
18
18
 
19
19
  * `('gem_package_name')` must specify a Gem package, such as `'rubocop'`
20
+ * `('gem_binary')` can specify the path to a non-default gem binary, defaults to `'gem'`
20
21
  * `be_installed` is a valid matcher for this resource
21
22
 
22
23
  ## Matchers
@@ -71,3 +72,21 @@ The following examples show how to use this InSpec audit resource.
71
72
  describe gem('rubocop') do
72
73
  it { should_not be_installed }
73
74
  end
75
+
76
+ ### Verify that a gem package is installed in an omnibus environment
77
+
78
+ describe gem('pry', '/opt/ruby-2.3.1/embedded/bin/gem') do
79
+ it { should be_installed }
80
+ end
81
+
82
+ ### Verify that a gem package is installed in a chef omnibus environment
83
+
84
+ describe gem('chef-sugar', :chef) do
85
+ it { should be_installed }
86
+ end
87
+
88
+ ### Verify that a gem package is installed in a chef-server omnibus environment
89
+
90
+ describe gem('knife-backup', :chef_server) do
91
+ it { should be_installed }
92
+ end
@@ -0,0 +1,70 @@
1
+ ---
2
+ title: The key_rsa Resource
3
+ ---
4
+
5
+ # key_rsa
6
+
7
+ Use the `key_rsa` InSpec audit resource to test RSA public/private keypairs.
8
+
9
+ This resource is mainly useful when used in conjunction with the x509_certificate resource but it can also be used for checking SSH keys.
10
+
11
+
12
+ ## Syntax
13
+
14
+ An `key_rsa` resource block declares a `key file` to be tested.
15
+
16
+ describe key_rsa('mycertificate.key') do
17
+ it { should be_private }
18
+ it { should be_public }
19
+ its('public_key') { should match "-----BEGIN PUBLIC KEY-----\n3597459df9f3982" }
20
+ its('key_length') { should eq 2048 }
21
+ end
22
+
23
+ You can use an optional passphrase with `key_rsa`
24
+
25
+ describe key_rsa('mycertificate.key', 'passphrase') do
26
+ it { should be_private }
27
+ end
28
+
29
+ ## Supported Properties
30
+
31
+ ### public?
32
+
33
+ To verify if a key is public use the following:
34
+
35
+ describe key_rsa('/etc/pki/www.mywebsite.com.key') do
36
+ it { should be_public }
37
+ end
38
+
39
+ ### public_key (String)
40
+
41
+ The `public_key` property returns the public part of the RSA key pair
42
+
43
+ describe key_rsa('/etc/pki/www.mywebsite.com.key') do
44
+ its('public_key') { should match "-----BEGIN PUBLIC KEY-----\n3597459df9f3982......" }
45
+ end
46
+
47
+ ### private?
48
+
49
+ This property verifies that the key includes a private key:
50
+
51
+ describe key_rsa('/etc/pki/www.mywebsite.com.key') do
52
+ it { should be_private }
53
+ end
54
+
55
+
56
+ ### private_key (String)
57
+
58
+ The `private_key` property returns the private key or the RSA key pair.
59
+
60
+ describe key_rsa('/etc/pki/www.mywebsite.com.key') do
61
+ its('private_key') { should match "-----BEGIN RSA PRIVATE KEY-----\nMIIJJwIBAAK......" }
62
+ end
63
+
64
+ ### key_length
65
+
66
+ The `key_length` property allows testing the number of bits in the key pair.
67
+
68
+ describe key_rsa('/etc/pki/www.mywebsite.com.key') do
69
+ its('key_length') { should eq 2048 }
70
+ end
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: The x509_certificate Resource
3
+ ---
4
+
5
+ # x509_certificate
6
+
7
+ Use the `x509_certificate` InSpec audit resource to test the fields and validity of an x.509 certificate.
8
+
9
+ X.509 certificates use public/private key pairs to sign and encrypt documents
10
+ or communications over a network. They may also be used for authentication.
11
+
12
+ Examples include SSL certificates, S/MIME certificates and VPN authentication
13
+ certificates.
14
+
15
+ ## Syntax
16
+
17
+ An `x509_certificate` resource block declares a certificate `key file` to be tested.
18
+
19
+ describe x509_certificate('mycertificate.pem') do
20
+ its('validity_in_days') { should be > 30 }
21
+ end
22
+
23
+ ## Supported Properties
24
+
25
+ ### subject.XX
26
+
27
+ `subject` property makes it easier to access individual subject elements.
28
+
29
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
30
+ its('subject.CN') { should eq "www.mywebsite.com" }
31
+ end
32
+
33
+ ### subject_dn (String)
34
+
35
+ The `subject_dn` string returns the distinguished name of the subject field. It contains several fields separated by forward slashes. The field identifiers are the same ones used by OpenSSL to generate CSR's and certs. Use `subject.XX` instead to access the parsed version.
36
+
37
+ e.g. `/C=US/L=Seattle/O=Chef Software Inc/OU=Chefs/CN=Richard Nixon`
38
+
39
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
40
+ its('subject_dn') { should match "CN=www.mywebsite.com" }
41
+ end
42
+
43
+ ### issuer.XX
44
+
45
+ `issuer` makes it easier to access individual issuer elements.
46
+
47
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
48
+ its('issuer.CN') { should eq "Acme Trust CA" }
49
+ end
50
+
51
+ ### issuer_dn (String)
52
+
53
+ The `issuer_dn` is the distinguished name from a CA (certificate authority) during the
54
+ certificate signing process. It describes which authority is guaranteeing the
55
+ identity of our certificate.
56
+
57
+ e.g. `/C=US/L=Seattle/CN=Acme Trust CA/emailAddress=support@acmetrust.org`
58
+
59
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
60
+ its('issuer_cn') { should match "CN=Acme Trust CA" }
61
+ end
62
+
63
+ ### public_key (String)
64
+
65
+ The `public_key` property returns a base64 encoded public key in PEM format.
66
+
67
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
68
+ its('public_key') { should match "-----BEGIN PUBLIC KEY-----\nblah blah blah..." }
69
+ end
70
+
71
+ ### key_length (Integer)
72
+
73
+ The `key_length` property calculates the number of bits in the public key.
74
+ More bits increase security, but at the cost of speed and in extreme cases, compatibility.
75
+
76
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
77
+ its('key_length') { should be 2048 }
78
+ end
79
+
80
+ ### signature_algorithm (String)
81
+
82
+ The `signature_algorithm` property describes which hash function was used by the CA to
83
+ sign the certificate.
84
+
85
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
86
+ its('signature_algorithm') { should be 'sha256WithRSAEncryption' }
87
+ end
88
+
89
+
90
+ ### validity_in_days (Float)
91
+
92
+ The `validity_in_days` property can be used to check that certificates are not in
93
+ danger of expiring soon.
94
+
95
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
96
+ its('validity_in_days') { should be > 30 }
97
+ end
98
+
99
+ ### not_before and not_after (Time)
100
+
101
+ The `not_before` and `not_after` properties expose the start and end dates of certificate
102
+ validity. They are exposed as ruby Time class so that date arithmetic can be easily performed.
103
+
104
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
105
+ its('not_before') { should be <= Time.utc.now }
106
+ its('not_after') { should be >= Time.utc.now }
107
+ end
108
+
109
+ ### serial (Integer)
110
+
111
+ The `serial` property exposes the serial number of the certificate. The serial number is set by the CA during the signing process and should be unique within that CA.
112
+
113
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
114
+ its('serial') { should eq 9623283588743302433 }
115
+ end
116
+
117
+ ### version (Integer)
118
+
119
+ The `version` property exposes the certificate version.
120
+
121
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
122
+ its('version') { should eq 2 }
123
+ end
124
+
125
+ ### extensions (Hash)
126
+
127
+ The `extensions` hash property is mainly used to determine what the certificate can be used for.
128
+
129
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
130
+ # Check what extension categories we have
131
+ its('extensions') { should include 'keyUsage' }
132
+ its('extensions') { should include 'extendedKeyUsage' }
133
+ its('extensions') { should include 'subjectAltName' }
134
+
135
+ # Check examples of basic 'keyUsage'
136
+ its('extensions.keyUsage') { should include 'Digital Signature' }
137
+ its('extensions.keyUsage') { should include 'Non Repudiation' }
138
+ its('extensions.keyUsage') { should include 'Data Encipherment' }
139
+
140
+ # Check examples of newer 'extendedKeyUsage'
141
+ its('extensions.extendedKeyUsage') { should include 'TLS Web Server Authentication' }
142
+ its('extensions.extendedKeyUsage') { should include 'Code Signing' }
143
+
144
+ # Check examples of 'subjectAltName'
145
+ its('extensions.subjectAltName') { should include 'email:support@chef.io' }
146
+ end