deploy_rubygem 0.60.18 → 0.60.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 428b3075e54be6e8c5d25d116b682807664ec7881e38fd7e2fcb61267374394d
4
- data.tar.gz: b1d648319b872db65d43204e0a0411014944e82a994664036da9dda6ded21850
3
+ metadata.gz: 1f61e704844f1f80fc9da968ad0e9ad34f2961f1c97f31c6ed329ffdd21d4a17
4
+ data.tar.gz: 7028f7729663bdff4748c01959c227865ef70fd506cc869bd0ef8e097c42a8fe
5
5
  SHA512:
6
- metadata.gz: ac50c3bb314cee3c6f23994eaad5b4e2a35c901e2821166c7f58793019a094da62ee16708cfd354563f93d79f34ad3071f65413372ff07427382d6f1eb80f2de
7
- data.tar.gz: 16d64454be82d7186fdac0a17b1fdf311a415cfb580dc5172bf0ee9e05233eb268752eabd5936e73b733a739562877b23405989bfe931ebaf233002581555390
6
+ metadata.gz: 2a4e9293b7af8c0a4335aee4ba6aae09f5e8495da15055bebddd2187f9ba9fe620bb89f4b7ef3c46b16fd326d3cab518bced7ba096a8f96eb2aa0a8d35da3d88
7
+ data.tar.gz: 29678da2f8a7096a239fed59503ad356d3171778ce19db1a8994a66714ec4874b47a993ff804b02917f7eb2783376a97abff823debce4dd2c0789685c6d55dcd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'project'
4
4
  require_relative 'kitchen'
5
- require_relative 'inspec'
5
+ require_relative 'inspectestor'
6
6
  require_relative 'rubygem'
7
7
 
8
8
  # DeployRubygem - deploy a gem using rake
@@ -17,13 +17,13 @@ module DeployRubygem
17
17
  @profiles = cookbook_info[:compliance_profiles].map do |profile_name|
18
18
  input_file = File.join(%w[compliance inputs] + ["#{cookbook_name}.yml"])
19
19
  waiver_file = File.join(%w[compliance waivers] + ["#{cookbook_name}.yml"])
20
- Inspec.new(profile_name, input_file, waiver_file)
20
+ InspecTestor.new(profile_name, input_file, waiver_file)
21
21
  end
22
22
  @kitchens = cookbook_info[:kitchens].map do |kitchen_name|
23
23
  Kitchen.new(kitchen_name, self)
24
24
  end
25
25
  @execute_profiles = cookbook_info[:execute_profiles].map do |profile_name|
26
- Inspec.new(profile_name)
26
+ InspecTestor.new(profile_name)
27
27
  end
28
28
  end
29
29
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DeployRubygem - deploy a gem using rake
4
+ # Containing a class
5
+ module DeployRubygem
6
+ # Using Inspec to deploy and manage Inspec
7
+ class InspecTestorResult
8
+ attr_reader :success_control, :success_result, :failed_control, :failed_result, :pending_control, :pending_result
9
+
10
+ def initialize(as_json)
11
+ @as_json = as_json
12
+ @success_control = 0
13
+ @success_result = 0
14
+ @failed_control = 0
15
+ @failed_result = 0
16
+ @pending_control = 0
17
+ @pending_result = 0
18
+ results
19
+ end
20
+
21
+ def profile
22
+ @as_json['profiles'].first
23
+ end
24
+
25
+ def status
26
+ profile['status']
27
+ end
28
+
29
+ def controls
30
+ profile['controls']
31
+ end
32
+
33
+ def result_summary
34
+ {
35
+ success_control: success_control,
36
+ success_result: success_result,
37
+ failed_control: failed_control,
38
+ failed_result: failed_result,
39
+ pending_control: pending_control,
40
+ pending_result: pending_result
41
+ }
42
+ end
43
+
44
+ private
45
+
46
+ def results
47
+ controls.each do |control_result|
48
+ control_as_fail = false
49
+ control_result['results'].each do |item_result|
50
+ case item_result['status']
51
+ when 'passed'
52
+ @success_result += 1
53
+ when 'failed'
54
+ @failed_result += 1
55
+ @failed_control += 1
56
+ control_as_fail = true
57
+ else
58
+ @pending_result += 1
59
+ @pending_control += 1
60
+ control_as_fail = true
61
+ end
62
+ end
63
+ @success_control += 1 unless control_as_fail
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ require_relative 'inspec_result'
6
+
7
+ # DeployRubygem - deploy a gem using rake
8
+ # Containing a class
9
+ module DeployRubygem
10
+ # Using Inspec to deploy and manage Inspec
11
+ class InspecTestor
12
+ attr_reader :inspec_path, :input_file, :waiver_file
13
+
14
+ def initialize(inspec_path, input_file = nil, waiver_file = nil)
15
+ @inspec_path = inspec_path
16
+ @input_file = input_file
17
+ @waiver_file = waiver_file
18
+ end
19
+
20
+ def inspect_name
21
+ File.basename(inspec_path)
22
+ end
23
+
24
+ def apply
25
+ puts "ActuaL Dir #{Dir.pwd}"
26
+ puts "inspec_name = #{inspec_name}"
27
+ puts "input_file = #{input_file}"
28
+ puts "waiver_file = #{waiver_file}"
29
+
30
+ check
31
+ system("inspec exec #{inspec_path} #{inspec_options.join(' ')}")
32
+ end
33
+
34
+ def update
35
+ system("rm -rf #{inspec_path}/vendor")
36
+ system("rm #{inspec_path}/inspec.lock")
37
+ system("inspec vendor #{inspec_path}")
38
+ end
39
+
40
+ def save_as_html(html_file)
41
+ check
42
+ system("inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter html:#{html_file}")
43
+ end
44
+
45
+ def test_json
46
+ @test_json ||= InspecTestorResult.new(as_json)
47
+ end
48
+
49
+ private
50
+
51
+ def inspec_options
52
+ cmd_opt = []
53
+
54
+ unless input_file.nil?
55
+ cmd_opt << '--input-file'
56
+ cmd_opt << input_file
57
+ end
58
+
59
+ unless waiver_file.nil?
60
+ cmd_opt << '--waiver-file'
61
+ cmd_opt << waiver_file
62
+ end
63
+ cmd_opt
64
+ end
65
+
66
+ def check
67
+ update
68
+ system("inspec check #{inspec_path}")
69
+ end
70
+
71
+ def as_json
72
+ check
73
+ request_str = `inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter json`
74
+ JSON.parse(request_str)
75
+ end
76
+ end
77
+ end
@@ -19,7 +19,7 @@ module DeployRubygem
19
19
  new_cookbook_option[:chefrepo_path] = chefrepo_path
