inspec 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -2
  3. data/Gemfile +1 -0
  4. data/README.md +2 -1
  5. data/bin/inspec +4 -1
  6. data/docs/dsl_resource.rst +2 -2
  7. data/docs/profiles.rst +5 -3
  8. data/examples/profile/README.md +1 -1
  9. data/inspec.gemspec +1 -1
  10. data/lib/inspec/version.rb +1 -1
  11. data/lib/resources/etc_group.rb +1 -1
  12. data/lib/resources/file.rb +5 -1
  13. data/lib/resources/package.rb +63 -9
  14. data/lib/resources/port.rb +47 -7
  15. data/lib/resources/service.rb +53 -15
  16. data/lib/resources/user.rb +42 -21
  17. data/lib/utils/parser.rb +85 -0
  18. data/test/helper.rb +8 -0
  19. data/test/integration/.kitchen.chef.yml +29 -0
  20. data/test/integration/.kitchen.ec2.yml +10 -4
  21. data/test/integration/.kitchen.shell.yml +19 -0
  22. data/test/integration/.kitchen/default-chef-solaris-1011.yml +6 -0
  23. data/test/integration/.kitchen/default-chef-windows-server-2008r2-standard.yml +7 -0
  24. data/test/integration/.kitchen/default-chef-windows-server-2012r2-standard.yml +7 -0
  25. data/test/integration/.kitchen/default-chris-rock-omnios-r151014.yml +6 -0
  26. data/test/integration/.kitchen/default-debian-81.yml +6 -0
  27. data/test/integration/.kitchen/default-omniti-omnios-r151014.yml +1 -0
  28. data/test/integration/.kitchen/default-windows-2008.yml +5 -0
  29. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  30. 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
  31. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/id +1 -0
  32. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  33. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/private_key +27 -0
  34. 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
  35. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/Vagrantfile +8 -0
  36. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  37. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  38. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/id +1 -0
  39. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  40. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  41. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/Vagrantfile +7 -0
  42. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  43. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  44. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/id +1 -0
  45. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  46. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  47. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2012r2-standard/Vagrantfile +8 -0
  48. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  49. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  50. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/id +1 -0
  51. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  52. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +27 -0
  53. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  54. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/Vagrantfile +8 -0
  55. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  56. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  57. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/id +1 -0
  58. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  59. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key +27 -0
  60. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  61. data/test/integration/.kitchen/kitchen-vagrant/{kitchen-integration-default-fedora-22 → kitchen-integration-default-debian-81}/Vagrantfile +3 -3
  62. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  63. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  64. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/id +1 -0
  65. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  66. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +27 -0
  67. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/Vagrantfile +8 -0
  68. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -1
  69. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -1
  70. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -1
  71. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +25 -25
  72. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -1
  73. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -1
  74. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -1
  75. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +25 -25
  76. data/test/integration/.kitchen/logs/default-aws-linux.log +3 -0
  77. data/test/integration/.kitchen/logs/default-centos-511-i386.log +0 -2
  78. data/test/integration/.kitchen/logs/default-centos-511.log +0 -2
  79. data/test/integration/.kitchen/logs/default-centos-67-i386.log +0 -2
  80. data/test/integration/.kitchen/logs/default-centos-67.log +0 -2
  81. data/test/integration/.kitchen/logs/default-centos-7.log +3 -0
  82. data/test/integration/.kitchen/logs/default-centos-71.log +0 -2
  83. data/test/integration/.kitchen/logs/default-chef-solaris-1011.log +0 -0
  84. data/test/integration/.kitchen/logs/default-chef-windows-server-2008r2-standard.log +0 -0
  85. data/test/integration/.kitchen/logs/default-chef-windows-server-2012r2-standard.log +0 -0
  86. data/test/integration/.kitchen/logs/default-chris-rock-omnios-r151014.log +23 -0
  87. data/test/integration/.kitchen/logs/default-debian-6010-i386.log +0 -2
  88. data/test/integration/.kitchen/logs/default-debian-6010.log +0 -2
  89. data/test/integration/.kitchen/logs/default-debian-78-i386.log +0 -2
  90. data/test/integration/.kitchen/logs/default-debian-78.log +0 -2
  91. data/test/integration/.kitchen/logs/default-debian-8.log +3 -0
  92. data/test/integration/.kitchen/logs/default-debian-81-i386.log +0 -2
  93. data/test/integration/.kitchen/logs/default-debian-81.log +240 -2
  94. data/test/integration/.kitchen/logs/default-dusank-oi-server.log +0 -0
  95. data/test/integration/.kitchen/logs/default-fedora-21-i386.log +0 -2
  96. data/test/integration/.kitchen/logs/default-fedora-21.log +0 -2
  97. data/test/integration/.kitchen/logs/default-fedora-22.log +3 -0
  98. data/test/integration/.kitchen/logs/default-freebsd-102.log +0 -2
  99. data/test/integration/.kitchen/logs/default-freebsd-93.log +0 -2
  100. data/test/integration/.kitchen/logs/default-livinginthepast-smartos-base64.log +0 -0
  101. data/test/integration/.kitchen/logs/default-mint-172-cinnamon.log +0 -2
  102. data/test/integration/.kitchen/logs/default-omniti-omnios-r151014.log +0 -0
  103. data/test/integration/.kitchen/logs/default-opensuse-132-i386.log +0 -2
  104. data/test/integration/.kitchen/logs/default-opensuse-132-x86-64.log +0 -2
  105. data/test/integration/.kitchen/logs/default-redhat-65.log +3 -0
  106. data/test/integration/.kitchen/logs/default-redhat-71.log +3 -0
  107. data/test/integration/.kitchen/logs/default-suse-11sp3.log +3 -0
  108. data/test/integration/.kitchen/logs/default-suse-12.log +3 -0
  109. data/test/integration/.kitchen/logs/default-ubuntu-1004-i386.log +0 -2
  110. data/test/integration/.kitchen/logs/default-ubuntu-1004.log +0 -2
  111. data/test/integration/.kitchen/logs/default-ubuntu-1204-i386.log +0 -2
  112. data/test/integration/.kitchen/logs/default-ubuntu-1204.log +3 -0
  113. data/test/integration/.kitchen/logs/default-ubuntu-1404-i386.log +0 -2
  114. data/test/integration/.kitchen/logs/default-ubuntu-1404.log +3 -0
  115. data/test/integration/.kitchen/logs/default-ubuntu-1510.log +3 -0
  116. data/test/integration/.kitchen/logs/default-windows-2012r2.log +2 -41
  117. data/test/integration/.kitchen/logs/default-winrm.log +0 -0
  118. data/test/integration/.kitchen/logs/kitchen.log +14 -0
  119. data/test/integration/bootstrap.sh +3 -0
  120. data/test/integration/cookbooks/os_prepare/recipes/file.rb +2 -0
  121. data/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +2 -0
  122. data/test/integration/cookbooks/os_prepare/recipes/mount.rb +24 -20
  123. data/test/integration/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +1 -2
  124. data/test/integration/test/integration/default/_debug_spec.rb +1 -1
  125. data/test/integration/test/integration/default/compare_matcher_spec.rb +15 -13
  126. data/test/integration/test/integration/default/etc_group_spec.rb +9 -8
  127. data/test/integration/test/integration/default/file_spec.rb +14 -4
  128. data/test/integration/test/integration/default/group_spec.rb +17 -7
  129. data/test/integration/test/integration/default/mount_spec.rb +9 -7
  130. data/test/integration/test/integration/default/package_spec.rb +16 -0
  131. data/test/integration/test/integration/default/port_spec.rb +8 -2
  132. data/test/integration/test/integration/default/service_spec.rb +4 -1
  133. data/test/integration/test/integration/default/user_spec.rb +37 -14
  134. data/test/unit/mock/cmd/pkg-info-system-file-system-zfs +8 -0
  135. data/test/unit/mock/cmd/pkginfo-l-SUNWzfsr +7 -0
  136. data/test/unit/mock/cmd/s11-netstat-an-finet-finet6 +32 -0
  137. data/test/unit/resources/file_test.rb +1 -0
  138. data/test/unit/resources/package_test.rb +18 -0
  139. data/test/unit/resources/port_test.rb +10 -0
  140. data/test/unit/utils/passwd_parser_test.rb +2 -0
  141. data/test/unit/utils/solaris_netstat_parser.rb +124 -0
  142. metadata +127 -42
  143. data/lib/extras/compliance/README.md +0 -15
  144. data/lib/extras/compliance/compliance.rb +0 -245
  145. data/test/integration/.kitchen/default-aws-linux.yml +0 -4
  146. data/test/integration/.kitchen/default-centos-7.yml +0 -4
  147. data/test/integration/.kitchen/default-debian-8.yml +0 -4
  148. data/test/integration/.kitchen/default-fedora-22.yml +0 -4
  149. data/test/integration/.kitchen/default-redhat-65.yml +0 -4
  150. data/test/integration/.kitchen/default-redhat-71.yml +0 -4
  151. data/test/integration/.kitchen/default-suse-11sp3.yml +0 -4
  152. data/test/integration/.kitchen/default-suse-12.yml +0 -4
  153. data/test/integration/.kitchen/default-ubuntu-1204.yml +0 -3
  154. data/test/integration/.kitchen/default-ubuntu-1404.yml +0 -4
  155. data/test/integration/.kitchen/default-windows-2012r2.yml +0 -2
  156. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  157. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/id +0 -1
  158. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  159. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/private_key +0 -27
@@ -38,7 +38,7 @@
38
38
  require 'utils/parser'
39
39
  require 'utils/convert'
40
40
 
41
- class User < Inspec.resource(1)
41
+ class User < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
42
42
  name 'user'
43
43
  desc 'Use the user InSpec audit resource to test user profiles, including the groups to which they belong, the frequency of required password changes, the directory paths to home and shell.'
44
44
  example "
@@ -53,63 +53,65 @@ class User < Inspec.resource(1)
53
53
 
54
54
  # select package manager
55
55
  @user_provider = nil
56
- case inspec.os[:family]
57
- when 'ubuntu', 'debian', 'redhat', 'fedora', 'centos', 'arch', 'opensuse', 'wrlinux'
56
+ os = inspec.os
57
+ if os.linux?
58
58
  @user_provider = LinuxUser.new(inspec)
59
- when 'windows'
59
+ elsif os.windows?
60
60
  @user_provider = WindowsUser.new(inspec)
61
- when 'darwin'
61
+ elsif ['darwin'].include?(os[:family])
62
62
  @user_provider = DarwinUser.new(inspec)
63
- when 'freebsd'
63
+ elsif ['freebsd'].include?(os[:family])
64
64
  @user_provider = FreeBSDUser.new(inspec)
65
- when 'aix'
65
+ elsif ['aix'].include?(os[:family])
66
66
  @user_provider = AixUser.new(inspec)
