omnibus 8.2.2 → 8.3.2

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: af0b9ab4b9d9903d007df7fe7ef6400f29c440f6de01c3c76f2fb18690f04001
4
- data.tar.gz: aa35f665517e110e781329b7e97ea9ff154633fb25c80d274bae96d4f46a6bde
3
+ metadata.gz: 0ead593d30d6adc565642ff443cce0b239294752253a6811d94f830160af190c
4
+ data.tar.gz: b75f1260a3b3acfb23bc31f9f376edb1be0799567d5623a2c33a3d350041468f
5
5
  SHA512:
6
- metadata.gz: f8a052707df85029b1a29c3b55a24abd7f81d9b288707bc98512c1bc185c1f309c753d72e792dc68e814c67ccc06f059cddf1b16c593f913de68cfb356d8a903
7
- data.tar.gz: 46626cb42cca8480b546bd4281b853bc2c5a51063350109cff57a2f51c766963be06737af5ff26f0610c9ac9b9d2cf53ba5ae6da5df5077901569baf2bd00bfb
6
+ metadata.gz: c403ea34e2b0352ed171abc7d329a797f36f1b8bd9d79c4bd2f4da1c3d5c187a9caa7bcad4fca8d7ab4577b9d3c079b05927fe872d145ccd0e2ffa1b9c302820
7
+ data.tar.gz: 3230fb144ca86a372f6de1e3e5fd21f1e9e0c72c95c2a8ef0194bca0b0f8437a7881d1de882666c9980d2a9c2ccaba371646ae69648eb6191d55266875d3258e
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2012-2018 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
15
15
  #
16
16
 
17
17
  require "singleton" unless defined?(Singleton)
18
+ require "omnibus/sugarable" unless defined?(Sugarable)
18
19
 
19
20
  module Omnibus
20
21
  class Config
@@ -22,6 +23,7 @@ module Omnibus
22
23
  include NullArgumentable
23
24
  include Singleton
24
25
  include Util
26
+ include Sugarable
25
27
 
26
28
  class << self
27
29
  #
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright 2012-2018 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -66,20 +66,25 @@ module Omnibus
66
66
  def run!
67
67
  measure("Health check time") do
68
68
  log.info(log_key) { "Running health on #{project.name}" }
69
- bad_libs = case Ohai["platform"]
70
- when "mac_os_x"
71
- health_check_otool
72
- when "aix"
73
- health_check_aix
74
- when "windows"
75
- # TODO: objdump -p will provided a very limited check of
76
- # explicit dependencies on windows. Most dependencies are
77
- # implicit and hence not detected.
78
- log.warn(log_key) { "Skipping dependency health checks on Windows." }
79
- {}
80
- else
81
- health_check_ldd
82
- end
69
+ bad_libs, good_libs =
70
+ case Ohai["platform"]
71
+ when "mac_os_x"
72
+ health_check_otool
73
+ when "aix"
74
+ health_check_aix
75
+ when "windows"
76
+ # TODO: objdump -p will provided a very limited check of
77
+ # explicit dependencies on windows. Most dependencies are
78
+ # implicit and hence not detected.
79
+ log.warn(log_key) { "Skipping dependency health checks on Windows." }
80
+ [{}, {}]
81
+ when "solaris2"
82
+ health_check_solaris
83
+ when "freebsd", "openbsd", "netbsd"
84
+ health_check_freebsd
85
+ else
86
+ health_check_linux
87
+ end
83
88
 
84
89
  unresolved = []
85
90
  unreliable = []
@@ -167,6 +172,10 @@ module Omnibus
167
172
  raise HealthCheckFailed
168
173
  end
169
174
 
175
+ if good_libs.keys.length == 0 && !windows?
176
+ raise "Internal error: no good libraries were found"
177
+ end
178
+
170
179
  conflict_map = {}
171
180
 
172
181
  conflict_map = relocation_check if relocation_checkable?
@@ -280,19 +289,20 @@ module Omnibus
280
289
  def health_check_otool
281
290
  current_library = nil
282
291
  bad_libs = {}
292
+ good_libs = {}
283
293
 
