diffend 0.2.54 → 0.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1c08aff1de7f94edfb5505ec23a6f54ac69a7c028bab4002cc60f6262082308
4
- data.tar.gz: 515fce20c62f82d0d96622468975cdd601901754943c2082e6ddbf6639a8c7f0
3
+ metadata.gz: f22f4627b400b5672aeb7638996d275bd1f0e1228b2fc3c6ef7cd24ab2a1b584
4
+ data.tar.gz: 64dd90639cb97523cdda102cbf3d9e46a3b12c62f0e677d918ed861a5a69ad50
5
5
  SHA512:
6
- metadata.gz: 8cec5d03b1669f6590a82472ab4f07ba64fb3c4a8936a6ec00d38f53f2dcca7a662eb0d7824bf125f1cd0cbec8a31f4fa65c2aee4a2ddecf01f3db77fadc46f8
7
- data.tar.gz: c79f7b9536793962aca4420cf14a5089ee1a5f0da08df4659d33a1e8ce7a3bd8861e9fdcfb2abe91ea7f0e78de734e2a2c3fcb132373d24a6ba0e552fec81135
6
+ metadata.gz: d879938e335b56faa066cd0d2379f4a916ded4cf708fd6bf4bc7e14f2697ac0477280bf29cfacc9b26e61dd7cef36b4cd34bb15e4c44f8985d517003e25a2bd1
7
+ data.tar.gz: d2fe957474c47054a2825b6d42f06a4adef2f9113eacf31f75da4095cbd13b45330903afd2de277759734be64bc43af002dde6f3f544bfd137b2e7d486ac0b93
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.55] (2026-11-17)
4
+ - Fix: on Bundler 2.3 and later the plugin sent an empty package list, so the Diffend API allowed every gem. The plugin now sends every resolved gem (name, version, source, platform) on Bundler 2.3 to 4.1 (the versions in the CI matrix), with and without a lockfile (#205).
5
+ - Fix: the plugin crashed on Bundler 4, which removed `feature_flag.default_cli_command`. The plugin now reads the setting or uses `install` (#205).
6
+ - Fix: on Bundler 4.1, `bundle secure` failed with a command conflict when the Gemfile `plugin 'diffend'` line and `bundle plugin install diffend` both registered the plugin (#205).
7
+ - Fix: gem-installing command names (`bundle i`, `cache`, `package`, `pack`, `remove` and the prefixes Bundler accepts) raised "invalid command" in the plugin, and with the default `ignore_errors` the install continued after a deny verdict. These commands are now handled as `install` (#205).
8
+ - Fix: SSL errors (for example CRL verification failures with OpenSSL 3.6+) are now retried and reported with a clear message (#200).
9
+ - Add `DIFFEND_SKIP_SSL_VERIFY=true`. It turns off TLS certificate verification for the requests to the Diffend API. Use it only to diagnose a certificate problem, not in production. It is off by default (#200).
10
+ - CI: a matrix (Ruby 3.1 to 3.4, Bundler 2.3 to 4.1 and the latest release every week) runs `bundle install` and `bundle secure` against a local stub API and checks the payload and the allow, warn and deny results (#205).
11
+ - CI: the spec suite runs again on Ruby 2.7 to 3.4 and Bundler 2.3 to 4.0, with payload fixtures that list the resolved gems (#204).
12
+ - Build: the gem is signed only when the signing key is present. The certificate in `certs/` expired in 2023, and 0.2.54 was published unsigned.
13
+ - No change to the defaults (`ignore_errors` stays `true`).
14
+
3
15
  ## [0.2.52] (Unreleased)
4
16
  - Bundler 2.2.28 specs support
5
17
  - Bundler 2.2.29 specs support
data/diffend.gemspec CHANGED
@@ -25,11 +25,14 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.required_ruby_version = '>= 2.5.0'
27
27
 
28
- if $PROGRAM_NAME.end_with?('gem')
29
- spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
28
+ signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
29
+
30
+ # The gem is signed only when the signing key is on the build host.
31
+ if $PROGRAM_NAME.end_with?('gem') && File.exist?(signing_key)
32
+ spec.signing_key = signing_key
33
+ spec.cert_chain = %w[certs/mensfeld.pem]
30
34
  end
31
35
 
32
- spec.cert_chain = %w[certs/mensfeld.pem]
33
36
  spec.require_paths = %w[lib]
34
37
 
35
38
  files_locations.each { |location| spec.files += Dir[location] }
@@ -3,7 +3,35 @@
3
3
  module Diffend
4
4
  # Extend bundler with a new secure command to be able to run Diffend separately
5
5
  class BundleSecure
6
- ::Bundler::Plugin::API.command(Diffend::Commands::SECURE, self)
6
+ # Name of the plugin in the Bundler plugin index
7
+ PLUGIN_NAME = 'diffend'
8
+
9
+ class << self
10
+ # Declares the secure command to Bundler
11
+ #
12
+ # Bundler 4.1 registers a plugin again when the Gemfile installs the plugin and the
13
+ # plugin is already in the index at another path. The index then rejects the command
14
+ # that the same plugin owns. The method skips the declaration in this case. The index
15
+ # keeps the command of the first registration.
16
+ def register_command
17
+ return if registered_again?
18
+
19
+ ::Bundler::Plugin::API.command(Diffend::Commands::SECURE, self)
20
+ end
21
+
22
+ private
23
+
24
+ # The method reads the call stack to find the registration.
25
+ #
26
+ # @return [Boolean] true when Bundler registers the plugin again and the index maps the command to it
27
+ def registered_again?
28
+ owner = ::Bundler::Plugin.index.command_plugin(Diffend::Commands::SECURE)
29
+
30
+ owner == PLUGIN_NAME && caller_locations.any? { |location| location.label.include?('register_plugin') }
31
+ end
32
+ end
33
+
34
+ register_command
7
35
 
8
36
  # Execute diffend check
9
37
  #
@@ -6,6 +6,11 @@ module Diffend
6
6
  # Name of the diffend config file
7
7
  FILENAME = '.diffend.yml'
8
8
 
9
+ # Commands that the API knows besides install
10
+ OWN_COMMANDS = [
11
+ Diffend::Commands::UPDATE, Diffend::Commands::ADD, Diffend::Commands::EXEC, Diffend::Commands::SECURE
12
+ ].freeze
13
+
9
14
  attr_reader :project_id, :shareable_id, :shareable_key, :build_path, :env, :command, :errors
10
15
 
11
16
  # Build diffend config object
@@ -104,14 +109,46 @@ module Diffend
104
109
  #
105
110
  # @return [String]
106
111
  def build_command
107
- default = ::Bundler.feature_flag.default_cli_command.to_s
112
+ default = default_command
108
113
 
109
114
  return default unless ARGV.first
110
115
  # There is a case where no command may be provided and the first argument is the first option
111
116
  # In a case like this we fallback to default command
112
117
  return default if ARGV.first.start_with?('-')
113
118
 
114
- ARGV.first
119
+ canonical_command(ARGV.first)
120
+ end
121
+
122
+ # Resolves the command name the same way Bundler does
123
+ #
124
+ # Bundler accepts aliases (`i`, `pack`), unique prefixes (`inst`) and other commands that
125
+ # install gems (`cache`, `remove`, `install_or_cli_help`). The hook of the plugin runs only
126
+ # when Bundler is about to install gems. So every command that is not update, add, exec or
127
+ # secure maps to the install command. Without this the plugin rejects the name and the
128
+ # guarded install can go on.
129
+ #
130
+ # @param name [String] first argument given to bundler
131
+ #
132
+ # @return [String]
133
+ def canonical_command(name)
134
+ resolved = ::Bundler::CLI.send(:normalize_command_name, name).to_s
135
+ OWN_COMMANDS.include?(resolved) ? resolved : Diffend::Commands::INSTALL
136
+ rescue StandardError
137
+ OWN_COMMANDS.include?(name) ? name : Diffend::Commands::INSTALL
138
+ end
139
+
140
+ # Command that Bundler runs when no command is given
141
+ #
142
+ # Bundler 4 removed the `default_cli_command` feature flag. The plugin reads the setting
143
+ # directly and uses `install` when the setting is not set.
144
+ #
145
+ # @return [String]
146
+ def default_command
147
+ feature_flag = ::Bundler.feature_flag
148
+
149
+ return canonical_command(feature_flag.default_cli_command.to_s) if feature_flag.respond_to?(:default_cli_command)
150
+
151
+ canonical_command((::Bundler.settings[:default_cli_command] || Diffend::Commands::INSTALL).to_s)
115
152
  end
116
153
 
117
154
  # @return [String] path to the plugin
@@ -24,6 +24,13 @@ module Diffend
24
24
  If you think that this is a bug, don't hesitate.\n
25
25
  Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
26
26
  MSG
27
+ SSL_CONNECTION_ERROR = <<~MSG
28
+ \nWe experienced an SSL connection error. This is likely due to certificate verification issues with OpenSSL 3.6+.\n
29
+ The error has been recorded. If the issue persists, please try:\n
30
+ 1. Update your CA certificates: brew install ca-certificates (macOS)\n
31
+ 2. Set DIFFEND_SKIP_SSL_VERIFY=true (not recommended for production)\n
32
+ 3. Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
33
+ MSG
27
34
  end
28
35
  end
29
36
  end
@@ -74,9 +74,7 @@ module Diffend
74
74
  def build
75
75
  hash = build_main
76
76
 
77
- @definition.resolve.each do |spec|
78
- # Skip metadata
79
- next if spec.instance_variable_get(:@specification).nil?
77
+ @definition.specs.each do |spec|
80
78
  next if skip?(spec.source)
81
79
 
82
80
  locked_spec = @locked_specs.find { |s| s.name == spec.name }
@@ -268,6 +266,7 @@ module Diffend
268
266
  #
269
267
  # @return [Boolean] true if we should skip this source, false otherwise
270
268
  def skip?(source)
269
+ return true if source.is_a?(::Bundler::Source::Metadata)
271
270
  return true if me?(source)
272
271
 
273
272
  false
@@ -17,6 +17,12 @@ module Diffend
17
17
  Errno::ECONNREFUSED,
18
18
  SocketError
19
19
  ].freeze
20
+ # Message displayed when SSL issue occurred
21
+ SSL_ERROR_MESSAGE = 'We experienced an SSL connection issue. This may be due to certificate verification problems with OpenSSL 3.6+.'
22
+ # List of SSL exceptions
23
+ SSL_EXCEPTIONS = [
24
+ OpenSSL::SSL::SSLError
25
+ ].freeze
20
26
  # Message displayed when timeout occured and we will retry
21
27
  TIMEOUT_MESSAGE = 'We experienced a connection issue, retrying...'
22
28
  # List of timeout exceptions
@@ -98,6 +104,25 @@ module Diffend
98
104
  config: request_object.config,
99
105
  message: :request_error
100
106
  )
107
+ rescue *SSL_EXCEPTIONS => e
108
+ retry_count += 1
109
+
110
+ # Provide more helpful context for SSL errors
111
+ if e.message.include?('certificate verify failed') || e.message.include?('CRL')
112
+ request_object.config.logger.warn(
113
+ "#{SSL_ERROR_MESSAGE} Error: #{e.message}. " \
114
+ "Consider updating CA certificates or setting DIFFEND_SKIP_SSL_VERIFY=true (not recommended for production)."
115
+ )
116
+ end
117
+
118
+ retry if handle_retry(request_object.config, SSL_ERROR_MESSAGE, retry_count)
119
+
120
+ Diffend::HandleErrors::Report.call(
121
+ exception: e,
122
+ payload: request_object.payload,
123
+ config: request_object.config,
124
+ message: :ssl_connection_error
125
+ )
101
126
  end
102
127
 
103
128
  # Handle retry
@@ -120,15 +145,45 @@ module Diffend
120
145
  def build_http(url)
121
146
  uri = URI(url)
122
147
 
148
+ # Build SSL options hash - must be passed to Net::HTTP.start before SSL handshake
149
+ ssl_options = if uri.scheme == 'https'
150
+ build_ssl_options
151
+ else
152
+ {}
153
+ end
154
+
123
155
  Net::HTTP.start(
124
156
  uri.host,
125
157
  uri.port,
126
158
  use_ssl: uri.scheme == 'https',
127
159
  open_timeout: 15,
128
- read_timeout: 15
160
+ read_timeout: 15,
161
+ **ssl_options
129
162
  ) { |http| yield(http, uri) }
130
163
  end
131
164
 
165
+ # Build SSL options for Net::HTTP.start
166
+ #
167
+ # @return [Hash] SSL options including verify_mode and cert_store
168
+ def build_ssl_options
169
+ if ENV['DIFFEND_SKIP_SSL_VERIFY'] == 'true'
170
+ # Emergency escape hatch - not recommended for production
171
+ warn('[DIFFEND] WARNING: SSL verification is disabled! This is not secure.')
172
+ { verify_mode: OpenSSL::SSL::VERIFY_NONE }
173
+ else
174
+ # Standard SSL configuration with CRL checking disabled
175
+ # This prevents failures on OpenSSL 3.6+ while maintaining certificate verification
176
+ {
177
+ verify_mode: OpenSSL::SSL::VERIFY_PEER,
178
+ cert_store: OpenSSL::X509::Store.new.tap do |store|
179
+ store.set_default_paths
180
+ # Disable CRL checking which causes issues with OpenSSL 3.6+
181
+ store.flags = 0
182
+ end
183
+ }
184
+ end
185
+ end
186
+
132
187
  # Build http post request and assigns headers and payload
133
188
  #
134
189
  # @param uri [URI::HTTPS]
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Diffend
4
4
  # Current version
5
- VERSION = '0.2.54'
5
+ VERSION = '0.2.55'
6
6
  end
metadata CHANGED
@@ -1,42 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.54
4
+ version: 0.2.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Pajor
8
8
  - Maciej Mensfeld
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
- cert_chain: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qhkiG9w0BAQsFAAOCAYEA1aS+E7RXJ1w9g9mJ
30
- G0NzFxe64OEuENosNlvYQCbRKGCXAU1qqelYkBQHseRgRKxLICrnypRo9IEobyHa
31
- vDnJ4r7Tsb34dleqQW2zY/obG+cia3Ym2JsegXWF7dDOzCXJ4FN8MFoT2jHlqLLw
32
- yrap0YO5zx0GSQ0Dwy8h2n2v2vanMEeCx7iNm3ERgR5WuN5sjzWoz2A/JLEEcK0C
33
- EnAGKCWAd1fuG8IemDjT1edsd5FyYR4bIX0m+99oDuFZyPiiIbalmyYiSBBp59Yb
34
- Q0P8zeBi4OfwCZNcxqz0KONmw9JLNv6DgyEAH5xe/4JzhMEgvIRiPj0pHfA7oqQF
35
- KUNqvD1KlxbEC+bZfE5IZhnqYLdld/Ksqd22FI1RBhiS1Ejfsj99LVIm9cBuZEY2
36
- Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
37
- MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
38
- -----END CERTIFICATE-----
39
- date: 2022-12-26 00:00:00.000000000 Z
11
+ cert_chain: []
12
+ date: 2026-11-18 00:00:00.000000000 Z
40
13
  dependencies:
41
14
  - !ruby/object:Gem::Dependency
42
15
  name: bundler
@@ -66,7 +39,7 @@ dependencies:
66
39
  - - ">="
67
40
  - !ruby/object:Gem::Version
68
41
  version: '0'
69
- description:
42
+ description:
70
43
  email:
71
44
  - contact@diffend.io
72
45
  executables: []
@@ -116,7 +89,7 @@ homepage: https://diffend.io
116
89
  licenses:
117
90
  - Prosperity Public License
118
91
  metadata: {}
119
- post_install_message:
92
+ post_install_message:
120
93
  rdoc_options: []
121
94
  require_paths:
122
95
  - lib
@@ -131,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
104
  - !ruby/object:Gem::Version
132
105
  version: '0'
133
106
  requirements: []
134
- rubygems_version: 3.4.1
135
- signing_key:
107
+ rubygems_version: 3.4.10
108
+ signing_key:
136
109
  specification_version: 4
137
110
  summary: OSS supply chain security and management platform
138
111
  test_files: []
checksums.yaml.gz.sig DELETED
@@ -1,5 +0,0 @@
1
- @ڎ�Wt�N0]k�
2
- ��Z>\�?nt��`G�I��.�~4���w��&/�}q�Ը%�W&[ӄ�����G��B5�3[
3
- ��h�Q(��$2c
4
- Z� *��fI�����Y���!���,1�TaLh���q�������/i&A�r�V�A����
5
- �C�W�8$"��f��:�E.�B:�$(�F������� k�W�;�\(4��P����-��:�3/�fm��V��УǔemR�>�;�p0�U�5�G~�:��c�x�}[�㭋$���C�x��h��c5W�b�P�rš�mz�h�DI�?��|Cj�k�2}�
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- �zư:�w�~dg�J�a�R͝}z��
2
- ^+�(ޯ�����'�Tx���O����.S���Ɍ���Ks�~��(��>u�s�-W��ܤ4�����֕��������/py�ӌ��3uM��L��&�P(h�P�Y�=tU@^�-:_iX��<k��0�hP�Jg׬av��!�rذ���G��}gfhs0ȹ���6�IƤs���A5����؇aU��
metadata.gz.sig DELETED
Binary file