67
+ elsif os.solaris?
68
+ @user_provider = SolarisUser.new(inspec)
67
69
  else
68
70
  return skip_resource 'The `user` resource is not supported on your OS yet.'
69
71
  end
70
72
  end
71
73
 
72
74
  def exists?
73
- !identiy.nil? && !identiy[:user].nil?
75
+ !identity.nil? && !identity[:user].nil?
74
76
  end
75
77
 
76
78
  def uid
77
- identiy.nil? ? nil : identiy[:uid]
79
+ identity[:uid] unless identity.nil?
78
80
  end
79
81
 
80
82
  def gid
81
- identiy.nil? ? nil : identiy[:gid]
83
+ identity[:gid] unless identity.nil?
82
84
  end
83
85
 
84
86
  def group
85
- identiy.nil? ? nil : identiy[:group]
87
+ identity[:group] unless identity.nil?
86
88
  end
87
89
 
88
90
  def groups
89
- identiy.nil? ? nil : identiy[:groups]
91
+ identity[:groups] unless identity.nil?
90
92
  end
91
93
 
92
94
  def home
93
- meta_info.nil? ? nil : meta_info[:home]
95
+ meta_info[:home] unless meta_info.nil?
94
96
  end
95
97
 
96
98
  def shell
97
- meta_info.nil? ? nil : meta_info[:shell]
99
+ meta_info[:shell] unless meta_info.nil?
98
100
  end
