inspec 0.9.10 → 0.9.11
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 -2
- data/Gemfile +1 -0
- data/README.md +2 -1
- data/bin/inspec +4 -1
- data/docs/dsl_resource.rst +2 -2
- data/docs/profiles.rst +5 -3
- data/examples/profile/README.md +1 -1
- data/inspec.gemspec +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/etc_group.rb +1 -1
- data/lib/resources/file.rb +5 -1
- data/lib/resources/package.rb +63 -9
- data/lib/resources/port.rb +47 -7
- data/lib/resources/service.rb +53 -15
- data/lib/resources/user.rb +42 -21
- data/lib/utils/parser.rb +85 -0
- data/test/helper.rb +8 -0
- data/test/integration/.kitchen.chef.yml +29 -0
- data/test/integration/.kitchen.ec2.yml +10 -4
- data/test/integration/.kitchen.shell.yml +19 -0
- data/test/integration/.kitchen/default-chef-solaris-1011.yml +6 -0
- data/test/integration/.kitchen/default-chef-windows-server-2008r2-standard.yml +7 -0
- data/test/integration/.kitchen/default-chef-windows-server-2012r2-standard.yml +7 -0
- data/test/integration/.kitchen/default-chris-rock-omnios-r151014.yml +6 -0
- data/test/integration/.kitchen/default-debian-81.yml +6 -0
- data/test/integration/.kitchen/default-omniti-omnios-r151014.yml +1 -0
- data/test/integration/.kitchen/default-windows-2008.yml +5 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/{kitchen-integration-default-fedora-22 → kitchen-integration-default-chef-solaris-1011}/.vagrant/machines/default/virtualbox/creator_uid +0 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/{kitchen-integration-default-fedora-22 → kitchen-integration-default-chef-solaris-1011}/.vagrant/machines/default/virtualbox/synced_folders +0 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/Vagrantfile +8 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/Vagrantfile +7 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/Vagrantfile +8 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/Vagrantfile +8 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/{kitchen-integration-default-fedora-22 → kitchen-integration-default-debian-81}/Vagrantfile +3 -3
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/Vagrantfile +8 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +25 -25
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +25 -25
- data/test/integration/.kitchen/logs/default-aws-linux.log +3 -0
- data/test/integration/.kitchen/logs/default-centos-511-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-centos-511.log +0 -2
- data/test/integration/.kitchen/logs/default-centos-67-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-centos-67.log +0 -2
- data/test/integration/.kitchen/logs/default-centos-7.log +3 -0
- data/test/integration/.kitchen/logs/default-centos-71.log +0 -2
- data/test/integration/.kitchen/logs/default-chef-solaris-1011.log +0 -0
- data/test/integration/.kitchen/logs/default-chef-windows-server-2008r2-standard.log +0 -0
- data/test/integration/.kitchen/logs/default-chef-windows-server-2012r2-standard.log +0 -0
- data/test/integration/.kitchen/logs/default-chris-rock-omnios-r151014.log +23 -0
- data/test/integration/.kitchen/logs/default-debian-6010-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-debian-6010.log +0 -2
- data/test/integration/.kitchen/logs/default-debian-78-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-debian-78.log +0 -2
- data/test/integration/.kitchen/logs/default-debian-8.log +3 -0
- data/test/integration/.kitchen/logs/default-debian-81-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-debian-81.log +240 -2
- data/test/integration/.kitchen/logs/default-dusank-oi-server.log +0 -0
- data/test/integration/.kitchen/logs/default-fedora-21-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-fedora-21.log +0 -2
- data/test/integration/.kitchen/logs/default-fedora-22.log +3 -0
- data/test/integration/.kitchen/logs/default-freebsd-102.log +0 -2
- data/test/integration/.kitchen/logs/default-freebsd-93.log +0 -2
- data/test/integration/.kitchen/logs/default-livinginthepast-smartos-base64.log +0 -0
- data/test/integration/.kitchen/logs/default-mint-172-cinnamon.log +0 -2
- data/test/integration/.kitchen/logs/default-omniti-omnios-r151014.log +0 -0
- data/test/integration/.kitchen/logs/default-opensuse-132-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-opensuse-132-x86-64.log +0 -2
- data/test/integration/.kitchen/logs/default-redhat-65.log +3 -0
- data/test/integration/.kitchen/logs/default-redhat-71.log +3 -0
- data/test/integration/.kitchen/logs/default-suse-11sp3.log +3 -0
- data/test/integration/.kitchen/logs/default-suse-12.log +3 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1004-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-ubuntu-1004.log +0 -2
- data/test/integration/.kitchen/logs/default-ubuntu-1204-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-ubuntu-1204.log +3 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1404-i386.log +0 -2
- data/test/integration/.kitchen/logs/default-ubuntu-1404.log +3 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1510.log +3 -0
- data/test/integration/.kitchen/logs/default-windows-2012r2.log +2 -41
- data/test/integration/.kitchen/logs/default-winrm.log +0 -0
- data/test/integration/.kitchen/logs/kitchen.log +14 -0
- data/test/integration/bootstrap.sh +3 -0
- data/test/integration/cookbooks/os_prepare/recipes/file.rb +2 -0
- data/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +2 -0
- data/test/integration/cookbooks/os_prepare/recipes/mount.rb +24 -20
- data/test/integration/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +1 -2
- data/test/integration/test/integration/default/_debug_spec.rb +1 -1
- data/test/integration/test/integration/default/compare_matcher_spec.rb +15 -13
- data/test/integration/test/integration/default/etc_group_spec.rb +9 -8
- data/test/integration/test/integration/default/file_spec.rb +14 -4
- data/test/integration/test/integration/default/group_spec.rb +17 -7
- data/test/integration/test/integration/default/mount_spec.rb +9 -7
- data/test/integration/test/integration/default/package_spec.rb +16 -0
- data/test/integration/test/integration/default/port_spec.rb +8 -2
- data/test/integration/test/integration/default/service_spec.rb +4 -1
- data/test/integration/test/integration/default/user_spec.rb +37 -14
- data/test/unit/mock/cmd/pkg-info-system-file-system-zfs +8 -0
- data/test/unit/mock/cmd/pkginfo-l-SUNWzfsr +7 -0
- data/test/unit/mock/cmd/s11-netstat-an-finet-finet6 +32 -0
- data/test/unit/resources/file_test.rb +1 -0
- data/test/unit/resources/package_test.rb +18 -0
- data/test/unit/resources/port_test.rb +10 -0
- data/test/unit/utils/passwd_parser_test.rb +2 -0
- data/test/unit/utils/solaris_netstat_parser.rb +124 -0
- metadata +127 -42
- data/lib/extras/compliance/README.md +0 -15
- data/lib/extras/compliance/compliance.rb +0 -245
- data/test/integration/.kitchen/default-aws-linux.yml +0 -4
- data/test/integration/.kitchen/default-centos-7.yml +0 -4
- data/test/integration/.kitchen/default-debian-8.yml +0 -4
- data/test/integration/.kitchen/default-fedora-22.yml +0 -4
- data/test/integration/.kitchen/default-redhat-65.yml +0 -4
- data/test/integration/.kitchen/default-redhat-71.yml +0 -4
- data/test/integration/.kitchen/default-suse-11sp3.yml +0 -4
- data/test/integration/.kitchen/default-suse-12.yml +0 -4
- data/test/integration/.kitchen/default-ubuntu-1204.yml +0 -3
- data/test/integration/.kitchen/default-ubuntu-1404.yml +0 -4
- data/test/integration/.kitchen/default-windows-2012r2.yml +0 -2
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/private_key +0 -27
@@ -1,15 +0,0 @@
|
|
1
|
-
# InSpec Extension for Chef Compliance
|
2
|
-
|
3
|
-
This extensions offers the following features:
|
4
|
-
|
5
|
-
- list profiles available in Chef Compliance
|
6
|
-
- execute profiles from Chef Compliance
|
7
|
-
- upload a local profile to Chef Compliance
|
8
|
-
|
9
|
-
To use the CLI, this extra package adds the following commands:
|
10
|
-
|
11
|
-
* `$ inspec compliance login user password` - retieves a authentication token from Chef Compliance
|
12
|
-
* `$ inspec compliance list` - list all available profiles in Chef Compliance
|
13
|
-
* `$ inspec exec profile` - runs a profile that is stored on Chef Compliance
|
14
|
-
* `$ inspec compliance upload path/to/local/profile` - uploads a local command to Chef Compliance
|
15
|
-
* `$ inspec compliance logout` - removes the authentication token from the local cache and logs out of the Chef Compliance server
|
@@ -1,245 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'thor'
|
6
|
-
require 'net/http'
|
7
|
-
require 'uri'
|
8
|
-
|
9
|
-
# TODO:
|
10
|
-
# - invalidate token
|
11
|
-
# - fix file upload and genereate tar if required
|
12
|
-
# - hook into exec with a new target helper
|
13
|
-
|
14
|
-
class ComplianceCLI < Thor
|
15
|
-
namespace 'compliance'
|
16
|
-
|
17
|
-
desc 'login SERVER', 'Log in to a Chef Compliance SERVER'
|
18
|
-
options :username => :required, :password => :required
|
19
|
-
def login(server)
|
20
|
-
config = Compliance::Configuration.new
|
21
|
-
config['server'] = server
|
22
|
-
url = "#{server}/oauth/token"
|
23
|
-
|
24
|
-
data = post(url, options['username'], options['password'])
|
25
|
-
if !data.nil?
|
26
|
-
tokendata = JSON.parse(data)
|
27
|
-
if tokendata['access_token']
|
28
|
-
config['token'] = tokendata['access_token']
|
29
|
-
puts "Successfully authenticated"
|
30
|
-
else
|
31
|
-
puts 'Reponse does not include a token'
|
32
|
-
end
|
33
|
-
else
|
34
|
-
puts "Authentication failed for Server: #{url}"
|
35
|
-
end
|
36
|
-
config.store
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'list', 'list all available profiles in Chef Compliance'
|
40
|
-
def list
|
41
|
-
profiles = get_profiles
|
42
|
-
if !profiles.empty?
|
43
|
-
# iterate over profiles
|
44
|
-
puts "Available profiles: "
|
45
|
-
profiles.each { |profile|
|
46
|
-
puts " * #{profile[:org]}/#{profile[:name]}"
|
47
|
-
}
|
48
|
-
else
|
49
|
-
puts "Could not reach server #{url}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
desc 'exec PROFILE', 'executes a profile from Chef Compliance'
|
54
|
-
def exec(profile)
|
55
|
-
config = Compliance::Configuration.new
|
56
|
-
profiles = get_profiles
|
57
|
-
if !profiles.empty?
|
58
|
-
# 1. verify that the profile exists (list)
|
59
|
-
index = profiles.index { |p| "#{p[:org]}/#{p[:name]}" == profile }
|
60
|
-
if index >= 0
|
61
|
-
p = profiles[index]
|
62
|
-
# 2. execute the profile with the proper url, inject `inspec exec` with the suitable params`
|
63
|
-
url = "#{config['server']}/owners/#{p[:org]}/compliance/#{p[:name]}/tar"
|
64
|
-
puts "b bin/inspec exec #{url} --user #{config['token']}"
|
65
|
-
end
|
66
|
-
else
|
67
|
-
puts "The profile #{profile} is not available"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
desc 'upload PATH', 'uploads a local profile to Chef Compliance'
|
72
|
-
def upload(path)
|
73
|
-
# 1. detect if tar or folder
|
74
|
-
# 2. archive if folder
|
75
|
-
# 3. check if tar is a compliance profile
|
76
|
-
# 4. show result and confirm upload to the user (skip with --force)
|
77
|
-
# 5. upload tar to server
|
78
|
-
|
79
|
-
# find the tar
|
80
|
-
config = Compliance::Configuration.new
|
81
|
-
tar_path = File.join(Dir.pwd, 'profile.tar.gz')
|
82
|
-
|
83
|
-
owner = 'admin'
|
84
|
-
profile = 'profile'
|
85
|
-
url = "#{config['server']}/owners/#{owner}/compliance/#{profile}/tar"
|
86
|
-
|
87
|
-
puts "Uploading to #{url}"
|
88
|
-
if post_file(url, config['token'], '', tar_path)
|
89
|
-
puts "Successfully uploaded profile"
|
90
|
-
else
|
91
|
-
puts "Error during profile upload"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
desc 'version', 'displays the version of the Chef Compliance server'
|
96
|
-
def version
|
97
|
-
config = Compliance::Configuration.new
|
98
|
-
url = "#{config['server']}/version"
|
99
|
-
|
100
|
-
data = get(url, nil, nil)
|
101
|
-
if !data.nil?
|
102
|
-
info = JSON.parse(data)
|
103
|
-
puts "Chef Compliance version: #{info['version']}"
|
104
|
-
else
|
105
|
-
puts "Could not reach server #{url}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
desc 'logout', 'user logout from Chef Compliance'
|
110
|
-
def logout
|
111
|
-
config = Compliance::Configuration.new
|
112
|
-
url = "#{config['server']}/logout"
|
113
|
-
data = post(url, config['token'], nil)
|
114
|
-
if !data.nil?
|
115
|
-
puts "Successfully logged out"
|
116
|
-
else
|
117
|
-
puts "Could not log out"
|
118
|
-
end
|
119
|
-
config.destroy
|
120
|
-
end
|
121
|
-
|
122
|
-
private
|
123
|
-
|
124
|
-
def get_profiles
|
125
|
-
config = Compliance::Configuration.new
|
126
|
-
|
127
|
-
url = "#{config['server']}/user/compliance"
|
128
|
-
data = get(url, config['token'], '')
|
129
|
-
|
130
|
-
if !data.nil?
|
131
|
-
profiles = JSON.parse(data)
|
132
|
-
val = []
|
133
|
-
# iterate over profiles
|
134
|
-
profiles.each_key { |org|
|
135
|
-
profiles[org].each_key { |name|
|
136
|
-
val.push({ org: org, name: name})
|
137
|
-
}
|
138
|
-
}
|
139
|
-
val
|
140
|
-
else
|
141
|
-
[]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def get(url, username, password)
|
146
|
-
uri = URI.parse(url)
|
147
|
-
req = Net::HTTP::Get.new(uri.path)
|
148
|
-
req.basic_auth username, password
|
149
|
-
|
150
|
-
send_request(uri, req)
|
151
|
-
end
|
152
|
-
|
153
|
-
def post(url, username, password)
|
154
|
-
# form request
|
155
|
-
uri = URI.parse(url)
|
156
|
-
req = Net::HTTP::Post.new(uri.path)
|
157
|
-
req.basic_auth username, password
|
158
|
-
req.form_data={}
|
159
|
-
|
160
|
-
send_request(uri, req)
|
161
|
-
end
|
162
|
-
|
163
|
-
# upload a file
|
164
|
-
def post_file(url, username, password, file_path)
|
165
|
-
uri = URI.parse(url)
|
166
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
167
|
-
req = Net::HTTP::Post.new(uri.path)
|
168
|
-
req.basic_auth username, password
|
169
|
-
|
170
|
-
req.body_stream=File.open(file_path)
|
171
|
-
req["Content-Type"] = "multipart/form-data"
|
172
|
-
req.add_field('Content-Length', File.size(file_path))
|
173
|
-
req.add_field('Content-Type', 'application/x-gtar')
|
174
|
-
|
175
|
-
boundary = "INSPEC-PROFILE-UPLOAD"
|
176
|
-
req.add_field('session', boundary)
|
177
|
-
res=http.request(req)
|
178
|
-
|
179
|
-
# puts "Response #{response.code} #{response.message}"
|
180
|
-
# puts "#{response.body}"
|
181
|
-
# puts "Headers: #{response.to_hash.inspect}"
|
182
|
-
|
183
|
-
res.is_a?(Net::HTTPSuccess)
|
184
|
-
end
|
185
|
-
|
186
|
-
def send_request(uri, req)
|
187
|
-
# send request
|
188
|
-
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') {|http|
|
189
|
-
http.request(req)
|
190
|
-
}
|
191
|
-
if res.is_a?(Net::HTTPSuccess)
|
192
|
-
res.body
|
193
|
-
else
|
194
|
-
nil
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
module Compliance
|
200
|
-
class Configuration
|
201
|
-
|
202
|
-
def initialize
|
203
|
-
@config_path = File.join(ENV['HOME'], '/.inspec')
|
204
|
-
# ensure the directory is available
|
205
|
-
unless File.directory?(@config_path)
|
206
|
-
FileUtils.mkdir_p(@config_path)
|
207
|
-
end
|
208
|
-
# set config file pasth
|
209
|
-
@config_file = File.join(@config_path, '/config.json')
|
210
|
-
@config = {}
|
211
|
-
|
212
|
-
# load the data
|
213
|
-
get
|
214
|
-
end
|
215
|
-
|
216
|
-
# direct access to config
|
217
|
-
def [](key)
|
218
|
-
@config[key]
|
219
|
-
end
|
220
|
-
|
221
|
-
def []=(key, value)
|
222
|
-
@config[key] = value
|
223
|
-
end
|
224
|
-
|
225
|
-
# return the json data
|
226
|
-
def get
|
227
|
-
if File.exists?(@config_file)
|
228
|
-
file = File.read(@config_file)
|
229
|
-
@config = JSON.parse(file)
|
230
|
-
end
|
231
|
-
@config
|
232
|
-
end
|
233
|
-
|
234
|
-
# stores a hash to json
|
235
|
-
def store
|
236
|
-
File.open(@config_file,"w") do |f|
|
237
|
-
f.write(@config.to_json)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def destroy
|
242
|
-
File.delete(@config_file)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
1447703787
|
@@ -1 +0,0 @@
|
|
1
|
-
770084ca-8622-45fc-9f86-9eff5d9f6662
|
@@ -1 +0,0 @@
|
|
1
|
-
f51e44a0bf9e44db901d78ce3ecd74af
|
@@ -1,27 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIEogIBAAKCAQEAwLGEO0LYDlsK9XekX6zmTVq0Elm/NwUtKQ7rFcBtGXzdpee0
|
3
|
-
XyhnpgnEIVL1MYL3gu3xxqNUKCrcoM1PPw8cZZqI9rT/GEEoy708wAkBbkLD81D8
|
4
|
-
ABUJ7SyP24Gj8sewuTkppkgFvYwM5yIqyP8WjCnCGr4KRUC1HCAH1U+9LJfaaarW
|
5
|
-
a5EJVDbfsrz9YoUG1fLm1nSReECFtgl7z1ZYdamjl1nd3m+OFJ5I9TRs38VEP0qg
|
6
|
-
L6XhdCyYwLqKhcF3pGF/CXkuBmlv4p722PAa/dL3RhoE2pAHAbncPuzySY/KQgLo
|
7
|
-
lsLN48LVpSBcwhXzZeyzsnr7XcsyP1s6V6ntfQIDAQABAoIBAEStgFGWy2aicE94
|
8
|
-
qu8mspaTY2a+8fXsNGJT3NnN0ZSp+l2tLY5U2kxFYs/1v0o8QXc601dW0yHV1PjC
|
9
|
-
9CGngxl7cKFtdRXx81ZaRhKzovzncut/y7FDzlvn7AXyOLrJDWWWyA9p0BH0noyq
|
10
|
-
ktE8iY6/O11IqmRwYZx6lhAi8Wu4vQ4ytVQhv15qNubka65RR9ylq0+dTPV4OIoW
|
11
|
-
H9tASvvTh3vb/zpBcBKvX4x9n6F9I2Vf0GgXwA+2E+/1frnatYqU8VjgXsc4D0yC
|
12
|
-
pWQyumGrytS6/jBnd64laqnvT1QFitaWob08WPHWYnXiBr0mlHGRpl5iz6l3sJKV
|
13
|
-
6a3LX8kCgYEA7J8jpd/ONFuPQDTrPQQJ7coDL0Dmxu5ihUVDgT/FfAz4OM9KF+ej
|
14
|
-
ptiDbl/UrSZQm1GcT3CwLOevgPcsK7rTBFOBwRxvi9Wf3I6g4QozeXcPEcZWmDAn
|
15
|
-
u+Lg6fMceKu8lwbTBLLqf02wk2IJkXgixXJJ6khxRy0qPujgQqERjbsCgYEA0Hln
|
16
|
-
6lmTOlN+mMs5pPu43ZRNy//QVUKBdOsZjyOnU3mydHRr+j1e3wN4csX6odBU2D9X
|
17
|
-
JKqd2Xep1biTGPEZjRnqgVeGzHpoDJTgGaJevhr2WZ+zySEmbIInTOtS/jGvhwG9
|
18
|
-
y23Zr5nIeVJGJ91eBT7GidjDYo7YvFabRjuXoicCgYAqR20ZMFop5Mo90LbPmi8j
|
19
|
-
+9qB0PjrRqD36x5as8hXmAGqNO+qQctt/nXNfPYFUjlI51Yko5/3BhbH1mJgFeuq
|
20
|
-
dDlVBf2wYKVFxX5dd3MnGuzoYiYK31/aJHnHk5bcwOLboW6HAmkAAiOw0e2fvnWI
|
21
|
-
DhnC8Nq8uwc3YmjfvuPiDQKBgDJFBCy7WsgWuBEp+AVzeXlcuIG3dsoIVmUWB7y/
|
22
|
-
USrMzp5MMHlP8R9/m7y5Rp1cOglHBMFfrt5wf3B8qGO8R3gBxs1XiLan0Y0vHPax
|
23
|
-
c30NzVeBLf4S00wY+lcO651F59h7MAPswjAYugGfODGGrJRBNeipbzvFzDdl/t0p
|
24
|
-
o3/DAoGAPM0tH/0E71pE3X2DGIAxgcma/waVurPGxw9+QqgksQW3+tkCg2EYuN8V
|
25
|
-
dAKKa9aI739+1Em3S0Cr4dfSon8zyEBpyZhxlpY+/KypzrQgTEYS/l8u4Vdk0L74
|
26
|
-
wL55wMiM0la2sLqUtgFF5zqSGCg7LLWNMc6owmlG5RZrneDjams=
|
27
|
-
-----END RSA PRIVATE KEY-----
|