20
20
  Cookbook.new(new_cookbook_option)
21
21
  end
22
- @compliance_profile = Inspec.new(project_options[:compliance_profile])
22
+ @compliance_profile = InspecTestor.new(project_options[:compliance_profile])
23
23
  end
24
24
 
25
25
  def project_name
@@ -95,5 +95,27 @@ module DeployRubygem
95
95
  end
96
96
  end
97
97
  end
98
+
99
+ def testing_inspec(inspector)
100
+ inspect_test = InspecTestor.new(inspector[:inspec_path], inspector[:input_file], inspector[:waiver_file])
101
+ RSpec.describe "Testing #{inspect_test} at #{Dir.pwd}" do
102
+ it 'Should be a kind of Html' do
103
+ test_html = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html')
104
+ expect(test_html).to be true
105
+ end
106
+ it 'Should be a kind of Json' do
107
+ expect(inspect_test.test_json).to be_kind_of(InspecTestorResult)
108
+ expect(inspect_test.test_json.status).to eq 'loaded'
109
+ end
110
+ it 'Should be successfull' do
111
+ expect(inspect_test.test_json.success_result).to eq inspector[:success_result]
112
+ expect(inspect_test.test_json.success_control).to eq inspector[:success_control]
113
+ expect(inspect_test.test_json.failed_result).to eq inspector[:failed_result]
114
+ expect(inspect_test.test_json.failed_control).to eq inspector[:failed_control]
115
+ expect(inspect_test.test_json.pending_result).to eq inspector[:pending_result]
116
+ expect(inspect_test.test_json.pending_control).to eq inspector[:pending_control]
117
+ end
118
+ end
119
+ end
98
120
  end
99
121
  end
@@ -17,5 +17,5 @@ module DeployRubygem
17
17
  end
18
18
 
19
19
  # VERSION = new_deploy_rubygem.gvb_version.short_version
20
- VERSION = '0.60.18'
20
+ VERSION = '0.60.20'
21
21
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy_rubygem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.60.18
4
+ version: 0.60.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Provencher
@@ -138,7 +138,8 @@ files:
138
138
  - lib/deploy_rubygem.rb
139
139
  - lib/deploy_rubygem/cookbook.rb
140
140
  - lib/deploy_rubygem/deploy_rubygem_options.rb
141
- - lib/deploy_rubygem/inspec.rb
141
+ - lib/deploy_rubygem/inspec_result.rb
142
+ - lib/deploy_rubygem/inspectestor.rb
142
143
  - lib/deploy_rubygem/kitchen.rb
143
144
  - lib/deploy_rubygem/project.rb
144
145
  - lib/deploy_rubygem/rspec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # DeployRubygem - deploy a gem using rake
4
- # Containing a class
5
- module DeployRubygem
6
- # Using Inspec to deploy and manage Inspec
7
- class Inspec
8
- attr_reader :inspec_name, :input_file, :waiver_file
9
-
10
- def initialize(inspec_name, input_file = nil, waiver_file = nil)
11
- @inspec_name = inspec_name
12
- @input_file = input_file
13
- @waiver_file = waiver_file
14
- end
15
-
16
- def inspec_options
17
- cmd_opt = []
18
-
19
- unless input_file.nil?
20
- cmd_opt << '--input-file'
21
- cmd_opt << input_file
22
- end
23
-
24
- unless waiver_file.nil?
25
- cmd_opt << '--waiver-file'
26
- cmd_opt << waiver_file
27
- end
28
- cmd_opt
29
- end
30
-
31
- def check
32
- system("inspec check compliance/profiles/#{inspec_name}")
33
- end
34
-
35
- def apply
36
- puts "ActuaL Dir #{Dir.pwd}"
37
- puts "inspec_name = #{inspec_name}"
38
- puts "input_file = #{input_file}"
39
- puts "waiver_file = #{waiver_file}"
40
-
41
- check
42
- system("inspec exec compliance/profiles/#{inspec_name} #{inspec_options.join(' ')}")
43
- end
44
-
45
- def update
46
- system("rm -rf compliance/profiles/#{inspec_name}/vendor")
47
- system("rm compliance/profiles/#{inspec_name}/inspec.lock")
48
- system("inspec vendor compliance/profiles/#{inspec_name}")
49
- end
50
-
51
- def save_as_html(html_file)
52
- check
53
- system("inspec exec compliance/profiles/#{inspec_name} #{inspec_options.join(' ')} --reporter html:#{html_file}")
54
- end
55
-
56
- def as_json
57
- check
58
- `inspec exec compliance/profiles/#{inspec_name} #{inspec_options.join(' ')} --reporter json")`
59
- end
60
- end
61
- end