bundler-integrity 1.0.4 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bundler-integrity +31 -22
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0caecea308edf5906a927983e7e771331a0c75f14c8ffe84dcb916b63b5aa041
4
- data.tar.gz: e6ace90d311cfff228e49c78b42184b88fb70345cd1a90a8d63cc08e903b66ef
3
+ metadata.gz: e9c3c4edd9e29589bf29f4a078a73a8708f17b842a7b8ce98bf65a5b840373f6
4
+ data.tar.gz: 247137efb0cf16c6718ff673236332d33e7010305b77ca732b1cef265a1e8eb1
5
5
  SHA512:
6
- metadata.gz: ea3e4892a86d6348f411c9e0265e8f42d72735f0b250d6b988410c326d4f96f7d4d6beb54b5a122cfe725d35499c2c8003fe6f08ca6c9ea2aac0e401c7eaafa9
7
- data.tar.gz: 1217c607fcef3ff45d64aed80e1e49821d73354d36203b7008a7c92e08c574dbb291628f55ba89e7f34e176d13ed0515a321bed97a6ce86a8eb928c19963888c
6
+ metadata.gz: f10059dd3b50de3f70b61dfb9712111add7b5ce1f1f6745b0d67cf711ea509e713d52e04349e76091a02e24c19cf4deec75ac7d1642b064634ff1ab4bac65357
7
+ data.tar.gz: 3c9034b4905e3f7465acf76d58ef9667a044f90f08e1d05f75be93f3f22e4aeaf5a719ea977f8ac437ebdbce920e05251f03bdff07a7af09fe476cce84ac6d6a
@@ -10,6 +10,10 @@ require 'json'
10
10
  require 'open-uri'
11
11
  require 'digest/sha2'
12
12
 
13
+ # This will only print gem files full names and their expected checksums WITHOUT validating
14
+ # Useful to export and run search and comparison in prod, etc
15
+ PRINT_EXPORT = (ARGV[0] == 'export')
16
+
13
17
  # Packages cache paths candidates (we will check all)
14
18
  CACHE_DIRS = [
15
19
  Bundler::RubygemsIntegration.new.gem_cache,
@@ -23,7 +27,6 @@ deps = ::Bundler::Definition
23
27
  .build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
24
28
  .tap(&:validate_runtime!)
25
29
 
26
-
27
30
  deps.specs.each do |spec|
28
31
  # Ignore git based, etc
29
32
  next unless spec.source.is_a?(Bundler::Source::Rubygems)
@@ -50,35 +53,41 @@ deps.specs.each do |spec|
50
53
 
51
54
  version || raise("#{full_name} not found in the RubyGems API response")
52
55
 
53
- candidates = CACHE_DIRS
54
- .map { |dir| File.join(dir, full_name) }
55
- .select { |path| File.exist?(path) }
56
+ if PRINT_EXPORT
57
+ puts "#{version.fetch('sha')} #{full_name}"
58
+ else
59
+ candidates = CACHE_DIRS
60
+ .map { |dir| File.join(dir, full_name) }
61
+ .select { |path| File.exist?(path) }
56
62
 
57
- if candidates.empty?
58
- puts "\033[0;33m[WARN]\033[0m #{full_name} was not found in cache locations, maybe it is a stdlib gem?"
59
- next
60
- end
63
+ if candidates.empty?
64
+ puts "\033[0;33m[WARN]\033[0m #{full_name} was not found in cache locations, maybe it is a stdlib gem?"
65
+ next
66
+ end
61
67
 
62
- candidates.each do |full_path|
63
- sha = Digest::SHA2.new
68
+ candidates.each do |full_path|
69
+ sha = Digest::SHA2.new
64
70
 
65
- File.open(full_path) do |f|
66
- while chunk = f.read(256)
67
- sha << chunk
71
+ File.open(full_path) do |f|
72
+ while chunk = f.read(256)
73
+ sha << chunk
74
+ end
68
75
  end
69
- end
70
76
 
71
77
 
72
- if version.fetch('sha') == sha.hexdigest
73
- puts "\033[0;32m[OK]\033[0m #{full_path}"
74
- else
75
- puts "\033[0;31m[FAILURE]\033[0m"
76
- puts "Checksum verification for #{full_path} failed!"
78
+ if version.fetch('sha') == sha.hexdigest
79
+ puts "\033[0;32m[OK]\033[0m #{full_path}"
80
+ else
81
+ puts "\033[0;31m[FAILURE]\033[0m"
82
+ puts "Checksum verification for #{full_path} failed!"
77
83
 
78
- exit 1
84
+ exit 1
85
+ end
79
86
  end
80
87
  end
81
88
  end
82
89
 
83
- puts "\033[0;32m[OK]\033[0m Congratulations, you're safe and sound!"
84
- puts "\033[0;32m[OK]\033[0m Maciej Mensfeld and the WhiteSource team wishes you a good day!"
90
+ unless PRINT_EXPORT
91
+ puts "\033[0;32m[OK]\033[0m Congratulations, you're safe and sound!"
92
+ puts "\033[0;32m[OK]\033[0m Maciej Mensfeld and the WhiteSource team wishes you a good day!"
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-integrity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld