gitlab-license 0.0.3 → 1.3.0
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 +5 -5
- data/.rubocop.yml +22 -0
- data/.rubocop_todo.yml +84 -0
- data/Rakefile +1 -1
- data/bin/console +3 -3
- data/gitlab-license.gemspec +17 -13
- data/lib/gitlab/license.rb +84 -56
- data/lib/gitlab/license/boundary.rb +40 -0
- data/lib/gitlab/license/encryptor.rb +19 -25
- data/lib/gitlab/license/version.rb +1 -1
- metadata +59 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7576ad0e3380471a2dfd3d4c1b0723af40aa4098e92ad07f81f6a57417c73d0a
|
4
|
+
data.tar.gz: 51f9db1de53aef2224d5b19dd7d36a7df3e26956ca7973b95cf09afe1af0937a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63425904d6d344e22258d2282e332fc14cec787d5a774bbcb98e7bc97db9ca5631ea5ae7368f7084fc32dea7330128c7b7d8424106f933e68553f69c932b84d8
|
7
|
+
data.tar.gz: a807d41b598fde56eaeceedff4f14986430c29b484dc9d0ceeed40637e8c5b3dd8f10a71814f2bc991649f8e511c7583f4d721b15b8a3420b342ed05b2ffc877
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require: rubocop-rspec
|
4
|
+
|
5
|
+
Metrics/BlockLength:
|
6
|
+
ExcludedMethods: ['describe', 'context']
|
7
|
+
|
8
|
+
Style/Alias:
|
9
|
+
EnforcedStyle: prefer_alias_method
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
Style/HashEachMethods:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Style/HashTransformKeys:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Style/HashTransformValues:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
RSpec/MultipleExpectations:
|
22
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-03-02 14:37:54 -0500 using RuboCop version 0.80.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 6
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 36
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: CountComments.
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Max: 129
|
17
|
+
|
18
|
+
# Offense count: 3
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Max: 16
|
21
|
+
|
22
|
+
# Offense count: 5
|
23
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 38
|
26
|
+
|
27
|
+
# Offense count: 3
|
28
|
+
Metrics/PerceivedComplexity:
|
29
|
+
Max: 16
|
30
|
+
|
31
|
+
# Offense count: 3
|
32
|
+
Style/Documentation:
|
33
|
+
Exclude:
|
34
|
+
- 'spec/**/*'
|
35
|
+
- 'test/**/*'
|
36
|
+
- 'lib/gitlab/license.rb'
|
37
|
+
- 'lib/gitlab/license/boundary.rb'
|
38
|
+
- 'lib/gitlab/license/encryptor.rb'
|
39
|
+
|
40
|
+
# Offense count: 12
|
41
|
+
# Cop supports --auto-correct.
|
42
|
+
# Configuration parameters: EnforcedStyle.
|
43
|
+
# SupportedStyles: always, always_true, never
|
44
|
+
Style/FrozenStringLiteralComment:
|
45
|
+
Exclude:
|
46
|
+
- 'Gemfile'
|
47
|
+
- 'Rakefile'
|
48
|
+
- 'bin/console'
|
49
|
+
- 'gitlab-license.gemspec'
|
50
|
+
- 'lib/gitlab/license.rb'
|
51
|
+
- 'lib/gitlab/license/boundary.rb'
|
52
|
+
- 'lib/gitlab/license/encryptor.rb'
|
53
|
+
- 'lib/gitlab/license/version.rb'
|
54
|
+
- 'spec/gitlab/license/boundary_spec.rb'
|
55
|
+
- 'spec/gitlab/license/encryptor_spec.rb'
|
56
|
+
- 'spec/gitlab/license_spec.rb'
|
57
|
+
- 'spec/spec_helper.rb'
|
58
|
+
|
59
|
+
# Offense count: 1
|
60
|
+
# Configuration parameters: MinBodyLength.
|
61
|
+
Style/GuardClause:
|
62
|
+
Exclude:
|
63
|
+
- 'lib/gitlab/license.rb'
|
64
|
+
|
65
|
+
# Offense count: 1
|
66
|
+
# Cop supports --auto-correct.
|
67
|
+
# Configuration parameters: EnforcedStyle.
|
68
|
+
# SupportedStyles: short, verbose
|
69
|
+
Style/PreferredHashMethods:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/gitlab/license.rb'
|
72
|
+
|
73
|
+
# Offense count: 1
|
74
|
+
# Cop supports --auto-correct.
|
75
|
+
Style/RescueModifier:
|
76
|
+
Exclude:
|
77
|
+
- 'lib/gitlab/license.rb'
|
78
|
+
|
79
|
+
# Offense count: 14
|
80
|
+
# Cop supports --auto-correct.
|
81
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
82
|
+
# URISchemes: http, https
|
83
|
+
Layout/LineLength:
|
84
|
+
Max: 104
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'gitlab/license'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "gitlab/license"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/gitlab-license.gemspec
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'gitlab/license/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'gitlab-license'
|
8
7
|
spec.version = Gitlab::License::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['Douwe Maan', 'Stan Hu', 'Tyler Amos']
|
9
|
+
spec.email = ['douwe@gitlab.com', 'stanhu@gitlab.com', 'tamos@gitlab.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
11
|
+
spec.summary = 'gitlab-license helps you generate, verify and enforce software licenses.'
|
12
|
+
spec.homepage = 'https://dev.gitlab.org/gitlab/gitlab-license'
|
13
|
+
spec.license = 'MIT'
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
16
|
+
spec.bindir = 'exe'
|
18
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
20
19
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_development_dependency
|
20
|
+
spec.required_ruby_version = '>= 2.3.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
|
+
spec.add_development_dependency 'byebug'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.80.1'
|
27
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.38.1'
|
24
28
|
end
|
data/lib/gitlab/license.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'openssl'
|
2
|
+
require 'date'
|
3
|
+
require 'json'
|
4
|
+
require 'base64'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'gitlab/license/version'
|
7
|
+
require 'gitlab/license/encryptor'
|
8
|
+
require 'gitlab/license/boundary'
|
8
9
|
|
9
10
|
module Gitlab
|
10
11
|
class License
|
@@ -17,38 +18,41 @@ module Gitlab
|
|
17
18
|
@encryption_key = nil
|
18
19
|
|
19
20
|
def encryption_key=(key)
|
20
|
-
if key && !key.is_a?(OpenSSL::PKey::RSA)
|
21
|
-
raise ArgumentError, "No RSA encryption key provided."
|
22
|
-
end
|
21
|
+
raise ArgumentError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA)
|
23
22
|
|
24
23
|
@encryption_key = key
|
24
|
+
@encryptor = nil
|
25
25
|
end
|
26
26
|
|
27
27
|
def encryptor
|
28
|
-
@encryptor ||= Encryptor.new(
|
28
|
+
@encryptor ||= Encryptor.new(encryption_key)
|
29
29
|
end
|
30
30
|
|
31
31
|
def import(data)
|
32
|
+
raise ImportError, 'No license data.' if data.nil?
|
33
|
+
|
34
|
+
data = Boundary.remove_boundary(data)
|
35
|
+
|
32
36
|
begin
|
33
37
|
license_json = encryptor.decrypt(data)
|
34
38
|
rescue Encryptor::Error
|
35
|
-
raise ImportError,
|
39
|
+
raise ImportError, 'License data could not be decrypted.'
|
36
40
|
end
|
37
41
|
|
38
42
|
begin
|
39
43
|
attributes = JSON.parse(license_json)
|
40
44
|
rescue JSON::ParseError
|
41
|
-
raise ImportError,
|
45
|
+
raise ImportError, 'License data is invalid JSON.'
|
42
46
|
end
|
43
|
-
|
47
|
+
|
44
48
|
new(attributes)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
52
|
attr_reader :version
|
49
|
-
attr_accessor :licensee, :starts_at, :expires_at
|
50
|
-
|
51
|
-
|
53
|
+
attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at,
|
54
|
+
:notify_users_at, :block_changes_at, :type, :last_synced_at,
|
55
|
+
:next_sync_at, :restrictions
|
52
56
|
|
53
57
|
alias_method :issued_at, :starts_at
|
54
58
|
alias_method :issued_at=, :starts_at=
|
@@ -58,51 +62,69 @@ module Gitlab
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def valid?
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
if !licensee || !licensee.is_a?(Hash) || licensee.empty?
|
66
|
+
false
|
67
|
+
elsif !starts_at || !starts_at.is_a?(Date)
|
68
|
+
false
|
69
|
+
elsif expires_at && !expires_at.is_a?(Date)
|
70
|
+
false
|
71
|
+
elsif notify_admins_at && !notify_admins_at.is_a?(Date)
|
72
|
+
false
|
73
|
+
elsif notify_users_at && !notify_users_at.is_a?(Date)
|
74
|
+
false
|
75
|
+
elsif block_changes_at && !block_changes_at.is_a?(Date)
|
76
|
+
false
|
77
|
+
elsif last_synced_at && !last_synced_at.is_a?(DateTime)
|
78
|
+
false
|
79
|
+
elsif next_sync_at && !next_sync_at.is_a?(DateTime)
|
80
|
+
false
|
81
|
+
elsif type && type != 'cloud'
|
82
|
+
false
|
83
|
+
elsif restrictions && !restrictions.is_a?(Hash)
|
84
|
+
false
|
85
|
+
else
|
86
|
+
true
|
87
|
+
end
|
70
88
|
end
|
71
89
|
|
72
90
|
def validate!
|
73
|
-
raise ValidationError,
|
91
|
+
raise ValidationError, 'License is invalid' unless valid?
|
74
92
|
end
|
75
93
|
|
76
94
|
def will_expire?
|
77
|
-
|
95
|
+
expires_at
|
78
96
|
end
|
79
97
|
|
80
98
|
def will_notify_admins?
|
81
|
-
|
99
|
+
notify_admins_at
|
82
100
|
end
|
83
101
|
|
84
102
|
def will_notify_users?
|
85
|
-
|
103
|
+
notify_users_at
|
86
104
|
end
|
87
105
|
|
88
106
|
def will_block_changes?
|
89
|
-
|
107
|
+
block_changes_at
|
108
|
+
end
|
109
|
+
|
110
|
+
def will_sync?
|
111
|
+
next_sync_at
|
90
112
|
end
|
91
113
|
|
92
114
|
def expired?
|
93
|
-
will_expire? && Date.today >=
|
115
|
+
will_expire? && Date.today >= expires_at
|
94
116
|
end
|
95
117
|
|
96
118
|
def notify_admins?
|
97
|
-
will_notify_admins? && Date.today >=
|
119
|
+
will_notify_admins? && Date.today >= notify_admins_at
|
98
120
|
end
|
99
121
|
|
100
122
|
def notify_users?
|
101
|
-
will_notify_users? && Date.today >=
|
123
|
+
will_notify_users? && Date.today >= notify_users_at
|
102
124
|
end
|
103
125
|
|
104
126
|
def block_changes?
|
105
|
-
will_block_changes? && Date.today >=
|
127
|
+
will_block_changes? && Date.today >= block_changes_at
|
106
128
|
end
|
107
129
|
|
108
130
|
def restricted?(key = nil)
|
@@ -113,34 +135,42 @@ module Gitlab
|
|
113
135
|
end
|
114
136
|
end
|
115
137
|
|
116
|
-
def attributes
|
138
|
+
def attributes
|
117
139
|
hash = {}
|
118
140
|
|
119
|
-
hash[
|
120
|
-
hash[
|
141
|
+
hash['version'] = version
|
142
|
+
hash['licensee'] = licensee
|
121
143
|
|
122
144
|
# `issued_at` is the legacy name for starts_at.
|
123
145
|
# TODO: Move to starts_at in a next version.
|
124
|
-
hash[
|
125
|
-
hash[
|
146
|
+
hash['issued_at'] = starts_at
|
147
|
+
hash['expires_at'] = expires_at if will_expire?
|
126
148
|
|
127
|
-
hash[
|
128
|
-
hash[
|
129
|
-
hash[
|
149
|
+
hash['notify_admins_at'] = notify_admins_at if will_notify_admins?
|
150
|
+
hash['notify_users_at'] = notify_users_at if will_notify_users?
|
151
|
+
hash['block_changes_at'] = block_changes_at if will_block_changes?
|
130
152
|
|
131
|
-
hash[
|
153
|
+
hash['next_sync_at'] = next_sync_at if will_sync?
|
154
|
+
hash['last_synced_at'] = last_synced_at if will_sync?
|
155
|
+
hash['type'] = type
|
156
|
+
|
157
|
+
hash['restrictions'] = restrictions if restricted?
|
132
158
|
|
133
159
|
hash
|
134
160
|
end
|
135
161
|
|
136
|
-
def to_json
|
137
|
-
JSON.dump(
|
162
|
+
def to_json(*_args)
|
163
|
+
JSON.dump(attributes)
|
138
164
|
end
|
139
165
|
|
140
|
-
def export
|
166
|
+
def export(boundary: nil)
|
141
167
|
validate!
|
142
168
|
|
143
|
-
self.class.encryptor.encrypt(
|
169
|
+
data = self.class.encryptor.encrypt(to_json)
|
170
|
+
|
171
|
+
data = Boundary.add_boundary(data, boundary) if boundary
|
172
|
+
|
173
|
+
data
|
144
174
|
end
|
145
175
|
|
146
176
|
private
|
@@ -148,28 +178,26 @@ module Gitlab
|
|
148
178
|
def load_attributes(attributes)
|
149
179
|
attributes = Hash[attributes.map { |k, v| [k.to_s, v] }]
|
150
180
|
|
151
|
-
version = attributes[
|
152
|
-
unless version && version == 1
|
153
|
-
raise ArgumentError, "Version is too new"
|
154
|
-
end
|
181
|
+
version = attributes['version'] || 1
|
182
|
+
raise ArgumentError, 'Version is too new' unless version && version == 1
|
155
183
|
|
156
184
|
@version = version
|
157
185
|
|
158
|
-
@licensee = attributes[
|
186
|
+
@licensee = attributes['licensee']
|
159
187
|
|
160
188
|
# `issued_at` is the legacy name for starts_at.
|
161
189
|
# TODO: Move to starts_at in a next version.
|
162
|
-
%w
|
190
|
+
%w[issued_at expires_at notify_admins_at notify_users_at block_changes_at].each do |attr|
|
163
191
|
value = attributes[attr]
|
164
192
|
value = Date.parse(value) rescue nil if value.is_a?(String)
|
165
|
-
|
193
|
+
|
166
194
|
next unless value
|
167
195
|
|
168
196
|
send("#{attr}=", value)
|
169
197
|
end
|
170
198
|
|
171
|
-
restrictions = attributes[
|
172
|
-
if restrictions
|
199
|
+
restrictions = attributes['restrictions']
|
200
|
+
if restrictions&.is_a?(Hash)
|
173
201
|
restrictions = Hash[restrictions.map { |k, v| [k.to_sym, v] }]
|
174
202
|
@restrictions = restrictions
|
175
203
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Gitlab
|
2
|
+
class License
|
3
|
+
module Boundary
|
4
|
+
BOUNDARY_START = /(\A|\r?\n)-*BEGIN .+? LICENSE-*\r?\n/.freeze
|
5
|
+
BOUNDARY_END = /\r?\n-*END .+? LICENSE-*(\r?\n|\z)/.freeze
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def add_boundary(data, product_name)
|
9
|
+
data = remove_boundary(data)
|
10
|
+
|
11
|
+
product_name.upcase!
|
12
|
+
|
13
|
+
pad = lambda do |message, width|
|
14
|
+
total_padding = [width - message.length, 0].max
|
15
|
+
|
16
|
+
padding = total_padding / 2.0
|
17
|
+
[
|
18
|
+
'-' * padding.ceil,
|
19
|
+
message,
|
20
|
+
'-' * padding.floor
|
21
|
+
].join
|
22
|
+
end
|
23
|
+
|
24
|
+
[
|
25
|
+
pad.call("BEGIN #{product_name} LICENSE", 60),
|
26
|
+
data.strip,
|
27
|
+
pad.call("END #{product_name} LICENSE", 60)
|
28
|
+
].join("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_boundary(data)
|
32
|
+
after_boundary = data.split(BOUNDARY_START).last
|
33
|
+
in_boundary = after_boundary.split(BOUNDARY_END).first
|
34
|
+
|
35
|
+
in_boundary
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -8,17 +8,13 @@ module Gitlab
|
|
8
8
|
attr_accessor :key
|
9
9
|
|
10
10
|
def initialize(key)
|
11
|
-
if key && !key.is_a?(OpenSSL::PKey::RSA)
|
12
|
-
raise KeyError, "No RSA encryption key provided."
|
13
|
-
end
|
11
|
+
raise KeyError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA)
|
14
12
|
|
15
13
|
@key = key
|
16
14
|
end
|
17
15
|
|
18
16
|
def encrypt(data)
|
19
|
-
unless key.private?
|
20
|
-
raise KeyError, "Provided key is not a private key."
|
21
|
-
end
|
17
|
+
raise KeyError, 'Provided key is not a private key.' unless key.private?
|
22
18
|
|
23
19
|
# Encrypt the data using symmetric AES encryption.
|
24
20
|
cipher = OpenSSL::Cipher::AES128.new(:CBC)
|
@@ -29,12 +25,12 @@ module Gitlab
|
|
29
25
|
encrypted_data = cipher.update(data) + cipher.final
|
30
26
|
|
31
27
|
# Encrypt the AES key using asymmetric RSA encryption.
|
32
|
-
encrypted_key =
|
28
|
+
encrypted_key = key.private_encrypt(aes_key)
|
33
29
|
|
34
30
|
encryption_data = {
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
'data' => Base64.encode64(encrypted_data),
|
32
|
+
'key' => Base64.encode64(encrypted_key),
|
33
|
+
'iv' => Base64.encode64(aes_iv)
|
38
34
|
}
|
39
35
|
|
40
36
|
json_data = JSON.dump(encryption_data)
|
@@ -42,31 +38,29 @@ module Gitlab
|
|
42
38
|
end
|
43
39
|
|
44
40
|
def decrypt(data)
|
45
|
-
unless key.public?
|
46
|
-
raise KeyError, "Provided key is not a public key."
|
47
|
-
end
|
41
|
+
raise KeyError, 'Provided key is not a public key.' unless key.public?
|
48
42
|
|
49
43
|
json_data = Base64.decode64(data.chomp)
|
50
44
|
|
51
45
|
begin
|
52
46
|
encryption_data = JSON.parse(json_data)
|
53
47
|
rescue JSON::ParserError
|
54
|
-
raise DecryptionError,
|
48
|
+
raise DecryptionError, 'Encryption data is invalid JSON.'
|
55
49
|
end
|
56
50
|
|
57
|
-
unless %w
|
58
|
-
raise DecryptionError,
|
51
|
+
unless %w[data key iv].all? { |key| encryption_data[key] }
|
52
|
+
raise DecryptionError, 'Required field missing from encryption data.'
|
59
53
|
end
|
60
54
|
|
61
|
-
encrypted_data = Base64.decode64(encryption_data[
|
62
|
-
encrypted_key = Base64.decode64(encryption_data[
|
63
|
-
aes_iv = Base64.decode64(encryption_data[
|
55
|
+
encrypted_data = Base64.decode64(encryption_data['data'])
|
56
|
+
encrypted_key = Base64.decode64(encryption_data['key'])
|
57
|
+
aes_iv = Base64.decode64(encryption_data['iv'])
|
64
58
|
|
65
59
|
begin
|
66
60
|
# Decrypt the AES key using asymmetric RSA encryption.
|
67
61
|
aes_key = self.key.public_decrypt(encrypted_key)
|
68
62
|
rescue OpenSSL::PKey::RSAError
|
69
|
-
raise DecryptionError,
|
63
|
+
raise DecryptionError, 'AES encryption key could not be decrypted.'
|
70
64
|
end
|
71
65
|
|
72
66
|
# Decrypt the data using symmetric AES encryption.
|
@@ -74,21 +68,21 @@ module Gitlab
|
|
74
68
|
cipher.decrypt
|
75
69
|
|
76
70
|
begin
|
77
|
-
cipher.key
|
71
|
+
cipher.key = aes_key
|
78
72
|
rescue OpenSSL::Cipher::CipherError
|
79
|
-
raise DecryptionError,
|
73
|
+
raise DecryptionError, 'AES encryption key is invalid.'
|
80
74
|
end
|
81
75
|
|
82
76
|
begin
|
83
|
-
cipher.iv
|
77
|
+
cipher.iv = aes_iv
|
84
78
|
rescue OpenSSL::Cipher::CipherError
|
85
|
-
raise DecryptionError,
|
79
|
+
raise DecryptionError, 'AES IV is invalid.'
|
86
80
|
end
|
87
81
|
|
88
82
|
begin
|
89
83
|
data = cipher.update(encrypted_data) + cipher.final
|
90
84
|
rescue OpenSSL::Cipher::CipherError
|
91
|
-
raise DecryptionError,
|
85
|
+
raise DecryptionError, 'Data could not be decrypted.'
|
92
86
|
end
|
93
87
|
|
94
88
|
data
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-license
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douwe Maan
|
8
|
+
- Stan Hu
|
9
|
+
- Tyler Amos
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: bundler
|
@@ -24,6 +26,20 @@ dependencies:
|
|
24
26
|
- - "~>"
|
25
27
|
- !ruby/object:Gem::Version
|
26
28
|
version: '1.9'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: byebug
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
27
43
|
- !ruby/object:Gem::Dependency
|
28
44
|
name: rake
|
29
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,28 +55,60 @@ dependencies:
|
|
39
55
|
- !ruby/object:Gem::Version
|
40
56
|
version: '10.0'
|
41
57
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
58
|
+
name: rspec
|
43
59
|
requirement: !ruby/object:Gem::Requirement
|
44
60
|
requirements:
|
45
|
-
- - "
|
61
|
+
- - "~>"
|
46
62
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
63
|
+
version: '3.9'
|
48
64
|
type: :development
|
49
65
|
prerelease: false
|
50
66
|
version_requirements: !ruby/object:Gem::Requirement
|
51
67
|
requirements:
|
52
|
-
- - "
|
68
|
+
- - "~>"
|
53
69
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
70
|
+
version: '3.9'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rubocop
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.80.1
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.80.1
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rubocop-rspec
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.38.1
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.38.1
|
55
99
|
description:
|
56
100
|
email:
|
57
101
|
- douwe@gitlab.com
|
102
|
+
- stanhu@gitlab.com
|
103
|
+
- tamos@gitlab.com
|
58
104
|
executables: []
|
59
105
|
extensions: []
|
60
106
|
extra_rdoc_files: []
|
61
107
|
files:
|
62
108
|
- ".gitignore"
|
63
109
|
- ".rspec"
|
110
|
+
- ".rubocop.yml"
|
111
|
+
- ".rubocop_todo.yml"
|
64
112
|
- ".travis.yml"
|
65
113
|
- Gemfile
|
66
114
|
- LICENSE.txt
|
@@ -70,9 +118,10 @@ files:
|
|
70
118
|
- bin/setup
|
71
119
|
- gitlab-license.gemspec
|
72
120
|
- lib/gitlab/license.rb
|
121
|
+
- lib/gitlab/license/boundary.rb
|
73
122
|
- lib/gitlab/license/encryptor.rb
|
74
123
|
- lib/gitlab/license/version.rb
|
75
|
-
homepage: https://gitlab.
|
124
|
+
homepage: https://dev.gitlab.org/gitlab/gitlab-license
|
76
125
|
licenses:
|
77
126
|
- MIT
|
78
127
|
metadata: {}
|
@@ -84,15 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
133
|
requirements:
|
85
134
|
- - ">="
|
86
135
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
136
|
+
version: 2.3.0
|
88
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
138
|
requirements:
|
90
139
|
- - ">="
|
91
140
|
- !ruby/object:Gem::Version
|
92
141
|
version: '0'
|
93
142
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.2.2
|
143
|
+
rubygems_version: 3.0.3
|
96
144
|
signing_key:
|
97
145
|
specification_version: 4
|
98
146
|
summary: gitlab-license helps you generate, verify and enforce software licenses.
|