gitlab-license 2.2.2 → 2.4.0

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: a061df608a1fce9d44d099ca2ec27c78f57954560d014ea3810a6a104d84e76c
4
- data.tar.gz: fc39825338f1e87996be207d2d16c0ad0fe809217614b91edd10b3df0a102a13
3
+ metadata.gz: c15aba535f2359601fa9cf8e50b45e1a5e7671717c08845f047b0eae35fb69a3
4
+ data.tar.gz: e44fb5a0cc537fb0c12fd49c82f72ca7092d6f04d42c76bd7ef57803c87ea345
5
5
  SHA512:
6
- metadata.gz: ef5ee9e933e196a77dee538f4222fe42eb9b68b5d8b6520e6a32e99fd5186eed592eef7062bfb55702e747b780488dfaf42d7f1e99ca6b8a6a7462c23fd9a7d8
7
- data.tar.gz: dbb5a8a59e70b4d315115a622118987c718e19f0df7686026cb43bbd189c3d22a98ed64b9f155d4c41f9e7bda656ccd306eb1060a39e72270993d390fbd329d4
6
+ metadata.gz: b43de2bf8c651358b253ab5dfb86d71349a56344adb2129bdb8fbd33bf9d202bc079d1b0054144b59a472e3e350a88b4aabb53f12850b6778f79acaad2eb9a52
7
+ data.tar.gz: 570d1d302a389fb4c34071d29161fdc9e3a2122813610af1e0da9e573b49db8e5342c931584f74508896e0517d082174dbb5316a5dc7d1eaaeda528a8cc6cc6b
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,25 @@
1
+ default:
2
+ image: "ruby:${RUBY_VERSION}"
3
+
4
+ cache:
5
+ key: "${CI_JOB_IMAGE}"
6
+ paths:
7
+ - vendor/ruby
8
+
9
+ before_script:
10
+ - ruby -v
11
+ - gem update --system --no-document
12
+ - bundle install -j $(nproc) --path vendor
13
+
14
+ test:
15
+ script:
16
+ - bundle exec rspec
17
+ parallel:
18
+ matrix:
19
+ - RUBY_VERSION: [ "3.0", "3.1", "3.2" ]
20
+
21
+ rubocop:
22
+ script:
23
+ - bundle exec rubocop
24
+ variables:
25
+ RUBY_VERSION: "3.0"
data/.rubocop.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  require: rubocop-rspec
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
4
6
 
5
7
  Metrics/BlockLength:
6
8
  ExcludedMethods: ['describe', 'context']
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-03-02 14:37:54 -0500 using RuboCop version 0.80.1.
3
+ # on 2023-12-21 18:05:17 -0500 using RuboCop version 0.80.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -8,25 +8,31 @@
8
8
 
9
9
  # Offense count: 6
10
10
  Metrics/AbcSize:
11
- Max: 36
11
+ Max: 60
12
+
13
+ # Offense count: 1
14
+ # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
16
+ Metrics/BlockLength:
17
+ Max: 26
12
18
 
13
19
  # Offense count: 1
14
20
  # Configuration parameters: CountComments.
15
21
  Metrics/ClassLength:
16
- Max: 129
22
+ Max: 223
17
23
 
18
24
  # Offense count: 3
19
25
  Metrics/CyclomaticComplexity:
20
- Max: 16
26
+ Max: 27
21
27
 
22
- # Offense count: 5
28
+ # Offense count: 6
23
29
  # Configuration parameters: CountComments, ExcludedMethods.
24
30
  Metrics/MethodLength:
25
- Max: 38
31
+ Max: 36
26
32
 
27
33
  # Offense count: 3
28
34
  Metrics/PerceivedComplexity:
29
- Max: 16
35
+ Max: 28
30
36
 
31
37
  # Offense count: 3
32
38
  Style/Documentation:
@@ -76,7 +82,7 @@ Style/RescueModifier:
76
82
  Exclude:
77
83
  - 'lib/gitlab/license.rb'
78
84
 
79
- # Offense count: 14
85
+ # Offense count: 28
80
86
  # Cop supports --auto-correct.
81
87
  # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
82
88
  # URISchemes: http, https
data/README.md CHANGED
@@ -82,6 +82,10 @@ license.notify_users_at = Date.new(2016, 4, 23)
82
82
  # Not required.
83
83
  license.block_changes_at = Date.new(2016, 5, 7)
84
84
 
85
+ # If this license was created due to a subscription cancellation
86
+ # Not required.
87
+ license.generated_from_cancellation? = false
88
+
85
89
  # Restrictions bundled with this license.