284
- read_shared_libs("find #{project.install_dir}/ -type f | egrep '\.(dylib|bundle)$' | xargs otool -L") do |line|
294
+ read_shared_libs("find #{project.install_dir}/ -type f | egrep '\.(dylib|bundle)$'", "xargs otool -L") do |line|
285
295
  case line
286
296
  when /^(.+):$/
287
297
  current_library = Regexp.last_match[1]
288
298
  when /^\s+(.+) \(.+\)$/
289
299
  linked = Regexp.last_match[1]
290
300
  name = File.basename(linked)
291
- bad_libs = check_for_bad_library(bad_libs, current_library, name, linked)
301
+ bad_libs, good_libs = check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
292
302
  end
293
303
  end
294
304
 
295
- bad_libs
305
+ [bad_libs, good_libs]
296
306
  end
297
307
 
298
308
  #
@@ -304,8 +314,9 @@ module Omnibus
304
314
  def health_check_aix
305
315
  current_library = nil
306
316
  bad_libs = {}
317
+ good_libs = {}
307
318
 
308
- read_shared_libs("find #{project.install_dir}/ -type f | xargs file | grep \"RISC System\" | awk -F: '{print $1}' | xargs -n 1 ldd") do |line|
319
+ read_shared_libs("find #{project.install_dir}/ -type f | xargs file | grep \"XCOFF\" | awk -F: '{print $1}'", "xargs -n 1 ldd") do |line|
309
320
  case line
310
321
  when /^(.+) needs:$/
311
322
  current_library = Regexp.last_match[1]
@@ -313,31 +324,63 @@ module Omnibus
313
324
  when /^\s+(.+)$/
314
325
  name = Regexp.last_match[1]
315
326
  linked = Regexp.last_match[1]
316
- bad_libs = check_for_bad_library(bad_libs, current_library, name, linked)
327
+ ( bad_libs, good_libs ) = check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
317
328
  when /File is not an executable XCOFF file/ # ignore non-executable files
318
329
  else
319
330
  log.warn(log_key) { "Line did not match for #{current_library}\n#{line}" }
320
331
  end
321
332
  end
322
333
 
323
- bad_libs
334
+ [bad_libs, good_libs]
324
335
  end
325
336
 
326
337
  #
327
- # Run healthchecks against ldd.
338
+ # Run healthchecks on Solaris.
328
339
  #
329
340
  # @return [Hash<String, Hash<String, Hash<String, Int>>>]
330
341
  # the bad libraries (library_name -> dependency_name -> satisfied_lib_path -> count)
331
342
  #
332
- def health_check_ldd
333
- regexp_ends = ".*(" + IGNORED_ENDINGS.map { |e| e.gsub(/\./, '\.') }.join("|") + ")$"
334
- regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(%r{/}, '\/') + ".*" }.join("|")
335
- regexp = regexp_ends + "|" + regexp_patterns
343
+ def health_check_solaris
344
+ current_library = nil
345
+ bad_libs = {}
346
+ good_libs = {}
336
347
 
348
+ read_shared_libs("find #{project.install_dir}/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'", "xargs -n 1 ldd") do |line|
349
+ case line
350
+ when /^(.+):$/
351
+ current_library = Regexp.last_match[1]
352
+ log.debug(log_key) { "Analyzing dependencies for #{current_library}" }
353
+ when /^\s+(.+) \=\>\s+(.+)( \(.+\))?$/
354
+ name = Regexp.last_match[1]
355
+ linked = Regexp.last_match[2]
356
+ ( bad_libs, good_libs ) = check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
357
+ when /^\s+(.+) \(.+\)$/
358
+ next
359
+ when /^\s+statically linked$/
360
+ next
361
+ when /^\s+not a dynamic executable$/ # ignore non-executable files
362
+ else
363
+ log.warn(log_key) do
364
+ "Line did not match for #{current_library}\n#{line}"
365
+ end
366
+ end
367
+ end
368
+
369
+ [bad_libs, good_libs]
370
+ end
371
+
372
+ #
373
+ # Run healthchecks on FreeBSD
374
+ #
375
+ # @return [Hash<String, Hash<String, Hash<String, Int>>>]
376
+ # the bad libraries (library_name -> dependency_name -> satisfied_lib_path -> count)
377
+ #
378
+ def health_check_freebsd
337
379
  current_library = nil