99
101
 
100
102
  # returns the minimum days between password changes
101
103
  def mindays
102
- credentials.nil? ? nil : credentials[:mindays]
104
+ credentials[:mindays] unless credentials.nil?
103
105
  end
104
106
 
105
107
  # returns the maximum days between password changes
106
108
  def maxdays
107
- credentials.nil? ? nil : credentials[:maxdays]
109
+ credentials[:maxdays] unless credentials.nil?
108
110
  end
109
111
 
110
112
  # returns the days for password change warning
111
113
  def warndays
112
- credentials.nil? ? nil : credentials[:warndays]
114
+ credentials[:warndays] unless credentials.nil?
113
115
  end
114
116
 
115
117
  # implement 'mindays' method to be compatible with serverspec
@@ -154,13 +156,13 @@ class User < Inspec.resource(1)
154
156
  "User #{@user}"
155
157
  end
156
158
 
157
- private
158
-
159
- def identiy
159
+ def identity
160
160
  return @id_cache if defined?(@id_cache)
161
161
  @id_cache = @user_provider.identity(@user) if !@user_provider.nil?
162
162
  end
163
163
 
164
+ private
165
+
164
166
  def meta_info
165
167
  return @meta_cache if defined?(@meta_cache)
166
168
  @meta_cache = @user_provider.meta_info(@user) if !@user_provider.nil?
@@ -186,6 +188,13 @@ end
186
188
 
187
189
  # implements generic unix id handling
188
190
  class UnixUser < UserInfo
191
+ attr_reader :inspec, :id_cmd
192
+ def initialize(inspec)
193
+ @inspec = inspec
194
+ @id_cmd ||= 'id'
195
+ super
196
+ end
197
+
189
198
  # parse one id entry like '0(wheel)''
190
199
  def parse_value(line)
