inspec 1.4.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -2
- data/examples/inheritance/README.md +49 -3
- data/examples/inheritance/controls/example.rb +4 -0
- data/examples/inheritance/inspec.yml +2 -0
- data/lib/inspec/dependencies/dependency_set.rb +2 -2
- data/lib/inspec/dependencies/requirement.rb +5 -4
- data/lib/inspec/profile.rb +3 -2
- data/lib/inspec/runner.rb +4 -2
- data/lib/inspec/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bca4fcc30155e9c8a8e2ff7a8ce6fc2b597a8d79
|
4
|
+
data.tar.gz: e8c2c7f7b0c6769c471c02886926fa8413f3cadf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e7937ad40da9cc29944dd82d3140275dc607e3970731b69945a7d523434778c304952b17742a75aec3482fceb6c7e6df0ec2f0f2b6928b90c878d4b6a3cfc68
|
7
|
+
data.tar.gz: 9b44c4bb35f154720e89e3844fb72fcea39f7f0491543a007faeb921f5dcaa5786d709bf33195f53111760832da040c580415969a86f443163a2442ebab3600c
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [1.4.
|
4
|
-
[Full Changelog](https://github.com/chef/inspec/compare/v1.
|
3
|
+
## [1.4.1](https://github.com/chef/inspec/tree/1.4.1) (2016-11-04)
|
4
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v1.4.0...1.4.1)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- Passing attributes to inherited profiles [\#1250](https://github.com/chef/inspec/issues/1250)
|
9
|
+
|
10
|
+
**Closed issues:**
|
11
|
+
|
12
|
+
- RFC: Harmonize profile location targets in inspec.yml/kitchen.yml/audit cookbook [\#1227](https://github.com/chef/inspec/issues/1227)
|
13
|
+
|
14
|
+
**Merged pull requests:**
|
15
|
+
|
16
|
+
- Fix attributes in profile dependencies [\#1258](https://github.com/chef/inspec/pull/1258) ([chris-rock](https://github.com/chris-rock))
|
17
|
+
|
18
|
+
## [v1.4.0](https://github.com/chef/inspec/tree/v1.4.0) (2016-11-04)
|
19
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v1.3.0...v1.4.0)
|
5
20
|
|
6
21
|
**Fixed bugs:**
|
7
22
|
|
@@ -7,13 +7,59 @@ This example shows the use of InSpec [profile](../../docs/profiles.rst) inherita
|
|
7
7
|
InSpec ships with built-in features to verify a profile structure.
|
8
8
|
|
9
9
|
```bash
|
10
|
-
$ inspec check examples/inheritance
|
10
|
+
$ inspec check examples/inheritance
|
11
11
|
```
|
12
12
|
|
13
13
|
## Execute a profile
|
14
14
|
|
15
|
-
To run a profile on a local machine use `inspec exec /path/to/profile`.
|
15
|
+
To run a profile on a local machine use `inspec exec /path/to/profile`. All dependencies are automatically resolved.
|
16
16
|
|
17
17
|
```bash
|
18
|
-
$ inspec exec examples/inheritance
|
18
|
+
$ inspec exec examples/inheritance
|
19
|
+
```
|
20
|
+
|
21
|
+
## Set attributes for dependent profiles
|
22
|
+
|
23
|
+
Without setting attributes, an `inspec exec` would return the following:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ inspec git:(master) ✗ b inspec exec examples/inheritance
|
27
|
+
|
28
|
+
Profile: InSpec example inheritance (inheritance)
|
29
|
+
Version: 1.0.0
|
30
|
+
Target: local://
|
31
|
+
|
32
|
+
|
33
|
+
○ gordon-1.0: Verify the version number of Gordon (1 skipped)
|
34
|
+
○ Can't find file "/tmp/gordon/config.yaml"
|
35
|
+
✔ File content should match nil
|
36
|
+
✔ ssh-1: Allow only SSH Protocol 2
|
37
|
+
✔ File /bin/sh should be owned by "root"
|
38
|
+
|
39
|
+
File /tmp
|
40
|
+
✔ should be directory
|
41
|
+
alice should
|
42
|
+
✖ eq "bob"
|
43
|
+
|
44
|
+
expected: "bob"
|
45
|
+
got: "alice"
|
46
|
+
|
47
|
+
(compared using ==)
|
48
|
+
|
49
|
+
should eq
|
50
|
+
✖ "secret"
|
51
|
+
|
52
|
+
expected: "secret"
|
53
|
+
got: nil
|
54
|
+
|
55
|
+
(compared using ==)
|
56
|
+
|
57
|
+
|
58
|
+
Test Summary: 3 successful, 2 failures, 1 skipped
|
59
|
+
```
|
60
|
+
|
61
|
+
To pass in attributes, just call:
|
62
|
+
|
63
|
+
```
|
64
|
+
$ inspec exec examples/inheritance --attrs examples/profile-attribute.yml
|
19
65
|
```
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# copyright: 2016, Chef Software, Inc.
|
3
3
|
# license: All rights reserved
|
4
4
|
|
5
|
+
# manipulate controls of `profile`
|
5
6
|
include_controls 'profile' do
|
6
7
|
skip_control 'tmp-1.0'
|
7
8
|
|
@@ -9,3 +10,6 @@ include_controls 'profile' do
|
|
9
10
|
impact 0.0
|
10
11
|
end
|
11
12
|
end
|
13
|
+
|
14
|
+
# load all controls of `profile-attribute`
|
15
|
+
include_controls 'profile-attribute'
|
@@ -14,9 +14,9 @@ module Inspec
|
|
14
14
|
# @param cwd [String] Current working directory for relative path includes
|
15
15
|
# @param vendor_path [String] Path to the vendor directory
|
16
16
|
#
|
17
|
-
def self.from_lockfile(lockfile, cwd, cache, backend)
|
17
|
+
def self.from_lockfile(lockfile, cwd, cache, backend, opts = {})
|
18
18
|
dep_tree = lockfile.deps.map do |dep|
|
19
|
-
Inspec::Requirement.from_lock_entry(dep, cwd, cache, backend)
|
19
|
+
Inspec::Requirement.from_lock_entry(dep, cwd, cache, backend, opts)
|
20
20
|
end
|
21
21
|
|
22
22
|
dep_list = flatten_dep_tree(dep_tree)
|
@@ -14,16 +14,16 @@ module Inspec
|
|
14
14
|
new(dep[:name], dep[:version], cache, opts[:cwd], opts.merge(dep))
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.from_lock_entry(entry, cwd, cache, backend)
|
17
|
+
def self.from_lock_entry(entry, cwd, cache, backend, opts = {})
|
18
18
|
req = new(entry[:name],
|
19
19
|
entry[:version_constraints],
|
20
20
|
cache,
|
21
21
|
cwd,
|
22
|
-
entry[:resolved_source].merge(backend: backend))
|
22
|
+
entry[:resolved_source].merge(backend: backend).merge(opts))
|
23
23
|
|
24
24
|
locked_deps = []
|
25
25
|
Array(entry[:dependencies]).each do |dep_entry|
|
26
|
-
locked_deps << Inspec::Requirement.from_lock_entry(dep_entry, cwd, cache, backend)
|
26
|
+
locked_deps << Inspec::Requirement.from_lock_entry(dep_entry, cwd, cache, backend, opts)
|
27
27
|
end
|
28
28
|
req.lock_deps(locked_deps)
|
29
29
|
req
|
@@ -85,6 +85,7 @@ module Inspec
|
|
85
85
|
@fetcher ||= Inspec::CachedFetcher.new(opts, @cache)
|
86
86
|
end
|
87
87
|
|
88
|
+
# load dependencies of the dependency
|
88
89
|
def dependencies
|
89
90
|
@dependencies ||= profile.metadata.dependencies.map do |r|
|
90
91
|
Inspec::Requirement.from_metadata(r, @cache, cwd: @cwd, backend: @backend)
|
@@ -95,9 +96,9 @@ module Inspec
|
|
95
96
|
name
|
96
97
|
end
|
97
98
|
|
99
|
+
# load the profile for the requirement
|
98
100
|
def profile
|
99
101
|
return @profile if ! @profile.nil?
|
100
|
-
|
101
102
|
opts = @opts.dup
|
102
103
|
opts[:backend] = @backend
|
103
104
|
if !@dependencies.nil?
|
data/lib/inspec/profile.rb
CHANGED
@@ -60,13 +60,14 @@ module Inspec
|
|
60
60
|
@profile_id = options[:id]
|
61
61
|
@cache = options[:cache] || Cache.new
|
62
62
|
@backend = options[:backend] || Inspec::Backend.create(options)
|
63
|
+
@attr_values = options[:attributes]
|
63
64
|
@source_reader = source_reader
|
64
65
|
@tests_collected = false
|
65
66
|
@libraries_loaded = false
|
66
67
|
Metadata.finalize(@source_reader.metadata, @profile_id)
|
67
68
|
@runner_context =
|
68
69
|
options[:profile_context] ||
|
69
|
-
Inspec::ProfileContext.for_profile(self, @backend,
|
70
|
+
Inspec::ProfileContext.for_profile(self, @backend, @attr_values)
|
70
71
|
end
|
71
72
|
|
72
73
|
def name
|
@@ -350,7 +351,7 @@ module Inspec
|
|
350
351
|
end
|
351
352
|
|
352
353
|
def load_dependencies
|
353
|
-
Inspec::DependencySet.from_lockfile(lockfile, cwd, @cache, @backend)
|
354
|
+
Inspec::DependencySet.from_lockfile(lockfile, cwd, @cache, @backend, { attributes: @attr_values })
|
354
355
|
end
|
355
356
|
|
356
357
|
private
|
data/lib/inspec/runner.rb
CHANGED
@@ -116,7 +116,7 @@ module Inspec
|
|
116
116
|
def load_attributes(options)
|
117
117
|
attributes = {}
|
118
118
|
# read endpoints for secrets eg. yml file
|
119
|
-
secrets_targets = options[
|
119
|
+
secrets_targets = options[:attrs]
|
120
120
|
unless secrets_targets.nil?
|
121
121
|
secrets_targets.each do |target|
|
122
122
|
secrets = Inspec::SecretsBackend.resolve(target)
|
@@ -124,7 +124,9 @@ module Inspec
|
|
124
124
|
attributes = attributes.merge(secrets.attributes) unless secrets.nil? || secrets.attributes.nil?
|
125
125
|
end
|
126
126
|
end
|
127
|
-
options[
|
127
|
+
options[:attributes] = options[:attributes] || {}
|
128
|
+
options[:attributes] = options[:attributes].merge(attributes)
|
129
|
+
options[:attributes]
|
128
130
|
end
|
129
131
|
|
130
132
|
#
|
data/lib/inspec/version.rb
CHANGED