338
380
  bad_libs = {}
381
+ good_libs = {}
339
382
 
340
- read_shared_libs("find #{project.install_dir}/ -type f -regextype posix-extended ! -regex '#{regexp}' | xargs ldd") do |line|
383
+ read_shared_libs("find #{project.install_dir}/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'", "xargs ldd") do |line|
341
384
  case line
342
385
  when /^(.+):$/
343
386
  current_library = Regexp.last_match[1]
@@ -345,16 +388,51 @@ module Omnibus
345
388
  when /^\s+(.+) \=\>\s+(.+)( \(.+\))?$/
346
389
  name = Regexp.last_match[1]
347
390
  linked = Regexp.last_match[2]
348
- bad_libs = check_for_bad_library(bad_libs, current_library, name, linked)
391
+ ( bad_libs, good_libs ) = check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
349
392
  when /^\s+(.+) \(.+\)$/
350
393
  next
351
394
  when /^\s+statically linked$/
352
395
  next
353
- when /^\s+libjvm.so/
396
+ when /^\s+not a dynamic executable$/ # ignore non-executable files
397
+ else
398
+ log.warn(log_key) do
399
+ "Line did not match for #{current_library}\n#{line}"
400
+ end
401
+ end
402
+ end
403
+
404
+ [bad_libs, good_libs]
405
+ end
406
+
407
+ #
408
+ # Run healthchecks against ldd.
409
+ #
410
+ # @return [Hash<String, Hash<String, Hash<String, Int>>>]
411
+ # the bad libraries (library_name -> dependency_name -> satisfied_lib_path -> count)
412
+ #
413
+ def health_check_linux
414
+ current_library = nil
415
+ bad_libs = {}
416
+ good_libs = {}
417
+
418
+ read_shared_libs("find #{project.install_dir}/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'", "xargs ldd") do |line|
419
+ case line
420
+ when /^(.+):$/
421
+ current_library = Regexp.last_match[1]
422
+ log.debug(log_key) { "Analyzing dependencies for #{current_library}" }
423
+ when /^\s+(.+) \=\>\s+(.+)( \(.+\))?$/
424
+ name = Regexp.last_match[1]
425
+ linked = Regexp.last_match[2]
426
+ ( bad_libs, good_libs ) = check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
427
+ when /^\s+(.+) \(.+\)$/
354
428
  next
355
- when /^\s+libjava.so/
429
+ when /^\s+statically linked$/
356
430
  next
357
- when /^\s+libmawt.so/
431
+ when /^\s+libjvm.so/ # FIXME: should remove if it doesn't blow up server
432
+ next
433
+ when /^\s+libjava.so/ # FIXME: should remove if it doesn't blow up server
434
+ next
435
+ when /^\s+libmawt.so/ # FIXME: should remove if it doesn't blow up server
358
436
  next
359
437
  when /^\s+not a dynamic executable$/ # ignore non-executable files
360
438
  else
@@ -364,7 +442,7 @@ module Omnibus
364
442
  end
365
443
  end
366
444
 
367
- bad_libs
445
+ [bad_libs, good_libs]
368
446
  end
369
447
 
370
448
  private
@@ -399,10 +477,40 @@ module Omnibus
399
477
  # @yield [String]
400
478
  # each line
401
479
  #