191
200
  SimpleConfig.new(
@@ -199,7 +208,7 @@ class UnixUser < UserInfo
199
208
 
200
209
  # extracts the identity
201
210
  def identity(username)
202
- cmd = inspec.command("id #{username}")
211
+ cmd = inspec.command("#{id_cmd} #{username}")
203
212
  return nil if cmd.exit_status != 0
204
213
 
205
214
  # parse words
@@ -265,6 +274,18 @@ class LinuxUser < UnixUser
265
274
  end
266
275
  end
267
276
 
277
+ class SolarisUser < LinuxUser
278
+ def initialize(inspec)
279
+ @inspec = inspec
280
+ @id_cmd ||= 'id -a'
281
+ super
282
+ end
283
+
284
+ def credentials(_username)
285
+ nil
286
+ end
287
+ end
288
+
268
289
  class AixUser < UnixUser
269
290
  def identity(username)
270
291
  id = super(username)
@@ -92,3 +92,88 @@ module MountParser
92
92
  mount_options
93
93
  end
94
94
  end
95
+
96
+ module SolarisNetstatParser
97
+ # takes this as a input and parses the values
98
+ # UDP: IPv4
99
+ # Local Address Remote Address State
100
+ # -------------------- -------------------- ----------
101
+ # *.* Unbound
102
+ def parse_netstat(content) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
103
+ return [] if content.nil? || content.empty?
104
+
105
+ protocol = nil
106
+ column_widths = nil
107
+ ports = []
108
+ cache_name_line = nil
109
+
110
+ content.each_line { |line|
111
+ # find header, its delimiter
112
+ if line =~ /TCP:|UDP:|SCTP:/
113
+ # get protocol
114
+ protocol = line.split(':')[0].chomp.strip.downcase
115
+
116
+ # determine version tcp, tcp6, udp, udp6
117
+ proto_version = line.split(':')[1].chomp.strip
118
+ protocol += '6' if proto_version == 'IPv6'
119
+
120
+ # reset names cache
121
+ column_widths = nil
122
+ cache_name_line = nil
123
+ names = nil
124
+ # calulate width of a column based on the horizontal line
125
+ elsif line =~ /^[- ]+$/
126
+ column_widths = columns(line)
127
+ # parse header values from line
128
+ elsif column_widths.nil? && !line.nil?
129
+ # we do not know the width at this point of time, therefore we need to cache
130
+ cache_name_line = line
131
+ # content line
132
+ elsif !column_widths.nil? && !line.nil? && !line.chomp.empty?
133
+ # default row
134
+ port = split_columns(column_widths, line).to_a.map { |v| v.chomp.strip }
135
+
136
+ # parse the header names
137
+ # TODO: names should be optional
138
+ names = split_columns(column_widths, cache_name_line).to_a.map { |v| v.chomp.strip.downcase.tr(' ', '-').gsub(/[^\w-]/, '_') }
139
+ info = {
140
+ 'protocol' => protocol.downcase,
141
+ }
142
+
143
+ # generate hash for each line and use the names as keys
144
+ names.each_index { |i|
145
+ info[names[i]] = port[i] if i != 0
146
+ }
147
+
148
+ ports.push(info)
149
+ end
150
+ }
151
+ ports
152
+ end
153
+
154
+ private
155
+
156
+ # takes a line like "-------------------- -------------------- ----------"
157
+ # as input and calculates the length of each column
158
+ def columns(line)
159
+ # find all columns
160
+ m = line.scan(/-+/)
161
+ # calculate the length each column
162
+ m.map { |x| x.length } # rubocop:disable Style/SymbolProc
163
+ end
164
+
165
+ # takes a line and the width of the columns to extract the values
166
+ def split_columns(columns, line)
167
+ # generate regex based on columns
168
+ sep = '\\s'
169
+ length = columns.length
170
+ arr = columns.map.with_index { |x, i|
171
+ reg = "(.{#{x}})#{sep}" # add seperator between columns
172
+ reg = "(.{,#{x}})#{sep}" if i == length - 2 # make the pre-last one optional
173
+ reg = "(.{,#{x}})" if i == length - 1 # use , to say max value
174
+ reg
175
+ }
176
+ # extracts the columns
177
+ line.match(Regexp.new(arr.join))
178
+ end
179
+ end
@@ -40,6 +40,8 @@ class MockLoader
40
40
  ubuntu1504: { family: 'ubuntu', release: '15.04', arch: 'x86_64' },
41
41
  windows: { family: 'windows', release: nil, arch: nil },
42
42
  wrlinux: { family: 'wrlinux', release: '7.0(3)I2(2)', arch: 'x86_64' },
43
+ solaris11: { family: "solaris", release: '11', arch: 'i386'},
44
+ solaris10: { family: "solaris", release: '10', arch: 'i386'},
43
45
  undefined: { family: nil, release: nil, arch: nil },
44
46
  }
45
47
 
@@ -202,6 +204,12 @@ class MockLoader
202
204
  # mount
203
205
  "mount | grep -- ' on /'" => cmd.call("mount"),
204
206
  "mount | grep -- ' on /mnt/iso-disk'" => cmd.call("mount-multiple"),
207
+ # solaris 10 package manager
208
+ 'pkginfo -l SUNWzfsr' => cmd.call('pkginfo-l-SUNWzfsr'),
209
+ # solaris 11 package manager
210
+ 'pkg info system/file-system/zfs' => cmd.call('pkg-info-system-file-system-zfs'),
211
+ # port netstat on solaris 10 & 11
212
+ 'netstat -an -f inet -f inet6' => cmd.call('s11-netstat-an-finet-finet6'),
205
213
  }
206
214
 
207
215
  @backend
