inspec 2.2.54 → 2.2.55

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
  SHA256:
3
- metadata.gz: 977bb363360a10af70b26468798171a51e8ac00f4934dc62fe4efba59fdc9e5a
4
- data.tar.gz: 7915d80127ade0039e184c1b5b6dc56c07ffb87fcbab2da6ef4f7a34d7ec87df
3
+ metadata.gz: 22dc0070f981d1f1fde01573ca60ffbd69820ae73f57d4b0ca671d919d028f6f
4
+ data.tar.gz: 784732d10c1ca8126b67566db2249fcba998a032bf6973c7070eccad72b60c94
5
5
  SHA512:
6
- metadata.gz: add341eb8d92cb1f8ec093ff0bdb7bc22f4f63639e76defba94b1d8e4c823cf4948c845e4a1405b1778210fcd83d1108d7c8d91bc8aeba41d9409b4c79690a9f
7
- data.tar.gz: 380330555e16c43839401811df31ebb4477a03a2718e89675302317ef61ed9958f4551fb37f79575ae11aa7ec9b732fb9404233a7166a39d0f49f36a8b45a376
6
+ metadata.gz: e6da791946069dbc546ded07b7289e294e23244b84d4795638886534a8e8c3b2fc5bd529bd3beb7110e3e562debcddc505b47d45b317e1282a49a24a38971e5f
7
+ data.tar.gz: cd6c9fa8e65a6db9d210aeb8b41644d885f2a4dd8e7bb3a3790419a1fd57f4ff8461d6253df840b11dc0f284f0308029a82f8fcf719470e49dc73bde7396a91a
@@ -1,25 +1,31 @@
1
1
  # Change Log
2
2
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
3
- <!-- latest_release 2.2.54 -->
4
- ## [v2.2.54](https://github.com/inspec/inspec/tree/v2.2.54) (2018-08-02)
3
+ <!-- latest_release 2.2.55 -->
4
+ ## [v2.2.55](https://github.com/inspec/inspec/tree/v2.2.55) (2018-08-03)
5
5
 
6
6
  #### Enhancements