402
- def read_shared_libs(command)
403
- cmd = shellout(command)
404
- cmd.stdout.each_line do |line|
405
- yield line
480
+ def read_shared_libs(find_command, ldd_command, &output_proc)
481
+ #
482
+ # construct the list of files to check
483
+ #
484
+
485
+ find_output = shellout!(find_command).stdout.lines
486
+
487
+ find_output.reject! { |file| IGNORED_ENDINGS.any? { |ending| file.end_with?("#{ending}\n") } }
488
+
489
+ find_output.reject! { |file| IGNORED_SUBSTRINGS.any? { |substr| file.include?(substr) } }
490
+
491
+ if find_output.empty?
492
+ # probably the find_command is busted, it should never be empty or why are you using omnibus?
493
+ raise "Internal Error: Health Check found no lines"
494
+ end
495
+
496
+ if find_output.any? { |file| file !~ Regexp.new(project.install_dir) }
497
+ # every file in the find output should be within the install_dir
498
+ raise "Internal Error: Health Check lines not matching the install_dir"
499
+ end
500
+
501
+ #
502
+ # feed the list of files to the "ldd" command
503
+ #
504
+
505
+ # this command will typically fail if the last file isn't a valid lib/binary which happens often
506
+ ldd_output = shellout(ldd_command, input: find_output.join).stdout
507
+
508
+ #
509
+ # do the output process to determine if the files are good or bad
510
+ #
511
+
512
+ ldd_output.each_line do |line|
513
+ output_proc.call(line)
406
514
  end
407
515
  end
408
516
 
@@ -420,7 +528,7 @@ module Omnibus
420
528
  #
421
529
  # @return the modified bad_library hash
422
530
  #
423
- def check_for_bad_library(bad_libs, current_library, name, linked)
531
+ def check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
424
532
  safe = nil
425
533
 
426
534
  whitelist_libs = case Ohai["platform"]
@@ -463,10 +571,11 @@ module Omnibus
463
571
  bad_libs[current_library][name][linked] = 1
464
572
  end
465
573
  else
574
+ good_libs[current_library] = true
466
575
  log.debug(log_key) { " -> PASSED: #{name} is either whitelisted or safely provided." }
467
576
  end
468
577
 
469
- bad_libs
578
+ [bad_libs, good_libs]
470
579
  end
471
580
  end
472
581
  end
@@ -431,23 +431,21 @@ module Omnibus
431
431
  end
432
432
 
433
433
  def is_binary?(bin)
434
- is_binary = File.file?(bin) &&
435
- File.executable?(bin) &&
436
- !File.symlink?(bin)
437
- log.debug(log_key) { " removing non-binary file from signing: #{bin}" } unless is_binary
438
- is_binary
434
+ return false unless File.file?(bin) && File.executable?(bin) && !File.symlink?(bin)
435
+
436
+ log.debug(log_key) { " skipping non-binary file from signing: #{bin}" }
437
+ true
439
438
  end
440
439
 
441
440
  def is_macho?(lib)
442
- is_macho = false
443
- if is_binary?(lib)
444
- command = "file #{lib}"
441
+ return false unless File.file?(lib) && File.executable?(lib) && !File.symlink?(lib)
445
442
 
446
- stdout = shellout!(command).stdout
447
- is_macho = stdout.match?(/Mach-O.*(library|bundle)/)
443
+ if shellout!("file #{lib}").stdout.match?(/Mach-O.*(library|bundle)/) # https://rubular.com/r/nRgaQlAbkM9wHL
444
+ log.debug(log_key) { " skipping non-Mach-O library file from signing: #{lib}" }
445
+ return true
448
446
  end
449
- log.debug(log_key) { " removing non-Mach-O library file from signing: #{lib}" } unless is_macho
450
- is_macho
447
+
448
+ false
451
449
  end
452
450
  end
453
451
  end
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Omnibus
18
- VERSION = "8.2.2".freeze
18
+ VERSION = "8.3.2".freeze
19
19
  end
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright 2012-2020, Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -49,12 +49,18 @@ ARCH_WHITELIST_LIBS = [
49
49
  ].freeze
50
50
 
51
51
  AIX_WHITELIST_LIBS = [
52
+ /libc\.a/,
53
+ /libcfg\.a/,
54
+ /libcorcfg\.a/,
55
+ /libcrypt\.a/,
56
+ /libdl\.a/,
57
+ /liblvm\.a/,
58
+ /libodm\.a/,
59
+ /libperfstat\.a/,
52
60
  /libpthread\.a/,
53
61
  /libpthreads\.a/,
54
- /libdl.a/,
55
62
  /librtl\.a/,
56
- /libc\.a/,
57
- /libcrypt\.a/,
63
+ /libsrc\.a/,
58
64
  /unix$/,
59
65
  ].freeze
