inspec 1.46.2 → 1.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -15
- data/docs/ruby_usage.md +1 -1
- data/inspec.gemspec +1 -1
- data/lib/inspec/backend.rb +12 -0
- data/lib/inspec/base_cli.rb +2 -0
- data/lib/inspec/cli.rb +1 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/docker_image.rb +45 -17
- data/lib/resources/json.rb +6 -0
- data/lib/resources/key_rsa.rb +2 -2
- data/lib/resources/security_policy.rb +7 -8
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d4de764766d6ce02f52597d9cdd3d3c5f962bf
|
4
|
+
data.tar.gz: 0aaec0745ed380804d6bd333711054eab7c505ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d630d3408a4c34b13504dbdc6cb07e0de5a672525db739bb7e54eff8d0971b09838ae5c14169362d3a98b58ae27af1feffb0e443733e5e92ce948786494f95
|
7
|
+
data.tar.gz: 49a27fd5dbe847483d31fa7d5ec357c91008596f47042d531c81c290b332b542d7caf90e56a9ae04c572b9d39cc913dda87565ec82a405aeef92e7c3d87df425
|
data/CHANGELOG.md
CHANGED
@@ -1,28 +1,43 @@
|
|
1
1
|
# Change Log
|
2
2
|
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
|
3
|
-
<!-- latest_release 1.
|
4
|
-
## [v1.
|
3
|
+
<!-- latest_release 1.47.0 -->
|
4
|
+
## [v1.47.0](https://github.com/chef/inspec/tree/v1.47.0) (2017-12-04)
|
5
5
|
|
6
|
-
####
|
7
|
-
-
|
6
|
+
#### New Features
|
7
|
+
- Enable caching for backend calls [#2309](https://github.com/chef/inspec/pull/2309) ([jquick](https://github.com/jquick))
|
8
8
|
<!-- latest_release -->
|
9
9
|
|
10
|
-
<!-- release_rollup since=1.
|
11
|
-
### Changes since 1.
|
10
|
+
<!-- release_rollup since=1.46.2 -->
|
11
|
+
### Changes since 1.46.2 release
|
12
12
|
|
13
|
-
####
|
14
|
-
-
|
13
|
+
#### New Features
|
14
|
+
- Enable caching for backend calls [#2309](https://github.com/chef/inspec/pull/2309) ([jquick](https://github.com/jquick)) <!-- 1.47.0 -->
|
15
|
+
|
16
|
+
#### Merged Pull Requests
|
17
|
+
- docker_image resource: properly handle registries in image strings [#2356](https://github.com/chef/inspec/pull/2356) ([adamleff](https://github.com/adamleff)) <!-- 1.46.5 -->
|
15
18
|
|
16
19
|
#### Bug Fixes
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
21
|
-
- grub_conf resource: correct grub path for RHEL-7-based OS [#2332](https://github.com/chef/inspec/pull/2332) ([atomic111](https://github.com/atomic111)) <!-- 1.45.15 -->
|
22
|
-
- json resource (et. al.): allow inspec check to succeed when using command [#2317](https://github.com/chef/inspec/pull/2317) ([adamleff](https://github.com/adamleff)) <!-- 1.45.14 -->
|
20
|
+
- security_policy resource: use PID for filename instead of random [#2368](https://github.com/chef/inspec/pull/2368) ([jquick](https://github.com/jquick)) <!-- 1.46.7 -->
|
21
|
+
- key_rsa resource: fix inline shell documentation help, wrong resource name used in examples [#2364](https://github.com/chef/inspec/pull/2364) ([eramoto](https://github.com/eramoto)) <!-- 1.46.6 -->
|
22
|
+
- json resource: ensure params is not nil in event of read/parse failure [#2354](https://github.com/chef/inspec/pull/2354) ([adamleff](https://github.com/adamleff)) <!-- 1.46.4 -->
|
23
|
+
- Unique export file for security policy resource [#2350](https://github.com/chef/inspec/pull/2350) ([jquick](https://github.com/jquick)) <!-- 1.46.3 -->
|
23
24
|
<!-- release_rollup -->
|
24
25
|
|
25
26
|
<!-- latest_stable_release -->
|
27
|
+
## [v1.46.2](https://github.com/chef/inspec/tree/v1.46.2) (2017-11-29)
|
28
|
+
|
29
|
+
#### Enhancements
|
30
|
+
- allow override of attribute identifier [#2347](https://github.com/chef/inspec/pull/2347) ([chris-rock](https://github.com/chris-rock))
|
31
|
+
|
32
|
+
#### Bug Fixes
|
33
|
+
- json resource (et. al.): allow inspec check to succeed when using command [#2317](https://github.com/chef/inspec/pull/2317) ([adamleff](https://github.com/adamleff))
|
34
|
+
- grub_conf resource: correct grub path for RHEL-7-based OS [#2332](https://github.com/chef/inspec/pull/2332) ([atomic111](https://github.com/atomic111))
|
35
|
+
- http resource: properly support HEAD request with remote worker [#2340](https://github.com/chef/inspec/pull/2340) ([adamleff](https://github.com/adamleff))
|
36
|
+
- file resource: fix NilClass error when using advanced windows permissions [#2344](https://github.com/chef/inspec/pull/2344) ([TheLonelyGhost](https://github.com/TheLonelyGhost))
|
37
|
+
- wmi resource: properly escape quotes in WMI query [#2342](https://github.com/chef/inspec/pull/2342) ([TheLonelyGhost](https://github.com/TheLonelyGhost))
|
38
|
+
- Allow skipping/failing resources in FilterTable [#2349](https://github.com/chef/inspec/pull/2349) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
|
39
|
+
<!-- latest_stable_release -->
|
40
|
+
|
26
41
|
## [v1.45.13](https://github.com/chef/inspec/tree/v1.45.13) (2017-11-21)
|
27
42
|
|
28
43
|
#### Merged Pull Requests
|
@@ -30,7 +45,6 @@
|
|
30
45
|
- Remove bundler install during Appveyor tests [#2322](https://github.com/chef/inspec/pull/2322) ([adamleff](https://github.com/adamleff))
|
31
46
|
- Bump Rubocop to 0.49.1 [#2323](https://github.com/chef/inspec/pull/2323) ([adamleff](https://github.com/adamleff))
|
32
47
|
- Bump train to 0.29.2 [#2327](https://github.com/chef/inspec/pull/2327) ([adamleff](https://github.com/adamleff))
|
33
|
-
<!-- latest_stable_release -->
|
34
48
|
|
35
49
|
## [v1.45.9](https://github.com/chef/inspec/tree/v1.45.9) (2017-11-16)
|
36
50
|
|
data/docs/ruby_usage.md
CHANGED
@@ -73,7 +73,7 @@ independent of programming languages and their resolver mechanisms.
|
|
73
73
|
## Interactive Debugging with Pry
|
74
74
|
|
75
75
|
Here's a sample InSpec control that users Ruby variables to instantiate
|
76
|
-
an InSpec resource once and use the content in
|
76
|
+
an InSpec resource once and use the content in multiple tests.
|
77
77
|
|
78
78
|
```ruby
|
79
79
|
control 'check-perl' do
|
data/inspec.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = '>= 2.3'
|
28
28
|
|
29
|
-
spec.add_dependency 'train', '~> 0.
|
29
|
+
spec.add_dependency 'train', '~> 0.30'
|
30
30
|
spec.add_dependency 'thor', '~> 0.19'
|
31
31
|
spec.add_dependency 'json', '>= 1.8', '< 3.0'
|
32
32
|
spec.add_dependency 'rainbow', '~> 2'
|
data/lib/inspec/backend.rb
CHANGED
@@ -53,6 +53,18 @@ module Inspec
|
|
53
53
|
raise "Can't connect to transport backend '#{name}'."
|
54
54
|
end
|
55
55
|
|
56
|
+
# Set caching settings. We always want to enable caching for
|
57
|
+
# the Mock transport for testing.
|
58
|
+
if config[:backend_cache] || config[:backend] == :mock
|
59
|
+
connection.enable_cache(:file)
|
60
|
+
connection.enable_cache(:command)
|
61
|
+
elsif config[:debug_shell]
|
62
|
+
connection.disable_cache(:file)
|
63
|
+
connection.disable_cache(:command)
|
64
|
+
else
|
65
|
+
connection.disable_cache(:command)
|
66
|
+
end
|
67
|
+
|
56
68
|
cls = Class.new do
|
57
69
|
include Base
|
58
70
|
|
data/lib/inspec/base_cli.rb
CHANGED
@@ -67,6 +67,8 @@ module Inspec
|
|
67
67
|
desc: 'Use the given path for caching dependencies. (default: ~/.inspec/cache)'
|
68
68
|
option :create_lockfile, type: :boolean, default: true,
|
69
69
|
desc: 'Write out a lockfile based on this execution (unless one already exists)'
|
70
|
+
option :backend_cache, type: :boolean, default: false,
|
71
|
+
desc: 'Allow caching for backend command output.'
|
70
72
|
end
|
71
73
|
|
72
74
|
private
|
data/lib/inspec/cli.rb
CHANGED
@@ -189,6 +189,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
|
|
189
189
|
def shell_func
|
190
190
|
diagnose
|
191
191
|
o = opts.dup
|
192
|
+
o[:debug_shell] = true
|
192
193
|
|
193
194
|
json_output = ['json', 'json-min'].include?(opts['format'])
|
194
195
|
log_device = json_output ? nil : STDOUT
|
data/lib/inspec/version.rb
CHANGED
@@ -63,25 +63,19 @@ module Inspec::Resources
|
|
63
63
|
private
|
64
64
|
|
65
65
|
def sanitize_options(opts)
|
66
|
-
|
67
|
-
if !opts[:image].index(':').nil?
|
68
|
-
repo, tag = opts[:image].split(':')
|
69
|
-
else
|
70
|
-
opts[:repo] = opts[:image]
|
71
|
-
opts[:image] = nil
|
72
|
-
end
|
73
|
-
opts[:repo] ||= repo
|
74
|
-
opts[:tag] ||= tag
|
75
|
-
end
|
76
|
-
|
77
|
-
if !opts[:id].nil?
|
78
|
-
if opts[:id].index(':').nil?
|
79
|
-
opts[:id] = 'sha256:' + opts[:id]
|
80
|
-
end
|
81
|
-
end
|
66
|
+
opts.merge!(parse_components_from_image(opts[:image]))
|
82
67
|
|
68
|
+
# assume a "latest" tag if we don't have one
|
83
69
|
opts[:tag] ||= 'latest'
|
84
|
-
|
70
|
+
|
71
|
+
# if the ID isn't nil and doesn't contain a hash indicator (indicated by the presence
|
72
|
+
# of a colon, which separates the indicator from the actual hash), we assume it's sha256.
|
73
|
+
opts[:id] = 'sha256:' + opts[:id] unless opts[:id].nil? || opts[:id].include?(':')
|
74
|
+
|
75
|
+
# Assemble/reassemble the image from the repo and tag
|
76
|
+
opts[:image] = "#{opts[:repo]}:#{opts[:tag]}" unless opts[:repo].nil?
|
77
|
+
|
78
|
+
# return the santized opts back to the caller
|
85
79
|
opts
|
86
80
|
end
|
87
81
|
|
@@ -92,5 +86,39 @@ module Inspec::Resources
|
|
92
86
|
(repository == opts[:repo] && tag == opts[:tag]) || (!id.nil? && !opts[:id].nil? && (id == opts[:id] || id.start_with?(opts[:id])))
|
93
87
|
}
|
94
88
|
end
|
89
|
+
|
90
|
+
def parse_components_from_image(image_string)
|
91
|
+
# if the user did not supply an image string, they likely supplied individual
|
92
|
+
# option parameters, such as repo and tag. Return empty data back to the caller.
|
93
|
+
return {} if image_string.nil?
|
94
|
+
|
95
|
+
first_colon = image_string.index(':') || -1
|
96
|
+
first_slash = image_string.index('/') || -1
|
97
|
+
|
98
|
+
if image_string.count(':') == 2
|
99
|
+
# If there are two colons in the image string, it contains a repo-with-port and a tag.
|
100
|
+
# example: localhost:5000/chef/inspec:1.46.3
|
101
|
+
partitioned_string = image_string.rpartition(':')
|
102
|
+
repo = partitioned_string.first
|
103
|
+
tag = partitioned_string.last
|
104
|
+
elsif image_string.count(':') == 1 && first_colon < first_slash
|
105
|
+
# If there's one colon in the image string, and it comes before a forward-slash,
|
106
|
+
# it contains a repo-with-port but no tag.
|
107
|
+
# example: localhost:5000/ubuntu
|
108
|
+
repo = image_string
|
109
|
+
tag = nil
|
110
|
+
else
|
111
|
+
# If there's one colon in the image string and it doesn't preceed a slash, or if
|
112
|
+
# there is no colon at all, then it separates the repo from the tag, if there is a tag.
|
113
|
+
# example: chef/inspec:1.46.3
|
114
|
+
# example: chef/inspec
|
115
|
+
# example: ubuntu:14.04
|
116
|
+
repo, tag = image_string.split(':')
|
117
|
+
end
|
118
|
+
|
119
|
+
# return the repo and tag parsed from the string, which can be merged into
|
120
|
+
# the rest of the user-supplied options
|
121
|
+
{ repo: repo, tag: tag }
|
122
|
+
end
|
95
123
|
end
|
96
124
|
end
|
data/lib/resources/json.rb
CHANGED
@@ -29,6 +29,12 @@ module Inspec::Resources
|
|
29
29
|
attr_reader :params, :raw_content
|
30
30
|
|
31
31
|
def initialize(opts)
|
32
|
+
# pre-initialize @params to an empty hash. In the event that reading/parsing the data
|
33
|
+
# throws an exception, this allows the resource to still be called outside of a
|
34
|
+
# describe/test and not throw errors when a caller attempts to fetch a value from the params.
|
35
|
+
@params = {}
|
36
|
+
|
37
|
+
# load the raw content from the source, and then parse it
|
32
38
|
@raw_content = load_raw_content(opts)
|
33
39
|
@params = parse(@raw_content)
|
34
40
|
end
|
data/lib/resources/key_rsa.rb
CHANGED
@@ -10,11 +10,11 @@ module Inspec::Resources
|
|
10
10
|
name 'key_rsa'
|
11
11
|
desc 'public/private RSA key pair test'
|
12
12
|
example "
|
13
|
-
describe
|
13
|
+
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
14
14
|
its('public_key') { should match /BEGIN RSA PUBLIC KEY/ }
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe key_rsa('/etc/pki/www.mywebsite.com.key', 'passphrase') do
|
18
18
|
it { should be_private }
|
19
19
|
it { should be_public }
|
20
20
|
end
|
@@ -108,22 +108,21 @@ module Inspec::Resources
|
|
108
108
|
def read_content
|
109
109
|
return @content if defined?(@content)
|
110
110
|
|
111
|
+
# using process pid to prevent any race conditions with multiple runners
|
112
|
+
export_file = "win_secpol-#{Process.pid}.cfg"
|
113
|
+
|
111
114
|
# export the security policy
|
112
|
-
cmd = inspec.command(
|
115
|
+
cmd = inspec.command("secedit /export /cfg #{export_file}")
|
113
116
|
return nil if cmd.exit_status.to_i != 0
|
114
117
|
|
115
118
|
# store file content
|
116
|
-
cmd = inspec.command(
|
119
|
+
cmd = inspec.command("Get-Content #{export_file}")
|
117
120
|
return skip_resource "Can't read security policy" if cmd.exit_status.to_i != 0
|
118
|
-
@content = cmd.stdout
|
119
121
|
|
120
|
-
|
121
|
-
return skip_resource "Can't read security policy"
|
122
|
-
end
|
123
|
-
@content
|
122
|
+
@content = cmd.stdout
|
124
123
|
ensure
|
125
124
|
# delete temp file
|
126
|
-
inspec.command(
|
125
|
+
inspec.command("Remove-Item #{export_file}").exit_status.to_i
|
127
126
|
end
|
128
127
|
|
129
128
|
def read_params
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.47.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.29.2
|
19
|
+
version: '0.30'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.29.2
|
26
|
+
version: '0.30'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: thor
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|