86
90
  # Not required, to allow unlimited-user licenses for things like educational organizations.
87
91
  license.restrictions = {
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  class License
3
- VERSION = '2.2.2'.freeze
3
+ VERSION = '2.4.0'.freeze
4
4
  end
5
5
  end
@@ -15,6 +15,7 @@ module Gitlab
15
15
 
16
16
  class << self
17
17
  attr_reader :encryption_key
18
+ attr_reader :fallback_decryption_keys
18
19
  @encryption_key = nil
19
20
 
20
21
  def encryption_key=(key)
@@ -24,6 +25,19 @@ module Gitlab
24
25
  @encryptor = nil
25
26
  end
26
27
 
28
+ def fallback_decryption_keys=(keys)
29
+ unless keys
30
+ @fallback_decryption_keys = nil
31
+ return
32
+ end
33
+
34
+ unless keys.is_a?(Enumerable) && keys.all? { |key| key.is_a?(OpenSSL::PKey::RSA) }
35
+ raise ArgumentError, 'Invalid fallback RSA encryption keys provided.'
36
+ end
37
+
38
+ @fallback_decryption_keys = Array(keys)
39
+ end
40
+
27
41
  def encryptor
28
42
  @encryptor ||= Encryptor.new(encryption_key)
29
43
  end
@@ -33,11 +47,7 @@ module Gitlab
33
47
 
34
48
  data = Boundary.remove_boundary(data)
35
49
 
36
- begin
37
- license_json = encryptor.decrypt(data)
38
- rescue Encryptor::Error
39
- raise ImportError, 'License data could not be decrypted.'
40
- end
50
+ license_json = decrypt_with_fallback_keys(data)
41
51
 
42
52
  begin
43
53
  attributes = JSON.parse(license_json)
@@ -47,6 +57,20 @@ module Gitlab
47
57
 
48
58
  new(attributes)
49
59
  end
60
+
61
+ def decrypt_with_fallback_keys(data)
62
+ keys_to_try = Array(encryption_key)
63
+ keys_to_try += fallback_decryption_keys if fallback_decryption_keys
64
+
65
+ keys_to_try.each do |decryption_key|
66
+ decryptor = Encryptor.new(decryption_key)
67
+ return decryptor.decrypt(data)
68
+ rescue Encryptor::Error
69
+ next
70
+ end
71
+
72
+ raise ImportError, 'License data could not be decrypted.'
73
+ end
50
74
  end
51
75
 
52
76
  attr_reader :version
@@ -54,7 +78,8 @@ module Gitlab
54
78
  :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at,
55
79
  :activated_at, :restrictions, :cloud_licensing_enabled,
56
80
  :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled,
57
- :operational_metrics_enabled, :generated_from_customers_dot
81
+ :operational_metrics_enabled, :generated_from_customers_dot,
82
+ :generated_from_cancellation
58
83
 
59
84
  alias_method :issued_at, :starts_at
60
85
  alias_method :issued_at=, :starts_at=
@@ -161,6 +186,10 @@ module Gitlab
161
186
  generated_from_customers_dot == true
162
187
  end
163
188
 
189
+ def generated_from_cancellation?
190
+ generated_from_cancellation == true
191
+ end
192
+
164
193
  def gl_team_license?
165
194
  licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@gitlab.com')
166
195
  end
@@ -203,6 +232,7 @@ module Gitlab
203
232
  hash['operational_metrics_enabled'] = operational_metrics?
204
233
 
205
234
  hash['generated_from_customers_dot'] = generated_from_customers_dot?
235
+ hash['generated_from_cancellation'] = generated_from_cancellation?
206
236
 
207
237
  hash['restrictions'] = restrictions if restricted?
208
238
 
@@ -252,6 +282,7 @@ module Gitlab
252
282
  seat_reconciliation_enabled
253
283
  operational_metrics_enabled
254
284
  generated_from_customers_dot
285
+ generated_from_cancellation
255
286
  ].each do |attr_name|
256
287
  public_send("#{attr_name}=", attributes[attr_name] == true)
257
288
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-license
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douwe Maan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-05-05 00:00:00.000000000 Z
13
+ date: 2023-12-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -106,6 +106,7 @@ extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
108
  - ".gitignore"
109
+ - ".gitlab-ci.yml"
109
110
  - ".rspec"
110
111
  - ".rubocop.yml"
111
112
  - ".rubocop_todo.yml"
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
- rubygems_version: 3.1.6
144
+ rubygems_version: 3.4.13
144
145
  signing_key:
145
146
  specification_version: 4
146
147
  summary: gitlab-license helps you generate, verify and enforce software licenses.