inspec 0.14.6 → 0.14.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -3
- data/lib/bundles/inspec-compliance/api.rb +24 -15
- data/lib/bundles/inspec-compliance/cli.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: e23aea3ed6f256ada21afef149fe87553f84aa17
|
4
|
+
data.tar.gz: 1d36f905fa6a2dae444900d01d9db522da10fdb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 790db6f9584440a041282924b5e70faa2763c4b1e3dcee3f7f26d2bb29dc998ebaade90158179be869f624b9510172623641522508fb4015dad19bd9a3b6a0af
|
7
|
+
data.tar.gz: 220b6f09b83e99abddba71d156288ee5e1171e061d9bbc4cea33e34b9570dac3416602007ebb8982081ebcc88837eee82808d7780ff000c9cfd326fc1b049a36
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.14.
|
4
|
-
[Full Changelog](https://github.com/chef/inspec/compare/v0.14.
|
3
|
+
## [0.14.7](https://github.com/chef/inspec/tree/0.14.7) (2016-03-01)
|
4
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.14.6...0.14.7)
|
5
5
|
|
6
6
|
**Fixed bugs:**
|
7
7
|
|
8
|
-
-
|
8
|
+
- `compliance` command does not work with self-signed https [\#511](https://github.com/chef/inspec/issues/511)
|
9
|
+
|
10
|
+
**Closed issues:**
|
11
|
+
|
12
|
+
- check error - digest: no implicit conversion of nil into String \(TypeError\) [\#509](https://github.com/chef/inspec/issues/509)
|
9
13
|
|
10
14
|
**Merged pull requests:**
|
11
15
|
|
16
|
+
- adds a insecure option [\#512](https://github.com/chef/inspec/pull/512) ([chris-rock](https://github.com/chris-rock))
|
17
|
+
|
18
|
+
## [v0.14.6](https://github.com/chef/inspec/tree/v0.14.6) (2016-03-01)
|
19
|
+
[Full Changelog](https://github.com/chef/inspec/compare/v0.14.5...v0.14.6)
|
20
|
+
|
21
|
+
**Implemented enhancements:**
|
22
|
+
|
12
23
|
- Improve Supermarket CLI [\#508](https://github.com/chef/inspec/pull/508) ([alexpop](https://github.com/alexpop))
|
13
24
|
|
25
|
+
**Fixed bugs:**
|
26
|
+
|
27
|
+
- add missing supermarket loader [\#506](https://github.com/chef/inspec/pull/506) ([chris-rock](https://github.com/chris-rock))
|
28
|
+
|
29
|
+
**Merged pull requests:**
|
30
|
+
|
31
|
+
- 0.14.6 [\#510](https://github.com/chef/inspec/pull/510) ([chris-rock](https://github.com/chris-rock))
|
32
|
+
|
14
33
|
## [v0.14.5](https://github.com/chef/inspec/tree/v0.14.5) (2016-02-29)
|
15
34
|
[Full Changelog](https://github.com/chef/inspec/compare/v0.14.4...v0.14.5)
|
16
35
|
|
@@ -8,19 +8,20 @@ require 'uri'
|
|
8
8
|
module Compliance
|
9
9
|
# API Implementation does not hold any state by itself,
|
10
10
|
# everything will be stored in local Configuration store
|
11
|
-
class API
|
11
|
+
class API # rubocop:disable Metrics/ClassLength
|
12
12
|
# logs into the server, retrieves a token and stores it locally
|
13
|
-
def self.login(server, username, password)
|
13
|
+
def self.login(server, username, password, insecure)
|
14
14
|
config = Compliance::Configuration.new
|
15
15
|
config['server'] = server
|
16
16
|
url = "#{server}/oauth/token"
|
17
17
|
|
18
|
-
success, data = Compliance::API.post(url, username, password)
|
18
|
+
success, data = Compliance::API.post(url, username, password, insecure)
|
19
19
|
if !data.nil?
|
20
20
|
tokendata = JSON.parse(data)
|
21
21
|
if tokendata['access_token']
|
22
22
|
config['user'] = username
|
23
23
|
config['token'] = tokendata['access_token']
|
24
|
+
config['insecure'] = insecure
|
24
25
|
config.store
|
25
26
|
success = true
|
26
27
|
msg = 'Successfully authenticated'
|
@@ -36,7 +37,7 @@ module Compliance
|
|
36
37
|
def self.logout
|
37
38
|
config = Compliance::Configuration.new
|
38
39
|
url = "#{config['server']}/logout"
|
39
|
-
Compliance::API.post(url, config['token'], nil)
|
40
|
+
Compliance::API.post(url, config['token'], nil, config['insecure'])
|
40
41
|
config.destroy
|
41
42
|
end
|
42
43
|
|
@@ -45,7 +46,7 @@ module Compliance
|
|
45
46
|
config = Compliance::Configuration.new
|
46
47
|
url = "#{config['server']}/version"
|
47
48
|
|
48
|
-
_success, data = Compliance::API.get(url, nil, nil)
|
49
|
+
_success, data = Compliance::API.get(url, nil, nil, config['insecure'])
|
49
50
|
if !data.nil?
|
50
51
|
JSON.parse(data)
|
51
52
|
else
|
@@ -56,9 +57,8 @@ module Compliance
|
|
56
57
|
# return all compliance profiles available for the user
|
57
58
|
def self.profiles
|
58
59
|
config = Compliance::Configuration.new
|
59
|
-
|
60
60
|
url = "#{config['server']}/user/compliance"
|
61
|
-
_success, data = get(url, config['token'], '')
|
61
|
+
_success, data = get(url, config['token'], '', config['insecure'])
|
62
62
|
|
63
63
|
if !data.nil?
|
64
64
|
profiles = JSON.parse(data)
|
@@ -86,28 +86,33 @@ module Compliance
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
def self.get(url, username, password)
|
89
|
+
def self.get(url, username, password, insecure)
|
90
90
|
uri = URI.parse(url)
|
91
91
|
req = Net::HTTP::Get.new(uri.path)
|
92
92
|
req.basic_auth username, password
|
93
93
|
|
94
|
-
send_request(uri, req)
|
94
|
+
send_request(uri, req, insecure)
|
95
95
|
end
|
96
96
|
|
97
|
-
def self.post(url, username, password)
|
97
|
+
def self.post(url, username, password, insecure)
|
98
98
|
# form request
|
99
99
|
uri = URI.parse(url)
|
100
100
|
req = Net::HTTP::Post.new(uri.path)
|
101
101
|
req.basic_auth username, password
|
102
102
|
req.form_data={}
|
103
103
|
|
104
|
-
send_request(uri, req)
|
104
|
+
send_request(uri, req, insecure)
|
105
105
|
end
|
106
106
|
|
107
107
|
# upload a file
|
108
|
-
def self.post_file(url, username, password, file_path)
|
108
|
+
def self.post_file(url, username, password, file_path, insecure)
|
109
109
|
uri = URI.parse(url)
|
110
110
|
http = Net::HTTP.new(uri.host, uri.port)
|
111
|
+
|
112
|
+
# set connection flags
|
113
|
+
http.use_ssl = (uri.scheme == 'https')
|
114
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
|
115
|
+
|
111
116
|
req = Net::HTTP::Post.new(uri.path)
|
112
117
|
req.basic_auth username, password
|
113
118
|
|
@@ -123,9 +128,13 @@ module Compliance
|
|
123
128
|
[res.is_a?(Net::HTTPSuccess), res.body]
|
124
129
|
end
|
125
130
|
|
126
|
-
def self.send_request(uri, req)
|
127
|
-
|
128
|
-
|
131
|
+
def self.send_request(uri, req, insecure)
|
132
|
+
opts = {
|
133
|
+
use_ssl: uri.scheme == 'https',
|
134
|
+
}
|
135
|
+
opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if insecure
|
136
|
+
|
137
|
+
res = Net::HTTP.start(uri.host, uri.port, opts) {|http|
|
129
138
|
http.request(req)
|
130
139
|
}
|
131
140
|
[res.is_a?(Net::HTTPSuccess), res.body]
|
@@ -13,8 +13,10 @@ module Compliance
|
|
13
13
|
desc: 'Chef Compliance Username'
|
14
14
|
option :password, type: :string, required: true,
|
15
15
|
desc: 'Chef Compliance Password'
|
16
|
+
option :insecure, aliases: :k, type: :boolean,
|
17
|
+
desc: 'Explicitly allows InSpec to perform "insecure" SSL connections and transfers'
|
16
18
|
def login(server)
|
17
|
-
success, msg = Compliance::API.login(server, options['user'], options['password'])
|
19
|
+
success, msg = Compliance::API.login(server, options['user'], options['password'], options['insecure'])
|
18
20
|
if success
|
19
21
|
puts 'Successfully authenticated'
|
20
22
|
else
|
@@ -112,7 +114,7 @@ module Compliance
|
|
112
114
|
url = "#{config['server']}/owners/#{owner}/compliance/#{profile_name}/tar"
|
113
115
|
|
114
116
|
puts "Uploading to #{url}"
|
115
|
-
success, msg = Compliance::API.post_file(url, config['token'], '', archive_path)
|
117
|
+
success, msg = Compliance::API.post_file(url, config['token'], '', archive_path, config['insecure'])
|
116
118
|
if success
|
117
119
|
puts 'Successfully uploaded profile'
|
118
120
|
else
|
data/lib/inspec/version.rb
CHANGED