7
- - Escaping package names for windows packages [#3259](https://github.com/inspec/inspec/pull/3259) ([frezbo](https://github.com/frezbo))
7
+ - Add a merged json report for A2 [#3261](https://github.com/inspec/inspec/pull/3261) ([jquick](https://github.com/jquick))
8
8
  <!-- latest_release -->
9
9
 
10
- <!-- release_rollup since=2.2.50 -->
11
- ### Changes since 2.2.50 release
10
+ <!-- release_rollup since=2.2.54 -->
11
+ ### Changes since 2.2.54 release
12
12
 
13
13
  #### Enhancements
14
- - Escaping package names for windows packages [#3259](https://github.com/inspec/inspec/pull/3259) ([frezbo](https://github.com/frezbo)) <!-- 2.2.54 -->
15
- - Populate report code for merged controls [#3264](https://github.com/inspec/inspec/pull/3264) ([jquick](https://github.com/jquick)) <!-- 2.2.53 -->
16
- - Bump the chef client version for tests. [#3260](https://github.com/inspec/inspec/pull/3260) ([jquick](https://github.com/jquick)) <!-- 2.2.52 -->
17
-
18
- #### Merged Pull Requests
19
- - Ability to render contrib resource pack docs on main website [#3184](https://github.com/inspec/inspec/pull/3184) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.2.51 -->
14
+ - Add a merged json report for A2 [#3261](https://github.com/inspec/inspec/pull/3261) ([jquick](https://github.com/jquick)) <!-- 2.2.55 -->
20
15
  <!-- release_rollup -->
21
16
 
22
17
  <!-- latest_stable_release -->
18
+ ## [v2.2.54](https://github.com/inspec/inspec/tree/v2.2.54) (2018-08-02)
19
+
20
+ #### Enhancements
21
+ - Bump the chef client version for tests. [#3260](https://github.com/inspec/inspec/pull/3260) ([jquick](https://github.com/jquick))
22
+ - Populate report code for merged controls [#3264](https://github.com/inspec/inspec/pull/3264) ([jquick](https://github.com/jquick))
23
+ - Escaping package names for windows packages [#3259](https://github.com/inspec/inspec/pull/3259) ([frezbo](https://github.com/frezbo))
24
+
25
+ #### Merged Pull Requests
26
+ - Ability to render contrib resource pack docs on main website [#3184](https://github.com/inspec/inspec/pull/3184) ([clintoncwolfe](https://github.com/clintoncwolfe))
27
+ <!-- latest_stable_release -->
28
+
23
29
  ## [v2.2.50](https://github.com/inspec/inspec/tree/v2.2.50) (2018-07-26)
24
30
 
25
31
  #### New Features
@@ -36,7 +42,6 @@
36
42
  - cli: Downcase supermarket tool name to match URL [#3242](https://github.com/inspec/inspec/pull/3242) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
37
43
  - Satisfy RuboCop by adding `x` bit to `bin/inspec` [#3249](https://github.com/inspec/inspec/pull/3249) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
38
44
  - Fix for profile version not being included in the compliance upload c… [#3252](https://github.com/inspec/inspec/pull/3252) ([devoptimist](https://github.com/devoptimist))
39
- <!-- latest_stable_release -->
40
45
 
41
46
  ## [v2.2.41](https://github.com/inspec/inspec/tree/v2.2.41) (2018-07-20)
42
47
 
@@ -1,6 +1,7 @@
1
1
  require 'inspec/reporters/base'
2
2
  require 'inspec/reporters/cli'
3
3
  require 'inspec/reporters/json'
4
+ require 'inspec/reporters/json_merged'
4
5
  require 'inspec/reporters/json_min'
5
6
  require 'inspec/reporters/junit'
6
7
  require 'inspec/reporters/automate'
@@ -4,7 +4,7 @@ require 'json'
4
4
  require 'net/http'
5
5
 
6
6
  module Inspec::Reporters
7
- class Automate < Json
7
+ class Automate < JsonMerged
8
8
  def initialize(config)
9
9
  super(config)
10
10
 
@@ -17,7 +17,7 @@ module Inspec::Reporters
17
17
 
18
18
  def enriched_report
19
19
  # grab the report from the parent class
20
- final_report = report
20
+ final_report = report_merged
21
21
 
22
22
  # Label this content as an inspec_report
23
23
  final_report[:type] = 'inspec_report'
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ require 'json'
4
+
5
+ module Inspec::Reporters
6
+ class JsonMerged < Json
7
+ def initialize(config)
8
+ super(config)
9
+ @profiles = []
10
+ end
11
+
12
+ def render
13
+ output(report_merged.to_json, false)
14
+ end
15
+
16
+ def report_merged
17
+ # grab profiles from the json parent class
18
+ @profiles = report[:profiles]
19
+
20
+ {
21
+ platform: platform,
22
+ profiles: merge_profiles,
23
+ statistics: {
24
+ duration: run_data[:statistics][:duration],
25
+ },
26
+ version: run_data[:version],
27
+ }
28
+ end
29
+
30
+ private
31
+
32
+ def merge_profiles
33
+ @profiles.each do |profile|
34
+ next unless profile.key?(:parent_profile)
35
+ parent_profile = find_master_parent(profile)
36
+ merge_controls(parent_profile, profile)
37
+ merge_depends(parent_profile, profile)
38
+ end
39
+
40
+ # delete child profiles
41
+ @profiles.delete_if { |p| p.key?(:parent_profile) }
42
+
43
+ @profiles
44
+ end
45
+
46
+ def find_master_parent(profile)
47
+ return profile unless profile.key?(:parent_profile)
48
+
49
+ parent_profile = @profiles.select { |parent| parent[:name] == profile[:parent_profile] }.first
50
+ find_master_parent(parent_profile)
51
+ end
52
+
53
+ def merge_controls(parent, child)
54
+ parent[:controls].each do |control|
55
+ child_control = child[:controls].select { |c| c[:id] == control[:id] }.first
56
+ next if child_control.nil?
57
+
58
+ control.each do |name, _value|
59
+ child_value = child_control[name]
60
+ next if child_value.nil? || (child_value.respond_to?(:empty?) && child_value.empty?)
61
+ control[name] = child_value
62
+ end
63
+ end
64
+ end
65
+
66
+ def merge_depends(parent, child)
67
+ return unless child.key?(:depends)
68
+ child[:depends].each do |d|
69
+ parent[:depends] << d
70
+ end
71
+ end
72
+ end
73
+ end
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '2.2.54'
7
+ VERSION = '2.2.55'
8
8
  end
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: 2.2.54
4
+ version: 2.2.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-02 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -633,6 +633,7 @@ files:
633
633
  - lib/inspec/reporters/base.rb
634
634
  - lib/inspec/reporters/cli.rb
635
635
  - lib/inspec/reporters/json.rb
636
+ - lib/inspec/reporters/json_merged.rb
636
637
  - lib/inspec/reporters/json_min.rb
637
638
  - lib/inspec/reporters/junit.rb
638
639
  - lib/inspec/reporters/yaml.rb