@@ -0,0 +1,29 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ provisioner:
6
+ name: chef_zero
7
+ require_chef_omnibus: 12.6.0
8
+
9
+ verifier:
10
+ name: inspec
11
+ sudo: true
12
+
13
+ platforms:
14
+ - name: chef/windows-server-2008r2-standard
15
+ transport:
16
+ name: winrm
17
+ username: administrator
18
+ - name: chef/windows-server-2012r2-standard
19
+ transport:
20
+ name: winrm
21
+ username: administrator
22
+ - name: chef/solaris-10.11
23
+ - name: chris-rock/omnios-r151014
24
+
25
+ suites:
26
+ - name: default
27
+ run_list:
28
+ - recipe[os_prepare]
29
+ attributes:
@@ -1,23 +1,29 @@
1
1
  driver:
2
2
  name: ec2
3
3
  region: eu-central-1
4
- instance_type: m3.large
4
+ instance_type: m3.medium
5
5
  associate_public_ip: true
6
+ security_group_ids: ["travis-ci"]
6
7
  interface: dns
7
8
 
8
9
  transport:
9
- ssh_key: /path/to/aws.pem
10
10
  username: ec2-user
11
+ ssh_key: <%= ENV['EC2_SSH_KEY_PATH'] %>
11
12
 
12
13
  platforms:
14
+ - name: windows-2008
15
+ driver:
16
+ image_id: ami-58918e34
17
+ transport:
18
+ username: administrator
13
19
  - name: windows-2012
14
20
  driver:
15
- image_id: ami-58f7fb45
21
+ image_id: ami-44918e28
16
22
  transport:
17
23
  username: administrator
18
24
  - name: windows-2012r2
19
25
  driver:
20
- image_id: ami-f2f5f9ef
26
+ image_id: ami-8a918ee6
21
27
  transport:
22
28
  username: administrator
23
29
  - name: suse-11sp3