60
66
 
@@ -177,28 +183,34 @@ FREEBSD_WHITELIST_LIBS = [
177
183
  /libkvm\.so/,
178
184
  /libprocstat\.so/,
179
185
  /libmd\.so/,
186
+ /libdl\.so/,
180
187
  ].freeze
181
188
 
182
189
  IGNORED_ENDINGS = %w{
183
190
  .TXT
184
- .[ch]
185
- .[ch]pp
186
- .[eh]rl
187
191
  .app
188
192
  .appup
189
193
  .bat
190
194
  .beam
195
+ .c
191
196
  .cc
192
197
  .cmake
193
198
  .conf
199
+ .cpp
194
200
  .css
195
- .e*rb
201
+ .erb
202
+ .erl
196
203
  .feature
197
204
  .gemspec
198
205
  .gif
199
206
  .gitignore
200
207
  .gitkeep
201
- .h*h
208
+ .h
209
+ .h
210
+ .hh
211
+ .hpp
212
+ .hrl
213
+ .html
202
214
  .jar
203
215
  .java
204
216
  .jpg
@@ -210,6 +222,7 @@ IGNORED_ENDINGS = %w{
210
222
  .lua
211
223
  .md
212
224
  .mkd
225
+ .mo
213
226
  .npmignore
214
227
  .out
215
228
  .packlist
@@ -219,21 +232,28 @@ IGNORED_ENDINGS = %w{
219
232
  .png
220
233
  .pod
221
234
  .properties
222
- .py[oc]*
223
- .r*html
235
+ .py
236
+ .pyc
237
+ .pyo
224
238
  .rake
239
+ .rb
240
+ .rbs
225
241
  .rdoc
242
+ .rhtml
226
243
  .ri
244
+ .rpm
227
245
  .rst
228
246
  .scss
229
247
  .sh
230
248
  .sql
231
249
  .svg
232
250
  .toml
251
+ .tt
233
252
  .ttf
234
253
  .txt
235
254
  .xml
236
255
  .yml
256
+ COPYING
237
257
  Gemfile
238
258
  LICENSE
239
259
  Makefile
@@ -243,7 +263,7 @@ IGNORED_ENDINGS = %w{
243
263
  license
244
264
  }.freeze
245
265
 
246
- IGNORED_PATTERNS = %w{
266
+ IGNORED_SUBSTRINGS = %w{
247
267
  /build_info/
248
268
  /licenses/
249
269
  /LICENSES/
data/omnibus.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency "chef-cleanroom", "~> 1.0"
26
26
  gem.add_dependency "ffi-yajl", "~> 2.2"
27
27
  gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
28
- gem.add_dependency "ohai", ">= 15", "< 17"
28
+ gem.add_dependency "ohai", ">= 15", "< 18"
29
29
  gem.add_dependency "ruby-progressbar", "~> 1.7"
30
30
  gem.add_dependency "thor", ">= 0.18", "< 2.0"
31
31
  gem.add_dependency "license_scout", "~> 1.0"
@@ -13,6 +13,9 @@
13
13
 
14
14
  %define _binary_payload <%= compression %>
15
15
 
16
+ # Disable creation of build-id links
17
+ %define _build_id_links none
18
+
16
19
  # Metadata
17
20
  Name: <%= name %>
18
21
  Version: <%= version %>
@@ -99,9 +99,47 @@ module Omnibus
99
99
  context "on linux" do
100
100
  before { stub_ohai(platform: "ubuntu", version: "16.04") }
101
101
 
102
+ # file_list just needs to have one file which is inside of the install_dir
103
+ let(:file_list) do
104
+ double("Mixlib::Shellout",
105
+ error!: false,
106
+ stdout: <<~EOH
107
+ /opt/chefdk/shouldnt/matter
108
+ EOH
109
+ )
110
+ end
111
+
112
+ let(:empty_list) do
113
+ double("Mixlib::Shellout",
114
+ error!: false,
115
+ stdout: <<~EOH
116
+ EOH
117
+ )
118
+ end
119
+
120
+ let(:failed_list) do
121
+ failed_list = double("Mixlib::Shellout",
122
+ stdout: <<~EOH
123
+ /opt/chefdk/shouldnt/matter
124
+ EOH
125
+ )
126
+ allow(failed_list).to receive(:error!).and_raise("Mixlib::Shellout::ShellCommandFailed")
127
+ failed_list
128
+ end
129
+
130
+ let(:bad_list) do
131
+ double("Mixlib::Shellout",
132
+ error!: false,
133
+ stdout: <<~EOH
134
+ /somewhere/other/than/install/dir
135
+ EOH
136
+ )
137
+ end
138
+
102
139
  let(:bad_healthcheck) do
103
140
  double("Mixlib::Shellout",
104
- stdout: <<-EOH.gsub(/^ {12}/, "")
141
+ error!: false,
142
+ stdout: <<~EOH
105
143
  /bin/ls:
106
144
  linux-vdso.so.1 => (0x00007fff583ff000)
107
145
  libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fad8592a000)
@@ -122,7 +160,8 @@ module Omnibus
122
160
 
123
161
  let(:good_healthcheck) do
124
162
  double("Mixlib::Shellout",
125
- stdout: <<-EOH.gsub(/^ {12}/, "")
163
+ error!: false,
164
+ stdout: <<~EOH
126
165
  /bin/echo:
127
166
  linux-vdso.so.1 => (0x00007fff8a6ee000)
128
167
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70f58c0000)
@@ -135,11 +174,13 @@ module Omnibus
135
174
  )
136
175
  end
137
176
 
138
- let(:regexp) { ".*(\\.TXT|\\.[ch]|\\.[ch]pp|\\.[eh]rl|\\.app|\\.appup|\\.bat|\\.beam|\\.cc|\\.cmake|\\.conf|\\.css|\\.e*rb|\\.feature|\\.gemspec|\\.gif|\\.gitignore|\\.gitkeep|\\.h*h|\\.jar|\\.java|\\.jpg|\\.js|\\.jsm|\\.json|\\.lock|\\.log|\\.lua|\\.md|\\.mkd|\\.npmignore|\\.out|\\.packlist|\\.perl|\\.pl|\\.pm|\\.png|\\.pod|\\.properties|\\.py[oc]*|\\.r*html|\\.rake|\\.rdoc|\\.ri|\\.rst|\\.scss|\\.sh|\\.sql|\\.svg|\\.toml|\\.ttf|\\.txt|\\.xml|\\.yml|Gemfile|LICENSE|Makefile|README|Rakefile|VERSION|license)$|.*\\/build_info\\/.*|.*\\/licenses\\/.*|.*\\/LICENSES\\/.*|.*\\/man\\/.*|.*\\/share\\/doc\\/.*|.*\\/share\\/info\\/.*|.*\\/share\\/postgresql\\/.*|.*\\/share\\/terminfo\\/.*|.*\\/share\\/timezone\\/.*|.*\\/terminfo\\/.*" }
139
-
140
177
  it "raises an exception when there are external dependencies" do
141
178
  allow(subject).to receive(:shellout)
142
- .with("find #{project.install_dir}/ -type f -regextype posix-extended ! -regex '#{regexp}' | xargs ldd")
179
+ .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'")
180
+ .and_return(file_list)
181
+
182
+ allow(subject).to receive(:shellout)
183
+ .with("xargs ldd", { input: "/opt/chefdk/shouldnt/matter\n" })
143
184
  .and_return(bad_healthcheck)
144
185
 
145
186
  expect { subject.run! }.to raise_error(HealthCheckFailed)
@@ -147,7 +188,11 @@ module Omnibus
147
188
 
148
189
  it "does not raise an exception when the healthcheck passes" do
149
190
  allow(subject).to receive(:shellout)
150
- .with("find #{project.install_dir}/ -type f -regextype posix-extended ! -regex '#{regexp}' | xargs ldd")
191
+ .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'")
192
+ .and_return(file_list)
193
+
194
+ allow(subject).to receive(:shellout)
195
+ .with("xargs ldd", { input: "/opt/chefdk/shouldnt/matter\n" })
151
196
  .and_return(good_healthcheck)
152
197
 
153
198
  expect { subject.run! }.to_not raise_error
@@ -156,6 +201,30 @@ module Omnibus
156
201
  it "will not perform dll base relocation checks" do
157
202
  expect(subject.relocation_checkable?).to be false
158
203
  end
204
+
205
+ it "raises an exception if there's nothing in the file list" do
206
+ allow(subject).to receive(:shellout)
207
+ .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'")
208
+ .and_return(empty_list)
209
+
210
+ expect { subject.run! }.to raise_error(RuntimeError, "Internal Error: Health Check found no lines")
211
+ end
212
+
213
+ it "raises an exception if the file list command raises" do
214
+ allow(subject).to receive(:shellout)
215
+ .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'")
216
+ .and_return(failed_list)
217
+
218
+ expect { subject.run! }.to raise_error(RuntimeError, "Mixlib::Shellout::ShellCommandFailed")
219
+ end
220
+
221
+ it "raises an exception if the file list command has no entries in the install_dir" do
222
+ allow(subject).to receive(:shellout)
223
+ .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'")
224
+ .and_return(bad_list)
225
+
226
+ expect { subject.run! }.to raise_error(RuntimeError, "Internal Error: Health Check lines not matching the install_dir")
227
+ end
159
228
  end
160
229
  end
161
230
  end
@@ -557,7 +557,9 @@ module Omnibus
557
557
 
558
558
  context "when is a Mach-O library" do
559
559
  before do
560
- allow(subject).to receive(:is_binary?).with("file").and_return(true)
560
+ allow(File).to receive(:file?).with("file").and_return(true)
561
+ allow(File).to receive(:executable?).with("file").and_return(true)
562
+ allow(File).to receive(:symlink?).with("file").and_return(false)
561
563
  expect(subject).to receive(:shellout!).with("file file").and_return(shellout)
562
564
  allow(shellout).to receive(:stdout)
563
565
  .and_return("file: Mach-O 64-bit dynamically linked shared library x86_64")
@@ -570,7 +572,9 @@ module Omnibus
570
572
 
571
573
  context "when is a Mach-O Bundle" do
572
574
  before do
573
- allow(subject).to receive(:is_binary?).with("file").and_return(true)
575
+ allow(File).to receive(:file?).with("file").and_return(true)
576
+ allow(File).to receive(:executable?).with("file").and_return(true)
577
+ allow(File).to receive(:symlink?).with("file").and_return(false)
574
578
  expect(subject).to receive(:shellout!).with("file file").and_return(shellout)
575
579
  allow(shellout).to receive(:stdout)
576
580
  .and_return("file: Mach-O 64-bit bundle x86_64")
@@ -583,7 +587,9 @@ module Omnibus
583
587
 
584
588
  context "when is not a Mach-O Bundle or Mach-O library" do
585
589
  before do
586
- allow(subject).to receive(:is_binary?).with("file").and_return(true)
590
+ allow(File).to receive(:file?).with("file").and_return(true)
591
+ allow(File).to receive(:executable?).with("file").and_return(true)
592
+ allow(File).to receive(:symlink?).with("file").and_return(false)
587
593
  expect(subject).to receive(:shellout!).with("file file").and_return(shellout)
588
594
  allow(shellout).to receive(:stdout)
589
595
  .and_return("file: ASCII text")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.2
4
+ version: 8.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2022-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -95,7 +95,7 @@ dependencies:
95
95
  version: '15'
96
96
  - - "<"
97
97
  - !ruby/object:Gem::Version
98
- version: '17'
98
+ version: '18'
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
@@ -105,7 +105,7 @@ dependencies:
105
105
  version: '15'
106
106
  - - "<"
107
107
  - !ruby/object:Gem::Version
108
- version: '17'
108
+ version: '18'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: ruby-progressbar
111
111
  requirement: !ruby/object:Gem::Requirement