@@ -0,0 +1,19 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ provisioner:
6
+ name: shell
7
+
8
+ verifier:
9
+ name: inspec
10
+ sudo: true
11
+
12
+ platforms:
13
+ - name: chris-rock/omnios-r151014
14
+
15
+ suites:
16
+ - name: default
17
+ run_list:
18
+ - recipe[os_prepare]
19
+ attributes:
@@ -0,0 +1,6 @@
1
+ ---
2
+ hostname: 127.0.0.1
3
+ port: '2203'
4
+ username: vagrant
5
+ ssh_key: "/Users/chartmann/Development/compliance/inspec/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/private_key"
6
+ last_action: verify
@@ -0,0 +1,7 @@
1
+ ---
2
+ hostname: 127.0.0.1
3
+ port: '5985'
4
+ username: vagrant
5
+ password: vagrant
6
+ rdp_port: '3389'
7
+ last_action: setup
@@ -0,0 +1,7 @@
1
+ ---
2
+ hostname: 127.0.0.1
3
+ port: '2201'
4
+ username: vagrant
5
+ password: vagrant
6
+ rdp_port: '3389'
7
+ last_action: setup
@@ -0,0 +1,6 @@
1
+ ---
2
+ hostname: 127.0.0.1
3
+ port: '2200'
4
+ username: vagrant
5
+ ssh_key: "/Users/chartmann/Development/compliance/inspec/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/private_key"
6
+ last_action: setup
@@ -0,0 +1,6 @@
1
+ ---
2
+ hostname: 127.0.0.1
3
+ port: '2206'
4
+ username: vagrant
5
+ ssh_key: "/Users/chartmann/Development/compliance/inspec/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key"
6
+ last_action: setup
@@ -0,0 +1,5 @@
1
+ ---
2
+ server_id: i-0c29a8b0
3
+ hostname: ec2-52-29-149-42.eu-central-1.compute.amazonaws.com
4
+ password: T2GSmM)6LVn
5
+ last_action: create
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEogIBAAKCAQEApWAcKLP2eoi1xXjpwfDbzdwnlDdoX0eSR8LAfBMlk07PKNCT
3
+ m20KFvqoJPP0AAMld1AQb4iMUdipJvvlZixc9guIAPIS7J08/0Lu+YKRcVlBBsnj
4
+ 70IBEIv3H2bUCcSwyTT1M7E/8WTMS84s214GMREFh4ncidK3GX1CxgQfWDkEG67W
5
+ 4RorboUiqtV6Cha3aXKcyyOKMdCu/GR5A+QpykzeOm3K/pkw6kifpnrMrfMOgE9h
6
+ OE1V698/1l15879TZxR8q5S5GuA/oJzuAvqR9zeNTCtlYeFunZsvFCueqeRoMeJX
7
+ FPIy1gXmKHFo97LEp2uvVySU58XrTgbI+zzWRQIDAQABAoIBAAyf4KZuzpMeGpo/
8
+ l8C5bV4yv0a+UBZt9UnLITyXjZfIPWJFQe9sjIeijPF9OhRCKTsJfqe1Cdk5q/gQ
9
+ 5Ls/Cb2ytag00qMDgeOOrYWYpRe9E4y8Hs1mAYTM2omoJOm1/TTu+QUAM/xukHX9
10
+ AEmizOA0B3MIYDCZSGcGu/E34VivqiW4L88E9Ot4ZcRw4k/xElTN4c9DynLtfZeV
11
+ GC4YzQ58VcY3MRNo6ogbtYLpAQ3wpFvU21pMBvlWO3JDWr3On3ORiSydncQun7og
12
+ ZTFWc5dTJE1MVZjKbKw+surEMnsWUUtSuzzkTQc7x9D8Bb4SvVRbYQYKnEciIJyF
13
+ mskiG+UCgYEA1BOnIufVYg1eMnu3TeYSJR7n2V76SRgC5VXzNSixZRWmgZjAmNNh
14
+ ean7YRgagZ4ndD2U7J9r7mbkv8FltqrHcQdArsflyAZirdPQ78JsYheY4xEsubVA
15
+ oaVrd0vWU0qBUHDZRj3QZKY2VoVVCVodQfo/l9LjIOod3HbRXHUfwQMCgYEAx6BY
16
+ EB57FJOWuyE3t/Gy5Csc+UvXtICA9LshgRiaOY/JtN7TWnWeQxh6zfO3VYDK7A5f
17
+ Aam/NZxaMrBG3s5L/k2PgaOuaRUVpjqzxhT6NYN6QGPLm+hkjPk970cFw8Jo9S6W
18
+ avgBn7+1aTiVqKEXDO5TXtM6h2WptV0Od+WZ1RcCgYB/AYYGkXBo2DihYxXTwQT8
19
+ 1hVjSE37mDWjwmV0YHpcXyroUeKFo5Gsmu/Apf65wU0/f+HAE3k/vL8hV2DilEP8
20
+ nKtQAMbLk4dlMoTeEUF3PUqCMbbnQHUEWVyShQhFuUjYM7zrI/m5TREdn5vdjeoX
21
+ qRaMhe8ftxVLAp0/EaWCoQKBgCKka8PYVkma1ySAPjgYpI+9/5gvli5Hwpk1xDmv
22
+ +EuW7U0LAiiHksBYBi+pZJ5c7FoMoGYcfAckq+5x8sqFiGCIOygnLIQl2YzwUPRF
23
+ /am9uEBmURYsPQ7NzfaxH4n6OdaakBXeFgIP9b5dyHLsCaD/1s304ApRFSNZE8Kw
24
+ wIJfAoGAZJxLJauryB94O3ITA3Aqb5BwQwng7jROI5XLFX3iMax5QNMIe0ZgNCro
25
+ nNZOTJUR/1DbIQDqOYAvPtSHPhKYuN1I7TpBILhtOvNfvcbMtT0cHwFiuKgsb2lR
26
+ Coyj34c6ZDe2QM/ShuIkN7ViDSd5DDQAE+cQV9/qaR+SkCWpFhI=
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,8 @@
1
+ Vagrant.configure("2") do |c|
2
+ c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")
3
+ c.vm.box = "chef/solaris-10.11"
4
+ c.vm.hostname = "default-chef-solaris-1011"
5
+ c.vm.synced_folder ".", "/vagrant", disabled: true
6
+ c.vm.provider :virtualbox do |p|
7
+ end
8
+ end