From b2016dcc506c745245486e28738d70ea5a48d474 Mon Sep 17 00:00:00 2001 From: Lakr Aream <25259084+Lakr233@users.noreply.github.com> Date: Mon, 24 Jan 2022 16:53:47 +0800 Subject: [PATCH 01/62] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5aae44c..fa954b1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # GitLab-License-Generator -Generator GitLab License For Self-Hosted/Private Instances + +Generator GitLab License For Self-Hosted/Private Instances. + +**THIS IS NOT A CRACK WHICH MEANS YOU CAN NOT USE IT DIRECTLY** From 6795844de4b9230eb837038e6b75b631cdd00645 Mon Sep 17 00:00:00 2001 From: Lakr Aream <25259084+Lakr233@users.noreply.github.com> Date: Thu, 25 Aug 2022 00:33:47 +0800 Subject: [PATCH 02/62] Update for 15.3.1+ --- generate_licenses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate_licenses.rb b/generate_licenses.rb index c9aae84..e02e547 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -424,7 +424,7 @@ def set_datetime_attribute(attr_name, value) license.starts_at = Date.new(2000, 1, 1) license.restrictions = { - plan: 'ultimate', + plan: 'Ultimate', active_user_count: 100000000, } From d54f5c18e4725e2af9b36d0f77d54f5bc5efa696 Mon Sep 17 00:00:00 2001 From: Lakr Aream Date: Fri, 2 Sep 2022 13:45:21 +0800 Subject: [PATCH 03/62] updated validation --- generate_licenses.rb | 418 +-------------------------------------- lib/license.rb | 291 +++++++++++++++++++++++++++ lib/license/boundary.rb | 40 ++++ lib/license/encryptor.rb | 92 +++++++++ lib/license/version.rb | 5 + license_key | 50 ++--- license_key.pub | 14 +- result.gitlab-license | 45 ++--- 8 files changed, 492 insertions(+), 463 deletions(-) create mode 100644 lib/license.rb create mode 100644 lib/license/boundary.rb create mode 100644 lib/license/encryptor.rb create mode 100644 lib/license/version.rb diff --git a/generate_licenses.rb b/generate_licenses.rb index e02e547..3047508 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -1,408 +1,7 @@ -require 'openssl' -require 'date' -require 'json' -require 'base64' - -module Gitlab - class License - VERSION = '2.1.0'.freeze - end -end - -module Gitlab - class License - class Encryptor - class Error < StandardError; end - class KeyError < Error; end - class DecryptionError < Error; end - - attr_accessor :key - - def initialize(key) - raise KeyError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA) - - @key = key - end - - def encrypt(data) - raise KeyError, 'Provided key is not a private key.' unless key.private? - - # Encrypt the data using symmetric AES encryption. - cipher = OpenSSL::Cipher::AES128.new(:CBC) - cipher.encrypt - aes_key = cipher.random_key - aes_iv = cipher.random_iv - - encrypted_data = cipher.update(data) + cipher.final - - # Encrypt the AES key using asymmetric RSA encryption. - encrypted_key = key.private_encrypt(aes_key) - - encryption_data = { - 'data' => Base64.encode64(encrypted_data), - 'key' => Base64.encode64(encrypted_key), - 'iv' => Base64.encode64(aes_iv) - } - - json_data = JSON.dump(encryption_data) - Base64.encode64(json_data) - end - - def decrypt(data) - raise KeyError, 'Provided key is not a public key.' unless key.public? - - json_data = Base64.decode64(data.chomp) - - begin - encryption_data = JSON.parse(json_data) - rescue JSON::ParserError - raise DecryptionError, 'Encryption data is invalid JSON.' - end - - unless %w[data key iv].all? { |key| encryption_data[key] } - raise DecryptionError, 'Required field missing from encryption data.' - end - - encrypted_data = Base64.decode64(encryption_data['data']) - encrypted_key = Base64.decode64(encryption_data['key']) - aes_iv = Base64.decode64(encryption_data['iv']) - - begin - # Decrypt the AES key using asymmetric RSA encryption. - aes_key = self.key.public_decrypt(encrypted_key) - rescue OpenSSL::PKey::RSAError - raise DecryptionError, 'AES encryption key could not be decrypted.' - end - - # Decrypt the data using symmetric AES encryption. - cipher = OpenSSL::Cipher::AES128.new(:CBC) - cipher.decrypt - - begin - cipher.key = aes_key - rescue OpenSSL::Cipher::CipherError - raise DecryptionError, 'AES encryption key is invalid.' - end - - begin - cipher.iv = aes_iv - rescue OpenSSL::Cipher::CipherError - raise DecryptionError, 'AES IV is invalid.' - end - - begin - data = cipher.update(encrypted_data) + cipher.final - rescue OpenSSL::Cipher::CipherError - raise DecryptionError, 'Data could not be decrypted.' - end - - data - end - end - end -end - -module Gitlab - class License - module Boundary - BOUNDARY_START = /(\A|\r?\n)-*BEGIN .+? LICENSE-*\r?\n/.freeze - BOUNDARY_END = /\r?\n-*END .+? LICENSE-*(\r?\n|\z)/.freeze - - class << self - def add_boundary(data, product_name) - data = remove_boundary(data) - - product_name.upcase! - - pad = lambda do |message, width| - total_padding = [width - message.length, 0].max - - padding = total_padding / 2.0 - [ - '-' * padding.ceil, - message, - '-' * padding.floor - ].join - end - - [ - pad.call("BEGIN #{product_name} LICENSE", 60), - data.strip, - pad.call("END #{product_name} LICENSE", 60) - ].join("\n") - end - - def remove_boundary(data) - after_boundary = data.split(BOUNDARY_START).last - in_boundary = after_boundary.split(BOUNDARY_END).first - - in_boundary - end - end - end - end -end - -module Gitlab - class License - class Error < StandardError; end - class ImportError < Error; end - class ValidationError < Error; end - - class << self - attr_reader :encryption_key - @encryption_key = nil - - def encryption_key=(key) - raise ArgumentError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA) - - @encryption_key = key - @encryptor = nil - end - - def encryptor - @encryptor ||= Encryptor.new(encryption_key) - end - - def import(data) - raise ImportError, 'No license data.' if data.nil? - - data = Boundary.remove_boundary(data) - - begin - license_json = encryptor.decrypt(data) - rescue Encryptor::Error - raise ImportError, 'License data could not be decrypted.' - end - - begin - attributes = JSON.parse(license_json) - rescue JSON::ParseError - raise ImportError, 'License data is invalid JSON.' - end - - new(attributes) - end - end - - attr_reader :version - attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at, - :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at, - :activated_at, :restrictions, :cloud_licensing_enabled, - :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled, - :operational_metrics_enabled, :generated_from_customers_dot - - alias_method :issued_at, :starts_at - alias_method :issued_at=, :starts_at= - - def initialize(attributes = {}) - load_attributes(attributes) - end - - def valid? - if !licensee || !licensee.is_a?(Hash) || licensee.empty? - false - elsif !starts_at || !starts_at.is_a?(Date) - false - elsif expires_at && !expires_at.is_a?(Date) - false - elsif notify_admins_at && !notify_admins_at.is_a?(Date) - false - elsif notify_users_at && !notify_users_at.is_a?(Date) - false - elsif block_changes_at && !block_changes_at.is_a?(Date) - false - elsif last_synced_at && !last_synced_at.is_a?(DateTime) - false - elsif next_sync_at && !next_sync_at.is_a?(DateTime) - false - elsif activated_at && !activated_at.is_a?(DateTime) - false - elsif restrictions && !restrictions.is_a?(Hash) - false - elsif !cloud_licensing? && offline_cloud_licensing? - false - else - true - end - end - - def validate! - raise ValidationError, 'License is invalid' unless valid? - end - - def will_expire? - expires_at - end - - def will_notify_admins? - notify_admins_at - end - - def will_notify_users? - notify_users_at - end - - def will_block_changes? - block_changes_at - end - - def will_sync? - next_sync_at - end - - def activated? - activated_at - end - - def expired? - will_expire? && Date.today >= expires_at - end - - def notify_admins? - will_notify_admins? && Date.today >= notify_admins_at - end - - def notify_users? - will_notify_users? && Date.today >= notify_users_at - end - - def block_changes? - will_block_changes? && Date.today >= block_changes_at - end - - def cloud_licensing? - cloud_licensing_enabled == true - end - - def offline_cloud_licensing? - offline_cloud_licensing_enabled == true - end - - def auto_renew? - auto_renew_enabled == true - end - - def seat_reconciliation? - seat_reconciliation_enabled == true - end - - def operational_metrics? - operational_metrics_enabled == true - end - - def generated_from_customers_dot? - generated_from_customers_dot == true - end - - def restricted?(key = nil) - if key - restricted? && restrictions.has_key?(key) - else - restrictions && restrictions.length >= 1 - end - end - - def attributes - hash = {} - - hash['version'] = version - hash['licensee'] = licensee - - hash['issued_at'] = starts_at - hash['expires_at'] = expires_at if will_expire? - - hash['notify_admins_at'] = notify_admins_at if will_notify_admins? - hash['notify_users_at'] = notify_users_at if will_notify_users? - hash['block_changes_at'] = block_changes_at if will_block_changes? - - hash['next_sync_at'] = next_sync_at if will_sync? - hash['last_synced_at'] = last_synced_at if will_sync? - hash['activated_at'] = activated_at if activated? - - hash['cloud_licensing_enabled'] = cloud_licensing? - hash['offline_cloud_licensing_enabled'] = offline_cloud_licensing? - hash['auto_renew_enabled'] = auto_renew? - hash['seat_reconciliation_enabled'] = seat_reconciliation? - hash['operational_metrics_enabled'] = operational_metrics? - - hash['generated_from_customers_dot'] = generated_from_customers_dot? - - hash['restrictions'] = restrictions if restricted? - - hash - end - - def to_json(*_args) - JSON.dump(attributes) - end - - def export(boundary: nil) - validate! - - puts to_json - - data = self.class.encryptor.encrypt(to_json) - - data = Boundary.add_boundary(data, boundary) if boundary - - data - end - - private - - def load_attributes(attributes) - attributes = attributes.transform_keys(&:to_s) - - version = attributes['version'] || 1 - raise ArgumentError, 'Version is too new' unless version && version == 1 - - @version = version - - @licensee = attributes['licensee'] - - %w[issued_at expires_at notify_admins_at notify_users_at block_changes_at].each do |attr_name| - set_date_attribute(attr_name, attributes[attr_name]) - end - - %w[last_synced_at next_sync_at activated_at].each do |attr_name| - set_datetime_attribute(attr_name, attributes[attr_name]) - end - - %w[ - cloud_licensing_enabled - offline_cloud_licensing_enabled - auto_renew_enabled - seat_reconciliation_enabled - operational_metrics_enabled - generated_from_customers_dot - ].each do |attr_name| - public_send("#{attr_name}=", attributes[attr_name] == true) - end - - restrictions = attributes['restrictions'] - if restrictions&.is_a?(Hash) - restrictions = restrictions.transform_keys(&:to_sym) - @restrictions = restrictions - end - end - - def set_date_attribute(attr_name, value, date_class = Date) - value = date_class.parse(value) rescue nil if value.is_a?(String) - - return unless value - - public_send("#{attr_name}=", value) - end - - def set_datetime_attribute(attr_name, value) - set_date_attribute(attr_name, value, DateTime) - end - end -end +require_relative 'lib/license.rb' # MARK: GENERATOR - +# if !File.file?("license_key") || !File.file?("license_key.pub") puts "License key not found" puts "Generate a RSA key pair using generate_keys.rb" @@ -417,15 +16,16 @@ def set_datetime_attribute(attr_name, value) license = Gitlab::License.new license.licensee = { - "Name" => "GitLab Inc.", - "Company" => "GitLab Inc.", - "Email" => "support@gitlab.com" + "Name" => "Tim Cook", + "Company" => "Apple Computer, Inc.", + "Email" => "tcook@apple.com" } -license.starts_at = Date.new(2000, 1, 1) -license.restrictions = { +license.starts_at = Date.new(1976, 4, 1) +license.expires_at = Date.new(8848, 4, 1) +license.restrictions = { plan: 'Ultimate', - active_user_count: 100000000, + active_user_count: 1145141919810, } data = license.export diff --git a/lib/license.rb b/lib/license.rb new file mode 100644 index 000000000..eaac533 --- /dev/null +++ b/lib/license.rb @@ -0,0 +1,291 @@ +require 'openssl' +require 'date' +require 'json' +require 'base64' + +require_relative 'license/version' +require_relative 'license/encryptor' +require_relative 'license/boundary' + +module Gitlab + class License + class Error < StandardError; end + class ImportError < Error; end + class ValidationError < Error; end + + class << self + attr_reader :encryption_key + @encryption_key = nil + + def encryption_key=(key) + raise ArgumentError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA) + + @encryption_key = key + @encryptor = nil + end + + def encryptor + @encryptor ||= Encryptor.new(encryption_key) + end + + def import(data) + raise ImportError, 'No license data.' if data.nil? + + data = Boundary.remove_boundary(data) + + begin + license_json = encryptor.decrypt(data) + rescue Encryptor::Error + raise ImportError, 'License data could not be decrypted.' + end + + begin + attributes = JSON.parse(license_json) + rescue JSON::ParseError + raise ImportError, 'License data is invalid JSON.' + end + + new(attributes) + end + end + + attr_reader :version + attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at, + :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at, + :activated_at, :restrictions, :cloud_licensing_enabled, + :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled, + :operational_metrics_enabled, :generated_from_customers_dot + + alias_method :issued_at, :starts_at + alias_method :issued_at=, :starts_at= + + def initialize(attributes = {}) + load_attributes(attributes) + end + + def valid? + if !licensee || !licensee.is_a?(Hash) || licensee.empty? + puts "Invalid License - licensee is not a hash or is empty" + false + elsif !starts_at || !starts_at.is_a?(Date) + puts "Invalid License - starts_at is not a date" + false + elsif !expires_at && !gl_team_license? && !jh_team_license? + puts "Invalid License - expires_at is not a date" + false + elsif expires_at && !expires_at.is_a?(Date) + puts "Invalid License - expires_at is not a date" + false + elsif notify_admins_at && !notify_admins_at.is_a?(Date) + puts "Invalid License - notify_admins_at is not a date" + false + elsif notify_users_at && !notify_users_at.is_a?(Date) + puts "Invalid License - notify_users_at is not a date" + false + elsif block_changes_at && !block_changes_at.is_a?(Date) + puts "Invalid License - block_changes_at is not a date" + false + elsif last_synced_at && !last_synced_at.is_a?(DateTime) + puts "Invalid License - last_synced_at is not a datetime" + false + elsif next_sync_at && !next_sync_at.is_a?(DateTime) + puts "Invalid License - next_sync_at is not a datetime" + false + elsif activated_at && !activated_at.is_a?(DateTime) + puts "Invalid License - activated_at is not a datetime" + false + elsif restrictions && !restrictions.is_a?(Hash) + puts "Invalid License - restrictions is not a hash" + false + elsif !cloud_licensing? && offline_cloud_licensing? + puts "Invalid License - offline_cloud_licensing_enabled is true but cloud_licensing_enabled is false" + false + else + puts "License is valid" + true + end + end + + def validate! + raise ValidationError, 'License is invalid' unless valid? + end + + def will_expire? + expires_at + end + + def will_notify_admins? + notify_admins_at + end + + def will_notify_users? + notify_users_at + end + + def will_block_changes? + block_changes_at + end + + def will_sync? + next_sync_at + end + + def activated? + activated_at + end + + def expired? + will_expire? && Date.today >= expires_at + end + + def notify_admins? + will_notify_admins? && Date.today >= notify_admins_at + end + + def notify_users? + will_notify_users? && Date.today >= notify_users_at + end + + def block_changes? + will_block_changes? && Date.today >= block_changes_at + end + + def cloud_licensing? + cloud_licensing_enabled == true + end + + def offline_cloud_licensing? + offline_cloud_licensing_enabled == true + end + + def auto_renew? + auto_renew_enabled == true + end + + def seat_reconciliation? + seat_reconciliation_enabled == true + end + + def operational_metrics? + operational_metrics_enabled == true + end + + def generated_from_customers_dot? + generated_from_customers_dot == true + end + + def gl_team_license? + licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@gitlab.com') + end + + def jh_team_license? + licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@jihulab.com') + end + + def restricted?(key = nil) + if key + restricted? && restrictions.has_key?(key) + else + restrictions && restrictions.length >= 1 + end + end + + def attributes + hash = {} + + hash['version'] = version + hash['licensee'] = licensee + + # `issued_at` is the legacy name for starts_at. + # TODO: Move to starts_at in a next version. + hash['issued_at'] = starts_at + hash['expires_at'] = expires_at if will_expire? + + hash['notify_admins_at'] = notify_admins_at if will_notify_admins? + hash['notify_users_at'] = notify_users_at if will_notify_users? + hash['block_changes_at'] = block_changes_at if will_block_changes? + + hash['next_sync_at'] = next_sync_at if will_sync? + hash['last_synced_at'] = last_synced_at if will_sync? + hash['activated_at'] = activated_at if activated? + + hash['cloud_licensing_enabled'] = cloud_licensing? + hash['offline_cloud_licensing_enabled'] = offline_cloud_licensing? + hash['auto_renew_enabled'] = auto_renew? + hash['seat_reconciliation_enabled'] = seat_reconciliation? + hash['operational_metrics_enabled'] = operational_metrics? + + hash['generated_from_customers_dot'] = generated_from_customers_dot? + + hash['restrictions'] = restrictions if restricted? + + hash + end + + def to_json(*_args) + JSON.dump(attributes) + end + + def export(boundary: nil) + validate! + + data = self.class.encryptor.encrypt(to_json) + + data = Boundary.add_boundary(data, boundary) if boundary + + data + end + + private + + def load_attributes(attributes) + attributes = attributes.transform_keys(&:to_s) + + version = attributes['version'] || 1 + raise ArgumentError, 'Version is too new' unless version && version == 1 + + @version = version + + @licensee = attributes['licensee'] + + # `issued_at` is the legacy name for starts_at. + # TODO: Move to starts_at in a next version. + %w[issued_at expires_at notify_admins_at notify_users_at block_changes_at].each do |attr_name| + set_date_attribute(attr_name, attributes[attr_name]) + end + + %w[last_synced_at next_sync_at activated_at].each do |attr_name| + set_datetime_attribute(attr_name, attributes[attr_name]) + end + + %w[ + cloud_licensing_enabled + offline_cloud_licensing_enabled + auto_renew_enabled + seat_reconciliation_enabled + operational_metrics_enabled + generated_from_customers_dot + ].each do |attr_name| + public_send("#{attr_name}=", attributes[attr_name] == true) + end + + restrictions = attributes['restrictions'] + if restrictions&.is_a?(Hash) + restrictions = restrictions.transform_keys(&:to_sym) + @restrictions = restrictions + end + end + + def set_date_attribute(attr_name, value, date_class = Date) + value = date_class.parse(value) rescue nil if value.is_a?(String) + + return unless value + + public_send("#{attr_name}=", value) + end + + def set_datetime_attribute(attr_name, value) + set_date_attribute(attr_name, value, DateTime) + end + end +end diff --git a/lib/license/boundary.rb b/lib/license/boundary.rb new file mode 100644 index 000000000..019d5fc --- /dev/null +++ b/lib/license/boundary.rb @@ -0,0 +1,40 @@ +module Gitlab + class License + module Boundary + BOUNDARY_START = /(\A|\r?\n)-*BEGIN .+? LICENSE-*\r?\n/.freeze + BOUNDARY_END = /\r?\n-*END .+? LICENSE-*(\r?\n|\z)/.freeze + + class << self + def add_boundary(data, product_name) + data = remove_boundary(data) + + product_name.upcase! + + pad = lambda do |message, width| + total_padding = [width - message.length, 0].max + + padding = total_padding / 2.0 + [ + '-' * padding.ceil, + message, + '-' * padding.floor + ].join + end + + [ + pad.call("BEGIN #{product_name} LICENSE", 60), + data.strip, + pad.call("END #{product_name} LICENSE", 60) + ].join("\n") + end + + def remove_boundary(data) + after_boundary = data.split(BOUNDARY_START).last + in_boundary = after_boundary.split(BOUNDARY_END).first + + in_boundary + end + end + end + end +end diff --git a/lib/license/encryptor.rb b/lib/license/encryptor.rb new file mode 100644 index 000000000..6c70a07 --- /dev/null +++ b/lib/license/encryptor.rb @@ -0,0 +1,92 @@ +module Gitlab + class License + class Encryptor + class Error < StandardError; end + class KeyError < Error; end + class DecryptionError < Error; end + + attr_accessor :key + + def initialize(key) + raise KeyError, 'No RSA encryption key provided.' if key && !key.is_a?(OpenSSL::PKey::RSA) + + @key = key + end + + def encrypt(data) + raise KeyError, 'Provided key is not a private key.' unless key.private? + + # Encrypt the data using symmetric AES encryption. + cipher = OpenSSL::Cipher::AES128.new(:CBC) + cipher.encrypt + aes_key = cipher.random_key + aes_iv = cipher.random_iv + + encrypted_data = cipher.update(data) + cipher.final + + # Encrypt the AES key using asymmetric RSA encryption. + encrypted_key = key.private_encrypt(aes_key) + + encryption_data = { + 'data' => Base64.encode64(encrypted_data), + 'key' => Base64.encode64(encrypted_key), + 'iv' => Base64.encode64(aes_iv) + } + + json_data = JSON.dump(encryption_data) + Base64.encode64(json_data) + end + + def decrypt(data) + raise KeyError, 'Provided key is not a public key.' unless key.public? + + json_data = Base64.decode64(data.chomp) + + begin + encryption_data = JSON.parse(json_data) + rescue JSON::ParserError + raise DecryptionError, 'Encryption data is invalid JSON.' + end + + unless %w[data key iv].all? { |key| encryption_data[key] } + raise DecryptionError, 'Required field missing from encryption data.' + end + + encrypted_data = Base64.decode64(encryption_data['data']) + encrypted_key = Base64.decode64(encryption_data['key']) + aes_iv = Base64.decode64(encryption_data['iv']) + + begin + # Decrypt the AES key using asymmetric RSA encryption. + aes_key = self.key.public_decrypt(encrypted_key) + rescue OpenSSL::PKey::RSAError + raise DecryptionError, 'AES encryption key could not be decrypted.' + end + + # Decrypt the data using symmetric AES encryption. + cipher = OpenSSL::Cipher::AES128.new(:CBC) + cipher.decrypt + + begin + cipher.key = aes_key + rescue OpenSSL::Cipher::CipherError + raise DecryptionError, 'AES encryption key is invalid.' + end + + begin + cipher.iv = aes_iv + rescue OpenSSL::Cipher::CipherError + raise DecryptionError, 'AES IV is invalid.' + end + + begin + data = cipher.update(encrypted_data) + cipher.final + rescue OpenSSL::Cipher::CipherError + raise DecryptionError, 'Data could not be decrypted.' + end + + data + end + end + end +end diff --git a/lib/license/version.rb b/lib/license/version.rb new file mode 100644 index 000000000..3b734b9 --- /dev/null +++ b/lib/license/version.rb @@ -0,0 +1,5 @@ +module Gitlab + class License + VERSION = '2.2.1'.freeze + end +end diff --git a/license_key b/license_key index 665e32a..8ed3b3a 100644 --- a/license_key +++ b/license_key @@ -1,27 +1,27 @@ -----BEGIN RSA PRIVATE K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- diff --git a/license_key.pub b/license_key.pub index fcd4b9d..64eb81d 100644 --- a/license_key.pub +++ b/license_key.pub @@ -1,9 +1,9 @@ -----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAud4kAhXh7dQg9qlhqbwU -d1wrknf06vrT2Wc72lhag5jMtWSsHWEC817zNOTNkev3q6RYXUO0cm+fcZsO4g3I -y4ZbM9s5kXY1jDaM4Mc6JCehO7o11f4mY6FY6D1RHpk7GCKkS7ApbIjYkNt7TRYV -NUeMoY82g14NWjehWroOi23FOn4UXPX20mBCRjK0RFLQ26j0rWxHpD3yz0cbY8qx -3b9v/Jazlk282IakorxaHVTYN5aplspif3M1Ku36mRVXUVkoYRJl8vjUgicut6vc -qzrTk14l3quyPKri4Tnps/ZLvWGpd53UvEEevZxJVKVxdtgH0O2UCRVRXSuiG74Z -CwIDAQAB +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAreEfP/ncA1A5cuxBz7rS +0Z9DDxdSymLwt2OUSM5WJa+dVB3zSpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0 +rIifoj4oVpLhvnOAVjUn5tZeUX17tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B +59DjBxNqSm+GzhljHO7vvTKy2xXQQ7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtK +wQbFHAOvxFj8ghBh1Gshap1abExD4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBN +QDE3A5aKvpwLGozsvpGRMy5Tt4SgHC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/ +HwIDAQAB -----END PUBLIC KEY----- diff --git a/result.gitlab-license b/result.gitlab-license index b532deb..53a6ce3 100644 --- a/result.gitlab-license +++ b/result.gitlab-license @@ -1,22 +1,23 @@ -eyJkYXRhIjoieThyOWZHMjQyMGlMcEFnaS9nOFYxZmNobitoakxWSmszYTRU -czhTdTZ0VG80akFLdXhNM1NQbGJM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VraDRKR2J0MlM1WWxaTGo4S3VhcExLTjF2ajdvNDVc +bkxUaFZUOHJwTy9Hc1ZUMVV6L2xtOTJoa2NtS2FtQkdQN1ZIT2F1eVI0QS9z +ZEpXZVc0L2poU25SRUFMelxuUHVvK3A3aGxsekN5aEZ0RUlXdENWZ1ptUjFC +ejJoVm16bjdvMUFXdDIwZkFzTkN4OHArbERkVkJDL05YXG53cGl1TGVxTjBY +anpLTG8waWN1VWNOSmg4Ynp2WkoxTzQ2bzhtRUxpelVmb2xWMlFqUXg5OUdS +eWF0bjZcbmZKeTJvMEw1MWRXUnZHZUJsM09LR203WXdnTDRZTFFUd2tTeGtu +dmwwRGVVV0lmUk1vYmN3SFlmeTF3TlxuYU9TUVFUb3M3dHp6cXBRbmtJRjZH +cUlLNUdXUmZ3Y0ZQSldVdlRONFV3PT1cbiIsIml2IjoiamllcXNJK0Q0bHpP +dDNtbkRVdU1yZz09XG4ifQ== From f37415377d6af2d3b9bcde34a932e6ff8406fbed Mon Sep 17 00:00:00 2001 From: Lakr Aream Date: Fri, 2 Sep 2022 15:24:51 +0800 Subject: [PATCH 04/62] updated validation --- generate_licenses.rb | 11 ++++++----- make.sh | 2 +- result.gitlab-license | 46 +++++++++++++++++++++---------------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/generate_licenses.rb b/generate_licenses.rb index 3047508..eb83904 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -21,11 +21,12 @@ "Email" => "tcook@apple.com" } -license.starts_at = Date.new(1976, 4, 1) -license.expires_at = Date.new(8848, 4, 1) -license.restrictions = { - plan: 'Ultimate', - active_user_count: 1145141919810, +license.starts_at = Date.new(1976, 4, 1) +license.expires_at = Date.new(2500, 4, 1) + +license.restrictions = { + plan: 'ultimate', + active_user_count: 2147483647, } data = license.export diff --git a/make.sh b/make.sh index e6aa410..c643fea 100755 --- a/make.sh +++ b/make.sh @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")" -ruby ./generate_keys.rb +# ruby ./generate_keys.rb ruby ./generate_licenses.rb echo "done" \ No newline at end of file diff --git a/result.gitlab-license b/result.gitlab-license index 53a6ce3..49f767a 100644 --- a/result.gitlab-license +++ b/result.gitlab-license @@ -1,23 +1,23 @@ -eyJkYXRhIjoiRGdQZUxTaXFiSEdWNk9qUnRtNlZ0OHcrZTg3ZTdDbWZIdCtK -UnZVMVAyV0wrK3I4OUZ5VjNqWGk3aEFrXG5uTElTdlJUWUFPMjZDUi9JWEsv -L29FeFJuYUZmYlkxUXc0TnpoWVl5VjN3bjlIdVAzZHhvY2t6d3lad2Ncbmdt -Q0ZlMk5TSWJYYjd3WWtIUGd0RFZmS0tYVW5CUFhqbXVDeFdsTVdqa2M4L05h -NkQySFRFcTNXRm9WN1xuMkhaNGFrTnFzV2Z6SUdBOHhZQ0FHY096S2tRVzZY -SFJrd3BlWjkwemV3R1oxYXJsVzFBdDRpNkN1U0NiXG5vb2E3QVVUYzJFTGxi -U25SdGhnd05rcDBCcW1nVE02VmFCL3MrYVA3NXhQNzRNcmo2WWFzeExybGZL -aklcbm5WTmtyRlk4R25TNzNMRkFaUmZrY04reEF0NHFsV1ZhVkx1YVM4MmVR -d0tmU3NUaFR1UDhnZHk4cGtUOVxuMkNIT052QlJCYzlaYmZIS2kvblNDSmtt -YVB6OTd6eU41TnVWR2NsN1Z3TXd4VDBsSHV2N1VSQmxZVGRuXG5wM1FaWG5O -MW5qb0JlTlN1dk5CM1RIZ09KMzRMbDk3WWV2MUhMeDljQ0dTMFdHd3FZVHFz -azFnbDlUTXZcbmNuVzZKem9oWFZoTW81ZkhKVTFNZ1hZcDNvbDR3SFJvZUlo -dXNYVWhKWmc0eTdLYWVWMUp2VFBxVDFiQ1xuQnlSMkdsOEI4c1h1YU9kUGor -N3dBK1hpN2VYM0VYSmdqYlYwXG4iLCJrZXkiOiJEcy9Ma2ZXamI5elZuTVRF -TElPbUJ6WkFZeGxrbHVraDRKR2J0MlM1WWxaTGo4S3VhcExLTjF2ajdvNDVc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FwaTlX +ZmZqeU9rWnE1TldVNVNqMDFwTlk4T3hlK2hWWXN2amUwUTMrSFF4QUZGTlBy +eldMa09VYVlcbllUZm1tdTRSNjZYc0dVZW8yZ3N3K1F5VnVZSjBGZEkrK2h4 +TDhFMmJ6Z1A5RHRpNW1ybk0remg4MDVhb1xudVEyOG15ekJPc3d5MEFxK3lH +OXlJZnQxRkc1MGRQTkt1VTl3XG4iLCJrZXkiOiJIRDUvNWR1L0kramVIUWEx +eEljSnF4cHFmMjAvTG5oNDFFcldBMTZ3MW82ZktKVDBjS3NheFlJWWo4NUxc +bmlGc3oyRm1ZakFZMGdhdXYwM1F1Z1FQZm1hNXdJdkRIdGxXenlxSC9sWXgv +QnR5d2tva2VpUllsVDFLclxuMGgwWEFFYTljeElCVTdpSXZMQnE3bE40LzRS +amlqRWExZmtpVmdlN2x2NlQybVNtWGRGTHNsUGJyQndtXG50Y1BMREhvaStR +TTZKMHpMVUtITGFRcnZYWVoraWgxQVdtM3Iyc3A2Q2p0d0lidE9jcC9aMmhS +NmQxb09cbmFmWXJ1MnhldThva0ZpR2ZIeklJcUdMM29yelFEeHVKU0FJaW9u +bExHakhMQVBlbzNRWkxweWRndzhsUFxuc2s0MHRYMS90WUJHTEg1Q3VKenpI +SzhsMW42ZUNQUzFFVituckV6NmxnPT1cbiIsIml2IjoiN3pOWngwUTNXOHR0 +OVArcTVaOEhvQT09XG4ifQ== From 2ff74641bec6ebf9728661dca991e878260fa12e Mon Sep 17 00:00:00 2001 From: Lakr Aream Date: Fri, 2 Sep 2022 15:58:20 +0800 Subject: [PATCH 05/62] updated validation --- generate_keys.rb | 10 -------- generate_licenses.rb | 53 +++++++++++++++++++++++++++++++++++-------- make.sh | 10 ++------ result.gitlab-license | 47 +++++++++++++++++++------------------- 4 files changed, 70 insertions(+), 50 deletions(-) delete mode 100644 generate_keys.rb diff --git a/generate_keys.rb b/generate_keys.rb deleted file mode 100644 index 197f2ad..000000000 --- a/generate_keys.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'openssl' - -key_pair = OpenSSL::PKey::RSA.generate(2048) -File.open("license_key", "w") { |f| f.write(key_pair.to_pem) } - -public_key = key_pair.public_key -File.open("license_key.pub", "w") { |f| f.write(public_key.to_pem) } - -puts "Generated RSA key pairs, use generate_licenses.rb to generate licenses." -puts "Make your own customization to the code if needed." \ No newline at end of file diff --git a/generate_licenses.rb b/generate_licenses.rb index eb83904..6fe9c24 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -1,33 +1,68 @@ +require 'openssl' require_relative 'lib/license.rb' -# MARK: GENERATOR -# -if !File.file?("license_key") || !File.file?("license_key.pub") - puts "License key not found" - puts "Generate a RSA key pair using generate_keys.rb" - exit +LICENSE_TARGET_PRIVATE_KEY = "license_key" +LICENSE_TARGET_PUBLIC_KEY = "license_key.pub" +TARGET_LICENSE_FILE = 'result.gitlab-license' + +puts "[i] gitlab license generator - core v2.2.1" +puts "" + +if !File.exist?(LICENSE_TARGET_PRIVATE_KEY) || !File.exist?(LICENSE_TARGET_PUBLIC_KEY) + puts "[*] generating RSA keys..." + key = OpenSSL::PKey::RSA.new(2048) + File.write(LICENSE_TARGET_PRIVATE_KEY, key.to_pem) + File.write(LICENSE_TARGET_PUBLIC_KEY, key.public_key.to_pem) end -public_key = OpenSSL::PKey::RSA.new File.read("license_key.pub") -private_key = OpenSSL::PKey::RSA.new File.read("license_key") +puts "[*] loading RSA keys..." + +public_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PUBLIC_KEY) +private_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PRIVATE_KEY) + +puts "[*] building license..." Gitlab::License.encryption_key = private_key license = Gitlab::License.new +# don't use gitlab inc, search `gl_team_license` in lib for details license.licensee = { "Name" => "Tim Cook", "Company" => "Apple Computer, Inc.", "Email" => "tcook@apple.com" } +# required of course license.starts_at = Date.new(1976, 4, 1) + +# required since gem gitlab-license v2.2.1 license.expires_at = Date.new(2500, 4, 1) +# prevent gitlab crash at +# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at +license.block_changes_at = Date.new(2500, 4, 1) + +# required license.restrictions = { plan: 'ultimate', + # STARTER_PLAN = 'starter' + # PREMIUM_PLAN = 'premium' + # ULTIMATE_PLAN = 'ultimate' + active_user_count: 2147483647, + # required, just dont overflow } +puts "[*] calling export" + +puts "" +puts "=====================================================" + data = license.export -File.open("result.gitlab-license", "w") { |f| f.write(data) } +File.open(TARGET_LICENSE_FILE, "w") { |f| f.write(data) } + +puts "=====================================================" +puts "" + +puts "[*] License generated successfully!" \ No newline at end of file diff --git a/make.sh b/make.sh index c643fea..dc2541d 100755 --- a/make.sh +++ b/make.sh @@ -1,10 +1,4 @@ #!/bin/bash -set -e - -cd "$(dirname "$0")" - -# ruby ./generate_keys.rb -ruby ./generate_licenses.rb - -echo "done" \ No newline at end of file +cd "$(dirname "$0")" || exit 1 +ruby ./generate_licenses.rb \ No newline at end of file diff --git a/result.gitlab-license b/result.gitlab-license index 49f767a..3b7e5fb 100644 --- a/result.gitlab-license +++ b/result.gitlab-license @@ -1,23 +1,24 @@ -eyJkYXRhIjoiUW5sQ2NiL1Q5ME50RHVoYm1kU2l5S2ZEdElVczcwSWc1Q280 -UVRRM0FRMDYyQml1TlJrakRBa1QramVYXG5VODdRYktlTmc3Mm5lVE9YeFIr -MWxkWEVvaVhPS0JXOTVzSmZnY2Fla29XZWZBV2xXQWIzQkJMSU91TnRcbklE -WkRMMXNUTFQrenBlOGNMcW5vdE1GQjVBOWtveklYNWZIbXJMUVVtY2wvWldz -VGZ6d0JPVUpMUnRIK1xuSUk2ajlVUWZkTndXMDhlUXpjV0hCSUZFajl4bnJu -YnBlcFNzKzFQS0RSeGFsS0JtWUVFUmRnSTVOUFBaXG5pNVdGRTNxUDc2QkxK -UDNOZ24xWUV3b3BuTG82V1BiSVR6S1VRempaQVprQXFDRHhjellYZzJXdnpq -ODVcbitucFVWYUxiUkt2aTZSK2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pNenk1VTQz +enlSTnBrXG4rWmJ3YUY0cXpmMEZwSXd2ZnpGL3MyYTU3VC9JeGZvd3dMVG5j +NjJSYk45OWtGRlloQlhIc3dWSGdZN3VcbklOLzh0V2txdXJacU5zRGZ5N0RR +RmtwTTAvLzF0ekt3RURwWktRdlc1QT09XG4iLCJpdiI6IjdmenVqb1RZV3VV +MytQTzBkVS94c3c9PVxuIn0= From 5988594787292905cb2ae67f5bd5a3eafb50ec95 Mon Sep 17 00:00:00 2001 From: Lakr Aream Date: Fri, 2 Sep 2022 15:58:48 +0800 Subject: [PATCH 06/62] updated validation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fa954b1..09b460f 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ Generator GitLab License For Self-Hosted/Private Instances. +Last tested: 15.3.2-ee + **THIS IS NOT A CRACK WHICH MEANS YOU CAN NOT USE IT DIRECTLY** From 4fd7395c662c428548b16da0d3a706c98c68fd71 Mon Sep 17 00:00:00 2001 From: Lakr Aream Date: Fri, 2 Sep 2022 16:11:14 +0800 Subject: [PATCH 07/62] updated validation --- generate_licenses.rb | 28 +++++++++++++++++-------- result.gitlab-license | 48 +++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/generate_licenses.rb b/generate_licenses.rb index 6fe9c24..87e25a9 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -1,26 +1,31 @@ -require 'openssl' -require_relative 'lib/license.rb' +# GitLab License Generator LICENSE_TARGET_PRIVATE_KEY = "license_key" LICENSE_TARGET_PUBLIC_KEY = "license_key.pub" TARGET_LICENSE_FILE = 'result.gitlab-license' -puts "[i] gitlab license generator - core v2.2.1" -puts "" +puts "[*] Booting generator" + +require 'openssl' + +require_relative 'lib/license.rb' +CORE_LIB_VERSION = '2.2.1' + +puts "[i] Using core library version #{CORE_LIB_VERSION}" if !File.exist?(LICENSE_TARGET_PRIVATE_KEY) || !File.exist?(LICENSE_TARGET_PUBLIC_KEY) - puts "[*] generating RSA keys..." + puts "[*] Generating RSA keys..." key = OpenSSL::PKey::RSA.new(2048) File.write(LICENSE_TARGET_PRIVATE_KEY, key.to_pem) File.write(LICENSE_TARGET_PUBLIC_KEY, key.public_key.to_pem) end -puts "[*] loading RSA keys..." +puts "[*] Loading RSA keys..." public_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PUBLIC_KEY) private_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PRIVATE_KEY) -puts "[*] building license..." +puts "[*] Building license..." Gitlab::License.encryption_key = private_key @@ -54,15 +59,20 @@ # required, just dont overflow } -puts "[*] calling export" +puts "[*] Calling export..." puts "" puts "=====================================================" +puts JSON.pretty_generate(JSON.parse(license.to_json)) + +puts "=====================================================" + data = license.export File.open(TARGET_LICENSE_FILE, "w") { |f| f.write(data) } puts "=====================================================" puts "" -puts "[*] License generated successfully!" \ No newline at end of file +puts "[*] License generated successfully!" +puts "[*] License file: #{TARGET_LICENSE_FILE}" diff --git a/result.gitlab-license b/result.gitlab-license index 3b7e5fb..6b8ee3a 100644 --- a/result.gitlab-license +++ b/result.gitlab-license @@ -1,24 +1,24 @@ -eyJkYXRhIjoiT2FaeExyaDhuOEk1dkFSK3d1akhsaWNudVUvSnJtS04veSs0 -anhSV3V4K2g0ZDNrMHgvNHlBVVordE0yXG5sU1FEZ1NUSE5xM3J3N2pYbzhQ -V0JRM21JeDZ1VHRjdVROVlRyQ0FHNUV1STZFZzRzcFJCQzBQSjFjRHNcbis1 -V0s2UDhici9EMldKdytjbldSN3JqT0JqZndHcVB4NU9YZGlJMkV0clFFUHVy -UnFsZDRjNGI1VXpNeVxuaWlDMy9pNGIwQlVWUXB4bUpRTDdCVXczVFB6c2FR -cTBTam16cjFIaWF5TWJPaHE2ZytyVnd0aytGdE43XG52Q09DejVWSVVGTHJS -NHNpQUVkWCtMMFNQR3FoRldTeElQODMwREdRcHFtbjdTNEtNRVZRT0FyR24r -NlBcbnRT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rTnE0cGhqWktuQ1dneXk3dGU4YWI5Qm5ZNVBlYVxuWUNPL1I0SGpI +MkhKTnhmamd2TWh0YThMNXgrbmt2RXhBODFIRDFsQlVXZzJlQi92RzZjblg0 +YkRPRWF3XG5tVHJpMS9VLzRVcVVoQnRSYklVSnZZeGFCMC9hT3owaStLVkdw +SENSTCs3OXQveHA1NVg2bkRQWlhwdGdcbkE0WXJrbFVHUlF0RnZyMjRRMGxa +TndrS2Z4eU1pOWkrclgrVzVIa1MvQT09XG4iLCJpdiI6Im1FL1RodjE4MWJQ +eGNFaWVwdEhCWnc9PVxuIn0= From a0db30fead6d018dd3fcb5089c51aeefddacf3bb Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Tue, 29 Aug 2023 00:00:38 +0800 Subject: [PATCH 08/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09b460f..c2c77fa 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ Generator GitLab License For Self-Hosted/Private Instances. -Last tested: 15.3.2-ee +Last tested: 16.3.0-ee **THIS IS NOT A CRACK WHICH MEANS YOU CAN NOT USE IT DIRECTLY** From d76d4cde32c2cf4a3e54d8c27c0a28b2a8b9b013 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Mon, 25 Sep 2023 04:50:33 -0500 Subject: [PATCH 09/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2c77fa..095f6b8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ Generator GitLab License For Self-Hosted/Private Instances. -Last tested: 16.3.0-ee +Last tested: 16.4.0-ee **THIS IS NOT A CRACK WHICH MEANS YOU CAN NOT USE IT DIRECTLY** From f0a18bace1b6b34ab6fe6d00a42d8035abad0c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Tue, 26 Dec 2023 21:03:56 +0800 Subject: [PATCH 10/62] Auto Update --- .gitignore | 7 ++++ .root | 0 feature.scan.py | 49 +++++++++++++++++++++++++ generate_licenses.rb | 59 ++++++++++++++++++------------ lib/license.rb | 56 ++++++++++++++++++---------- lib/license/version.rb | 2 +- license_key | 27 -------------- license_key.pub | 9 ----- make.sh | 83 ++++++++++++++++++++++++++++++++++++++++-- result.gitlab-license | 24 ------------ 10 files changed, 210 insertions(+), 106 deletions(-) create mode 100644 .root create mode 100755 feature.scan.py delete mode 100644 license_key delete mode 100644 license_key.pub delete mode 100644 result.gitlab-license diff --git a/.gitignore b/.gitignore index e3200e0..03a0905 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,10 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* + +temp/ +output/ +license_key +license_key.pub +result.gitlab-license +features.list diff --git a/.root b/.root new file mode 100644 index 000000000..e69de29 diff --git a/feature.scan.py b/feature.scan.py new file mode 100755 index 000000000..b0fcc87 --- /dev/null +++ b/feature.scan.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import re +import os +import sys + +SCANNING_DIR = sys.argv[1] +OUTPUT_LIST_FILE = sys.argv[2] +print(f"[*] scanning directory: {SCANNING_DIR}") + +# use regex to find the string +# eg ::License.feature_available?(:aaa) || ::Feature.enabled?(:bbb, self) +# make sure +? for shortest match +REGEX_PARTTERN = "License.feature_available\?\(:.+?\)" + +REQUIRED_FILE_SUFFIX = ['rb'] + +scanning_file_list = set() +def build_file_list(input: str): + global scanning_file_list + scanning_file_list.add(input) + if os.path.isdir(input): + for file in os.listdir(input): + build_file_list(os.path.join(input, file)) +build_file_list(SCANNING_DIR) + +print(f"[*] scanning {len(scanning_file_list)} files...") +feature_list=set() +for file in scanning_file_list: + if not os.path.isfile(file): continue + if not file.split(".")[-1] in REQUIRED_FILE_SUFFIX: continue + with open(file, "r") as f: + content = f.read() + all_match = re.findall(REGEX_PARTTERN, content) + all_match = [x.split(":")[1].split(")")[0] for x in all_match] + all_match = [x for x in all_match if x] + feature_list.update(all_match) +print(f"[*] found {len(feature_list)} features") + +feature_list = list(feature_list) +feature_list.sort() + +print(f"[*] writing to {OUTPUT_LIST_FILE}...") +with open(OUTPUT_LIST_FILE, "w") as f: + for feature in feature_list: + f.write(feature + "\n") + +print(f"[*] done") diff --git a/generate_licenses.rb b/generate_licenses.rb index 87e25a9..344b4bc 100644 --- a/generate_licenses.rb +++ b/generate_licenses.rb @@ -1,31 +1,47 @@ -# GitLab License Generator +#!/usr/bin/env ruby +# encoding: utf-8 + +require 'openssl' +require_relative 'lib/license.rb' +puts "[i] lib gitlab-license: #{Gitlab::License::VERSION}" + +OUTPUT_DIR = ARGV[0] +puts "[*] output dir: #{OUTPUT_DIR}" LICENSE_TARGET_PRIVATE_KEY = "license_key" LICENSE_TARGET_PUBLIC_KEY = "license_key.pub" TARGET_LICENSE_FILE = 'result.gitlab-license' +TARGET_PLAIN_LICENSE_FILE = 'result.gitlab-license.json' + +FEATURE_LIST = [] +if ARGV[1].nil? + puts "[i] you can provide a list of feature to be enabled inside license" +else + FEATURE_LIST_FILE = ARGV[1] + File.open(FEATURE_LIST_FILE).each do |line| + FEATURE_LIST.push(line.chomp) + end + FEATURE_LIST.uniq! +end +puts "[*] loaded #{FEATURE_LIST.length} features" -puts "[*] Booting generator" - -require 'openssl' - -require_relative 'lib/license.rb' -CORE_LIB_VERSION = '2.2.1' - -puts "[i] Using core library version #{CORE_LIB_VERSION}" +Dir.chdir(OUTPUT_DIR) +puts "[*] switching working dir: #{Dir.pwd}" +puts "[*] generating license..." if !File.exist?(LICENSE_TARGET_PRIVATE_KEY) || !File.exist?(LICENSE_TARGET_PUBLIC_KEY) - puts "[*] Generating RSA keys..." + puts "[*] generating rsa key pair..." key = OpenSSL::PKey::RSA.new(2048) File.write(LICENSE_TARGET_PRIVATE_KEY, key.to_pem) File.write(LICENSE_TARGET_PUBLIC_KEY, key.public_key.to_pem) end -puts "[*] Loading RSA keys..." +puts "[*] loading key pair..." public_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PUBLIC_KEY) private_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PRIVATE_KEY) -puts "[*] Building license..." +puts "[*] building license..." Gitlab::License.encryption_key = private_key @@ -59,20 +75,17 @@ # required, just dont overflow } -puts "[*] Calling export..." - -puts "" -puts "=====================================================" +if !license.valid? + puts "[E] license validation failed!" + puts "[E] #{license.errors}" + exit 1 +end -puts JSON.pretty_generate(JSON.parse(license.to_json)) +puts "[*] exporting license file..." -puts "=====================================================" +File.open(TARGET_PLAIN_LICENSE_FILE, "w") { |f| f.write(JSON.pretty_generate(JSON.parse(license.to_json))) } data = license.export File.open(TARGET_LICENSE_FILE, "w") { |f| f.write(data) } -puts "=====================================================" -puts "" - -puts "[*] License generated successfully!" -puts "[*] License file: #{TARGET_LICENSE_FILE}" +puts "[*] done" diff --git a/lib/license.rb b/lib/license.rb index eaac533..c2648b5 100644 --- a/lib/license.rb +++ b/lib/license.rb @@ -15,6 +15,7 @@ class ValidationError < Error; end class << self attr_reader :encryption_key + attr_reader :fallback_decryption_keys @encryption_key = nil def encryption_key=(key) @@ -24,6 +25,19 @@ def encryption_key=(key) @encryptor = nil end + def fallback_decryption_keys=(keys) + unless keys + @fallback_decryption_keys = nil + return + end + + unless keys.is_a?(Enumerable) && keys.all? { |key| key.is_a?(OpenSSL::PKey::RSA) } + raise ArgumentError, 'Invalid fallback RSA encryption keys provided.' + end + + @fallback_decryption_keys = Array(keys) + end + def encryptor @encryptor ||= Encryptor.new(encryption_key) end @@ -33,11 +47,7 @@ def import(data) data = Boundary.remove_boundary(data) - begin - license_json = encryptor.decrypt(data) - rescue Encryptor::Error - raise ImportError, 'License data could not be decrypted.' - end + license_json = decrypt_with_fallback_keys(data) begin attributes = JSON.parse(license_json) @@ -47,6 +57,20 @@ def import(data) new(attributes) end + + def decrypt_with_fallback_keys(data) + keys_to_try = Array(encryption_key) + keys_to_try += fallback_decryption_keys if fallback_decryption_keys + + keys_to_try.each do |decryption_key| + decryptor = Encryptor.new(decryption_key) + return decryptor.decrypt(data) + rescue Encryptor::Error + next + end + + raise ImportError, 'License data could not be decrypted.' + end end attr_reader :version @@ -54,7 +78,8 @@ def import(data) :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at, :activated_at, :restrictions, :cloud_licensing_enabled, :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled, - :operational_metrics_enabled, :generated_from_customers_dot + :operational_metrics_enabled, :generated_from_customers_dot, + :generated_from_cancellation alias_method :issued_at, :starts_at alias_method :issued_at=, :starts_at= @@ -65,43 +90,30 @@ def initialize(attributes = {}) def valid? if !licensee || !licensee.is_a?(Hash) || licensee.empty? - puts "Invalid License - licensee is not a hash or is empty" false elsif !starts_at || !starts_at.is_a?(Date) - puts "Invalid License - starts_at is not a date" false elsif !expires_at && !gl_team_license? && !jh_team_license? - puts "Invalid License - expires_at is not a date" false elsif expires_at && !expires_at.is_a?(Date) - puts "Invalid License - expires_at is not a date" false elsif notify_admins_at && !notify_admins_at.is_a?(Date) - puts "Invalid License - notify_admins_at is not a date" false elsif notify_users_at && !notify_users_at.is_a?(Date) - puts "Invalid License - notify_users_at is not a date" false elsif block_changes_at && !block_changes_at.is_a?(Date) - puts "Invalid License - block_changes_at is not a date" false elsif last_synced_at && !last_synced_at.is_a?(DateTime) - puts "Invalid License - last_synced_at is not a datetime" false elsif next_sync_at && !next_sync_at.is_a?(DateTime) - puts "Invalid License - next_sync_at is not a datetime" false elsif activated_at && !activated_at.is_a?(DateTime) - puts "Invalid License - activated_at is not a datetime" false elsif restrictions && !restrictions.is_a?(Hash) - puts "Invalid License - restrictions is not a hash" false elsif !cloud_licensing? && offline_cloud_licensing? - puts "Invalid License - offline_cloud_licensing_enabled is true but cloud_licensing_enabled is false" false else - puts "License is valid" true end end @@ -174,6 +186,10 @@ def generated_from_customers_dot? generated_from_customers_dot == true end + def generated_from_cancellation? + generated_from_cancellation == true + end + def gl_team_license? licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@gitlab.com') end @@ -216,6 +232,7 @@ def attributes hash['operational_metrics_enabled'] = operational_metrics? hash['generated_from_customers_dot'] = generated_from_customers_dot? + hash['generated_from_cancellation'] = generated_from_cancellation? hash['restrictions'] = restrictions if restricted? @@ -265,6 +282,7 @@ def load_attributes(attributes) seat_reconciliation_enabled operational_metrics_enabled generated_from_customers_dot + generated_from_cancellation ].each do |attr_name| public_send("#{attr_name}=", attributes[attr_name] == true) end diff --git a/lib/license/version.rb b/lib/license/version.rb index 3b734b9..c0c6742 100644 --- a/lib/license/version.rb +++ b/lib/license/version.rb @@ -1,5 +1,5 @@ module Gitlab class License - VERSION = '2.2.1'.freeze + VERSION = '2.4.0'.freeze end end diff --git a/license_key b/license_key deleted file mode 100644 index 8ed3b3a..000000000 --- a/license_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAreEfP/ncA1A5cuxBz7rS0Z9DDxdSymLwt2OUSM5WJa+dVB3z -SpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0rIifoj4oVpLhvnOAVjUn5tZeUX17 -tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B59DjBxNqSm+GzhljHO7vvTKy2xXQ -Q7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtKwQbFHAOvxFj8ghBh1Gshap1abExD -4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBNQDE3A5aKvpwLGozsvpGRMy5Tt4Sg -HC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/HwIDAQABAoIBACb3f4hX112KugUu -OyVxidNebKnSIUSn3ahLkayrSRUTASAbwi0he8GJfLqzXrAFqx6QYCml9KVxnBHW -me6LKGOODrBOW73jFuIWgllPeky6F9MNWw7wTAT+GWP46u6AK8z93QZSZq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+4u1fi+eNl7uF7RRaD1 ------END RSA PRIVATE KEY----- diff --git a/license_key.pub b/license_key.pub deleted file mode 100644 index 64eb81d..000000000 --- a/license_key.pub +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAreEfP/ncA1A5cuxBz7rS -0Z9DDxdSymLwt2OUSM5WJa+dVB3zSpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0 -rIifoj4oVpLhvnOAVjUn5tZeUX17tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B -59DjBxNqSm+GzhljHO7vvTKy2xXQQ7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtK -wQbFHAOvxFj8ghBh1Gshap1abExD4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBN -QDE3A5aKvpwLGozsvpGRMy5Tt4SgHC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/ -HwIDAQAB ------END PUBLIC KEY----- diff --git a/make.sh b/make.sh index dc2541d..2f7649e 100755 --- a/make.sh +++ b/make.sh @@ -1,4 +1,81 @@ -#!/bin/bash +#!/bin/zsh -cd "$(dirname "$0")" || exit 1 -ruby ./generate_licenses.rb \ No newline at end of file +set -e + +cd "$(dirname "$0")" +if [ ! -f ".root" ]; then + echo "[!] failed to locate project directory, aborting..." + exit 1 +fi +WORKING_DIR=$(pwd) + +mkdir temp || true + +echo "[*] fetching ruby gem version..." +RB_GEM_NAME="gitlab-license" +RB_GEM_LIST_OUTPUT=$(gem list --remote $RB_GEM_NAME) + +RB_GEM_VERSION="" +while IFS= read -r line; do + if [[ $line == "gitlab-license ("* ]]; then + RB_GEM_VERSION=${line#"gitlab-license ("} + RB_GEM_VERSION=${RB_GEM_VERSION%")"} + break + fi +done <<< "$RB_GEM_LIST_OUTPUT" + +echo "[*] gitlab-license version: $RB_GEM_VERSION" +RB_GEM_DOWNLOAD_URL="https://rubygems.org/downloads/gitlab-license-$RB_GEM_VERSION.gem" +RB_GEM_DOWNLOAD_PATH=$(pwd)/temp/gem/gitlab-license.gem +mkdir -p $(dirname $RB_GEM_DOWNLOAD_PATH) +curl -L $RB_GEM_DOWNLOAD_URL -o $RB_GEM_DOWNLOAD_PATH +pushd $(dirname $RB_GEM_DOWNLOAD_PATH) > /dev/null +tar -xzf gitlab-license.gem +tar -xzf data.tar.gz + +if [ ! -f "./lib/gitlab/license.rb" ]; then + echo "[!] failed to locate gem file, aborting..." + exit 1 +fi + +echo "[*] copying gem..." +rm -rf "$WORKING_DIR/lib" || true +mkdir -p "$WORKING_DIR/lib" +cp -r ./lib/gitlab/* $WORKING_DIR/lib +popd > /dev/null + +pushd lib > /dev/null +echo "[*] patching lib requirements gem..." +# replace `require 'gitlab/license/` with `require 'license/` to make it work +find . -type f -exec sed -i '' 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; +popd > /dev/null + +echo "[*] updated gem" + +echo "[*] fetching gitlab source code..." +GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src/ +if [ -d "$GITLAB_SOURCE_CODE_DIR" ]; then + echo "[*] gitlab source code already exists, skipping cloning..." +else + echo "[*] cloning gitlab source code..." + git clone https://gitlab.com/gitlab-org/gitlab.git $GITLAB_SOURCE_CODE_DIR +fi + +echo "[*] updating gitlab source code..." +pushd $GITLAB_SOURCE_CODE_DIR > /dev/null +git clean -fdx -f +git reset --hard +git pull +popd > /dev/null + +echo "[*] scanning features..." +FEATURE_LIST_FILE=$(pwd)/temp/features.txt +rm -f $FEATURE_LIST_FILE || true +./feature.scan.py $GITLAB_SOURCE_CODE_DIR $FEATURE_LIST_FILE + +echo "[*] generating license..." +OUTPUT_DIR=$(pwd)/output +mkdir -p $OUTPUT_DIR +ruby ./generate_licenses.rb $OUTPUT_DIR $FEATURE_LIST_FILE + +echo "[*] done $(basename $0)" \ No newline at end of file diff --git a/result.gitlab-license b/result.gitlab-license deleted file mode 100644 index 6b8ee3a..000000000 --- a/result.gitlab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RSkFQLytRdGd4 -eDJiRnpFRlF5bk0zc0dnRUtcbkZRUkQzUGNTWkpzZGtXdkltWGEzWnlsMEg2 -WEtGelgrTnE0cGhqWktuQ1dneXk3dGU4YWI5Qm5ZNVBlYVxuWUNPL1I0SGpI -MkhKTnhmamd2TWh0YThMNXgrbmt2RXhBODFIRDFsQlVXZzJlQi92RzZjblg0 -YkRPRWF3XG5tVHJpMS9VLzRVcVVoQnRSYklVSnZZeGFCMC9hT3owaStLVkdw -SENSTCs3OXQveHA1NVg2bkRQWlhwdGdcbkE0WXJrbFVHUlF0RnZyMjRRMGxa -TndrS2Z4eU1pOWkrclgrVzVIa1MvQT09XG4iLCJpdiI6Im1FL1RodjE4MWJQ -eGNFaWVwdEhCWnc9PVxuIn0= From 83f34a87b935b441664a7ab22a7e11a19d15bfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 00:59:10 +0800 Subject: [PATCH 11/62] Done Feature Scanning --- feature.scan.py | 49 --------------- generate_licenses.rb | 91 ---------------------------- make.sh | 39 +++++++++--- src/generator.keys.rb | 44 ++++++++++++++ src/generator.license.rb | 127 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 200 insertions(+), 150 deletions(-) delete mode 100755 feature.scan.py delete mode 100644 generate_licenses.rb create mode 100755 src/generator.keys.rb create mode 100755 src/generator.license.rb diff --git a/feature.scan.py b/feature.scan.py deleted file mode 100755 index b0fcc87..000000000 --- a/feature.scan.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import re -import os -import sys - -SCANNING_DIR = sys.argv[1] -OUTPUT_LIST_FILE = sys.argv[2] -print(f"[*] scanning directory: {SCANNING_DIR}") - -# use regex to find the string -# eg ::License.feature_available?(:aaa) || ::Feature.enabled?(:bbb, self) -# make sure +? for shortest match -REGEX_PARTTERN = "License.feature_available\?\(:.+?\)" - -REQUIRED_FILE_SUFFIX = ['rb'] - -scanning_file_list = set() -def build_file_list(input: str): - global scanning_file_list - scanning_file_list.add(input) - if os.path.isdir(input): - for file in os.listdir(input): - build_file_list(os.path.join(input, file)) -build_file_list(SCANNING_DIR) - -print(f"[*] scanning {len(scanning_file_list)} files...") -feature_list=set() -for file in scanning_file_list: - if not os.path.isfile(file): continue - if not file.split(".")[-1] in REQUIRED_FILE_SUFFIX: continue - with open(file, "r") as f: - content = f.read() - all_match = re.findall(REGEX_PARTTERN, content) - all_match = [x.split(":")[1].split(")")[0] for x in all_match] - all_match = [x for x in all_match if x] - feature_list.update(all_match) -print(f"[*] found {len(feature_list)} features") - -feature_list = list(feature_list) -feature_list.sort() - -print(f"[*] writing to {OUTPUT_LIST_FILE}...") -with open(OUTPUT_LIST_FILE, "w") as f: - for feature in feature_list: - f.write(feature + "\n") - -print(f"[*] done") diff --git a/generate_licenses.rb b/generate_licenses.rb deleted file mode 100644 index 344b4bc..000000000 --- a/generate_licenses.rb +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env ruby -# encoding: utf-8 - -require 'openssl' -require_relative 'lib/license.rb' -puts "[i] lib gitlab-license: #{Gitlab::License::VERSION}" - -OUTPUT_DIR = ARGV[0] -puts "[*] output dir: #{OUTPUT_DIR}" - -LICENSE_TARGET_PRIVATE_KEY = "license_key" -LICENSE_TARGET_PUBLIC_KEY = "license_key.pub" -TARGET_LICENSE_FILE = 'result.gitlab-license' -TARGET_PLAIN_LICENSE_FILE = 'result.gitlab-license.json' - -FEATURE_LIST = [] -if ARGV[1].nil? - puts "[i] you can provide a list of feature to be enabled inside license" -else - FEATURE_LIST_FILE = ARGV[1] - File.open(FEATURE_LIST_FILE).each do |line| - FEATURE_LIST.push(line.chomp) - end - FEATURE_LIST.uniq! -end -puts "[*] loaded #{FEATURE_LIST.length} features" - -Dir.chdir(OUTPUT_DIR) -puts "[*] switching working dir: #{Dir.pwd}" - -puts "[*] generating license..." -if !File.exist?(LICENSE_TARGET_PRIVATE_KEY) || !File.exist?(LICENSE_TARGET_PUBLIC_KEY) - puts "[*] generating rsa key pair..." - key = OpenSSL::PKey::RSA.new(2048) - File.write(LICENSE_TARGET_PRIVATE_KEY, key.to_pem) - File.write(LICENSE_TARGET_PUBLIC_KEY, key.public_key.to_pem) -end - -puts "[*] loading key pair..." - -public_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PUBLIC_KEY) -private_key = OpenSSL::PKey::RSA.new File.read(LICENSE_TARGET_PRIVATE_KEY) - -puts "[*] building license..." - -Gitlab::License.encryption_key = private_key - -license = Gitlab::License.new - -# don't use gitlab inc, search `gl_team_license` in lib for details -license.licensee = { - "Name" => "Tim Cook", - "Company" => "Apple Computer, Inc.", - "Email" => "tcook@apple.com" -} - -# required of course -license.starts_at = Date.new(1976, 4, 1) - -# required since gem gitlab-license v2.2.1 -license.expires_at = Date.new(2500, 4, 1) - -# prevent gitlab crash at -# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at -license.block_changes_at = Date.new(2500, 4, 1) - -# required -license.restrictions = { - plan: 'ultimate', - # STARTER_PLAN = 'starter' - # PREMIUM_PLAN = 'premium' - # ULTIMATE_PLAN = 'ultimate' - - active_user_count: 2147483647, - # required, just dont overflow -} - -if !license.valid? - puts "[E] license validation failed!" - puts "[E] #{license.errors}" - exit 1 -end - -puts "[*] exporting license file..." - -File.open(TARGET_PLAIN_LICENSE_FILE, "w") { |f| f.write(JSON.pretty_generate(JSON.parse(license.to_json))) } - -data = license.export -File.open(TARGET_LICENSE_FILE, "w") { |f| f.write(data) } - -puts "[*] done" diff --git a/make.sh b/make.sh index 2f7649e..22d8ce8 100755 --- a/make.sh +++ b/make.sh @@ -9,7 +9,7 @@ if [ ! -f ".root" ]; then fi WORKING_DIR=$(pwd) -mkdir temp || true +mkdir temp 2> /dev/null || true echo "[*] fetching ruby gem version..." RB_GEM_NAME="gitlab-license" @@ -28,7 +28,7 @@ echo "[*] gitlab-license version: $RB_GEM_VERSION" RB_GEM_DOWNLOAD_URL="https://rubygems.org/downloads/gitlab-license-$RB_GEM_VERSION.gem" RB_GEM_DOWNLOAD_PATH=$(pwd)/temp/gem/gitlab-license.gem mkdir -p $(dirname $RB_GEM_DOWNLOAD_PATH) -curl -L $RB_GEM_DOWNLOAD_URL -o $RB_GEM_DOWNLOAD_PATH +curl -L $RB_GEM_DOWNLOAD_URL -o $RB_GEM_DOWNLOAD_PATH 1> /dev/null 2> /dev/null pushd $(dirname $RB_GEM_DOWNLOAD_PATH) > /dev/null tar -xzf gitlab-license.gem tar -xzf data.tar.gz @@ -63,19 +63,38 @@ fi echo "[*] updating gitlab source code..." pushd $GITLAB_SOURCE_CODE_DIR > /dev/null -git clean -fdx -f -git reset --hard -git pull +git clean -fdx -f > /dev/null +git reset --hard > /dev/null +git pull > /dev/null popd > /dev/null +BUILD_DIR=$(pwd)/build +mkdir -p $BUILD_DIR + echo "[*] scanning features..." -FEATURE_LIST_FILE=$(pwd)/temp/features.txt +FEATURE_LIST_FILE=$BUILD_DIR/features.json rm -f $FEATURE_LIST_FILE || true -./feature.scan.py $GITLAB_SOURCE_CODE_DIR $FEATURE_LIST_FILE +./src/scan.features.rb \ + -o $FEATURE_LIST_FILE \ + -s $GITLAB_SOURCE_CODE_DIR + +echo "[*] generating key pair..." +PUBLIC_KEY_FILE=$BUILD_DIR/public.key +PRIVATE_KEY_FILE=$BUILD_DIR/private.key +./src/generator.keys.rb \ + --public-key $PUBLIC_KEY_FILE \ + --private-key $PRIVATE_KEY_FILE \ + || true # ignore error if key already exists echo "[*] generating license..." -OUTPUT_DIR=$(pwd)/output -mkdir -p $OUTPUT_DIR -ruby ./generate_licenses.rb $OUTPUT_DIR $FEATURE_LIST_FILE +LICENSE_FILE=$BUILD_DIR/license.data +LICENSE_JSON_FILE=$BUILD_DIR/license.json + +./src/generator.license.rb \ + -f $FEATURE_LIST_FILE \ + --public-key $PUBLIC_KEY_FILE \ + --private-key $PRIVATE_KEY_FILE \ + -o $LICENSE_FILE \ + --plain-license $LICENSE_JSON_FILE echo "[*] done $(basename $0)" \ No newline at end of file diff --git a/src/generator.keys.rb b/src/generator.keys.rb new file mode 100755 index 000000000..c52370b --- /dev/null +++ b/src/generator.keys.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +require 'optparse' +require 'openssl' + +public_key_file = nil +private_key_file = nil + +OptionParser.new do |opts| + opts.banner = "Usage: generator.keys.rb [options]" + + opts.on("--public-key PATH", "Specify public key file (required)") do |v| + public_key_file = File.expand_path(v) + end + + opts.on("--private-key PATH", "Specify private key file (required)") do |v| + private_key_file = File.expand_path(v) + end + + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end.parse! + +if public_key_file.nil? || private_key_file.nil? + puts "[!] missing required options" + puts "[!] use -h for help" + exit 1 +end + +if File.exist?(private_key_file) || File.exist?(public_key_file) + puts "[!] key pair already exists" + puts "[!] remove them if you want to regenerate" + exit 1 +end + +puts "[*] generating rsa key pair..." +key = OpenSSL::PKey::RSA.new(2048) +File.write(private_key_file, key.to_pem) +File.write(public_key_file, key.public_key.to_pem) + +puts "[*] done" diff --git a/src/generator.license.rb b/src/generator.license.rb new file mode 100755 index 000000000..6d6d61d --- /dev/null +++ b/src/generator.license.rb @@ -0,0 +1,127 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +license_file_path = nil +license_json_path = nil +public_key_path = nil +private_key_path = nil +features_json_path = nil + +require 'optparse' +OptionParser.new do |opts| + opts.banner = "Usage: generator.license.rb [options]" + + opts.on("-o", "--output PATH", "Output to dir (required)") do |v| + license_file_path = File.expand_path(v) + end + + opts.on("--public-key PATH", "Specify public key file (required)") do |v| + public_key_path = File.expand_path(v) + end + + opts.on("--private-key PATH", "Specify private key file (required)") do |v| + private_key_path = File.expand_path(v) + end + + opts.on("-f", "--features PATH", "Specify features json file (optional)") do |v| + features_json_path = File.expand_path(v) + end + + opts.on("--plain-license PATH", "Export license in json if set, useful for debug. (optional)") do |v| + license_json_path = File.expand_path(v) + end + + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end +.parse! + +if license_file_path.nil? || public_key_path.nil? || private_key_path.nil? + puts "[!] missing required options" + puts "[!] use -h for help" + exit 1 +end + +# ========== + +puts "[*] loading keys..." +require 'openssl' +PUBLIC_KEY = OpenSSL::PKey::RSA.new File.read(public_key_path) +PRIVATE_KEY = OpenSSL::PKey::RSA.new File.read(private_key_path) + +puts "[*] loading licenses..." +require_relative '../lib/license.rb' +puts "[i] lib gitlab-license: #{Gitlab::License::VERSION}" + +if !features_json_path.nil? + puts "[*] loading features from #{features_json_path}" + require 'json' + FEATURE_LIST = JSON.parse(File.read(features_json_path)) +else + FEATURE_LIST = [] +end +puts "[*] total features to inject: #{FEATURE_LIST.size}" + +# ========== + +puts "[*] building a license..." + +Gitlab::License.encryption_key = PRIVATE_KEY + +license = Gitlab::License.new + +# don't use gitlab inc, search `gl_team_license` in lib for details +license.licensee = { + "Name" => "Tim Cook", + "Company" => "Apple Computer, Inc.", + "Email" => "tcook@apple.com" +} + +# required of course +license.starts_at = Date.new(1976, 4, 1) + +# required since gem gitlab-license v2.2.1 +license.expires_at = Date.new(2500, 4, 1) + +# prevent gitlab crash at +# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at +license.block_changes_at = Date.new(2500, 4, 1) + +# required +license.restrictions = { + plan: 'ultimate', + # STARTER_PLAN = 'starter' + # PREMIUM_PLAN = 'premium' + # ULTIMATE_PLAN = 'ultimate' + + active_user_count: 2147483647, + # required, just dont overflow +} + +# restricted_attr will access restrictions +# add_ons will access restricted_attr(:add_ons, {}) +# so here by we inject all features into restrictions +# see scan.rb for a list of features that we are going to inject +for feature in FEATURE_LIST + license.restrictions[feature] = 2147483647 +end + +if !license.valid? + puts "[E] license validation failed!" + puts "[E] #{license.errors}" + exit 1 +end + +puts "[*] exporting license file..." + +if !license_json_path.nil? + puts "[*] writing to #{license_json_path}" + File.write(license_json_path, JSON.pretty_generate(JSON.parse(license.to_json))) +end + +puts "[*] writing to #{license_file_path}" +File.write(license_file_path, license.export) + +puts "[*] done" From 668d9c56be132d2d69e6128c13d57d3b281db3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:30:22 +0800 Subject: [PATCH 12/62] Update License Name --- .gitignore | 1 + make.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 03a0905..353103b 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ license_key license_key.pub result.gitlab-license features.list +.DS_Store diff --git a/make.sh b/make.sh index 22d8ce8..2e0186a 100755 --- a/make.sh +++ b/make.sh @@ -87,7 +87,7 @@ PRIVATE_KEY_FILE=$BUILD_DIR/private.key || true # ignore error if key already exists echo "[*] generating license..." -LICENSE_FILE=$BUILD_DIR/license.data +LICENSE_FILE=$BUILD_DIR/result.gitlab-license LICENSE_JSON_FILE=$BUILD_DIR/license.json ./src/generator.license.rb \ From 20f084eec795df9560bdae78e4b86f610d11823d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:32:01 +0800 Subject: [PATCH 13/62] Update generator.license.rb --- src/generator.license.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/generator.license.rb b/src/generator.license.rb index 6d6d61d..eccc57b 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -108,11 +108,13 @@ license.restrictions[feature] = 2147483647 end +puts "[*] validating license..." if !license.valid? puts "[E] license validation failed!" puts "[E] #{license.errors}" exit 1 end +puts "[*] license validated" puts "[*] exporting license file..." From c5edcd6e25bad50505a3d5211abf5fe74d8037e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:51:45 +0800 Subject: [PATCH 14/62] Put Back Old Keys --- .github/.gitkeep | 0 .github/workflows/build.yml | 20 ++++++++++++++++++++ keys/private.key | 27 +++++++++++++++++++++++++++ keys/public.key | 9 +++++++++ make.sh | 11 +++++++---- 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 .github/.gitkeep create mode 100644 .github/workflows/build.yml create mode 100644 keys/private.key create mode 100644 keys/public.key diff --git a/.github/.gitkeep b/.github/.gitkeep new file mode 100644 index 000000000..e69de29 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..c3bf78e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: Ruby Gem + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 1 * * *" + +jobs: + rebuild: + runs-on: macos-latest + steps: + - name: Checkout Source Code + uses: actions/checkout@v4.1.1 + - name: Build + run: | + ./make.sh diff --git a/keys/private.key b/keys/private.key new file mode 100644 index 000000000..f46fe43 --- /dev/null +++ b/keys/private.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAreEfP/ncA1A5cuxBz7rS0Z9DDxdSymLwt2OUSM5WJa+dVB3z +SpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0rIifoj4oVpLhvnOAVjUn5tZeUX17 +tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B59DjBxNqSm+GzhljHO7vvTKy2xXQ +Q7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtKwQbFHAOvxFj8ghBh1Gshap1abExD +4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBNQDE3A5aKvpwLGozsvpGRMy5Tt4Sg +HC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/HwIDAQABAoIBACb3f4hX112KugUu +OyVxidNebKnSIUSn3ahLkayrSRUTASAbwi0he8GJfLqzXrAFqx6QYCml9KVxnBHW +me6LKGOODrBOW73jFuIWgllPeky6F9MNWw7wTAT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cUzcO7Bspm/JvkuaL+4u1fi+eNl7uF7RRaD1 +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/keys/public.key b/keys/public.key new file mode 100644 index 000000000..add326c --- /dev/null +++ b/keys/public.key @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAreEfP/ncA1A5cuxBz7rS +0Z9DDxdSymLwt2OUSM5WJa+dVB3zSpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0 +rIifoj4oVpLhvnOAVjUn5tZeUX17tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B +59DjBxNqSm+GzhljHO7vvTKy2xXQQ7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtK +wQbFHAOvxFj8ghBh1Gshap1abExD4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBN +QDE3A5aKvpwLGozsvpGRMy5Tt4SgHC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/ +HwIDAQAB +-----END PUBLIC KEY----- \ No newline at end of file diff --git a/make.sh b/make.sh index 2e0186a..aacbc52 100755 --- a/make.sh +++ b/make.sh @@ -81,10 +81,13 @@ rm -f $FEATURE_LIST_FILE || true echo "[*] generating key pair..." PUBLIC_KEY_FILE=$BUILD_DIR/public.key PRIVATE_KEY_FILE=$BUILD_DIR/private.key -./src/generator.keys.rb \ - --public-key $PUBLIC_KEY_FILE \ - --private-key $PRIVATE_KEY_FILE \ - || true # ignore error if key already exists +cp -f ./keys/public.key $PUBLIC_KEY_FILE +cp -f ./keys/private.key $PRIVATE_KEY_FILE + +# execute following command to generate new keys +# ./src/generator.keys.rb \ +# --public-key $PUBLIC_KEY_FILE \ +# --private-key $PRIVATE_KEY_FILE echo "[*] generating license..." LICENSE_FILE=$BUILD_DIR/result.gitlab-license From 1f3d986989111a0c403a9c5485a777e01ddf68f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:55:41 +0800 Subject: [PATCH 15/62] Update build.yml --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3bf78e..bde08a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,12 @@ jobs: runs-on: macos-latest steps: - name: Checkout Source Code - uses: actions/checkout@v4.1.1 + uses: actions/checkout@latest - name: Build run: | ./make.sh + - name: Upload Artifacts + uses: actions/upload-artifact@latest + with: + name: build + path: build From 5a71b73392ce4aeff97ee37761289957f46deec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:57:01 +0800 Subject: [PATCH 16/62] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bde08a3..f41ea06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,12 +14,12 @@ jobs: runs-on: macos-latest steps: - name: Checkout Source Code - uses: actions/checkout@latest + uses: actions/checkout@4.1.1 - name: Build run: | ./make.sh - name: Upload Artifacts - uses: actions/upload-artifact@latest + uses: actions/upload-artifact@v4 with: name: build path: build From f9307fbfb7d634e4f640a5d7534a22fe69c59782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 01:58:28 +0800 Subject: [PATCH 17/62] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f41ea06..2a0fb23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: macos-latest steps: - name: Checkout Source Code - uses: actions/checkout@4.1.1 + uses: actions/checkout@4 - name: Build run: | ./make.sh From 4ee5aab356c6374b45cb9a683a5467bca0682b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Wed, 27 Dec 2023 02:00:44 +0800 Subject: [PATCH 18/62] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a0fb23..6edbf90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: macos-latest steps: - name: Checkout Source Code - uses: actions/checkout@4 + uses: actions/checkout@v4 - name: Build run: | ./make.sh From f3f16cbad3f78822163f34c86e5061bfdf7372dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Thu, 28 Dec 2023 15:15:07 +0800 Subject: [PATCH 19/62] Update make.sh --- make.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index aacbc52..659f29d 100755 --- a/make.sh +++ b/make.sh @@ -1,5 +1,8 @@ #!/bin/zsh +echo "[i] GitLab License Generator" +echo "[i] Copyright (c) 2023 Tim Cook, All Rights Not Reserved" + set -e cd "$(dirname "$0")" @@ -30,8 +33,8 @@ RB_GEM_DOWNLOAD_PATH=$(pwd)/temp/gem/gitlab-license.gem mkdir -p $(dirname $RB_GEM_DOWNLOAD_PATH) curl -L $RB_GEM_DOWNLOAD_URL -o $RB_GEM_DOWNLOAD_PATH 1> /dev/null 2> /dev/null pushd $(dirname $RB_GEM_DOWNLOAD_PATH) > /dev/null -tar -xzf gitlab-license.gem -tar -xzf data.tar.gz +tar -xf gitlab-license.gem +tar -xf data.tar.gz if [ ! -f "./lib/gitlab/license.rb" ]; then echo "[!] failed to locate gem file, aborting..." From 4f72903666e4193301512cbb7c68b37c2220b9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Thu, 28 Dec 2023 15:15:42 +0800 Subject: [PATCH 20/62] Update make.sh --- make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.sh b/make.sh index 659f29d..4321673 100755 --- a/make.sh +++ b/make.sh @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/bin/bash echo "[i] GitLab License Generator" echo "[i] Copyright (c) 2023 Tim Cook, All Rights Not Reserved" From 3d42c646cec8d83b51fe71094b13a91a917d29de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Thu, 28 Dec 2023 15:39:56 +0800 Subject: [PATCH 21/62] Update README.md --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 095f6b8..86d9d35 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,66 @@ -# GitLab-License-Generator +# GitLab License Generator -Generator GitLab License For Self-Hosted/Private Instances. +This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested: 16.4.0-ee +Last tested on GitLab v16.7.0-ee . -**THIS IS NOT A CRACK WHICH MEANS YOU CAN NOT USE IT DIRECTLY** +## Principles + +**src/generator.keys.rb** + +The GitLab uses public/private key pair to encrypt the license. The public key is shipped with the GitLab distro and the private key is kept privately. The license it self is just a json dictionary. Since GitLab made their code open source, we can easily generate a license by our own. + +**src/generator.license.rb** + +The `lib` folder is extracted from GitLab's source. It is used for building and validating the license. Script `src/generator.license.rb` will load it. + +**src/scan.features.rb** + +The features is extracted from a object full of constant. The most powerful plan for a license is ultimate, but features like geo mirror is not included in any type of the plan. So here by we add them manually. + +## Usage + +Follow the procedure below to generate and install a license for your development use. + +### Get License + +**GitHub Action** + +Navigate to GitHub Action to download an artifact. + +**make.sh** + +This script is only tested on macOS. To build on Linux or other platform, you need to setup ruby with gem. + +### Install Test Key + +You will need to replace the public key shipped within GitLab distro. It is located at `/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub` most of the time. + +If you are using Docker, there is a easy way to do this. + +```yml +image: "gitlab/gitlab-ee:latest" +# ... +volumes: + - "public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub" +``` + +### Install License + +See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/license_file.html). Follow are part of the document. + +- Sign in to GitLab as an administrator. +- On the left sidebar, expand the top-most chevron. +- Select Admin Area. +- Select Settings > General. +- or entering the key. +- Select the Terms of Service checkbox. +- Select Add license. + +> In GitLab 14.7.x to 14.9.x, you can add the license file with the UI. In GitLab 14.1.x to 14.7, if you have already activated your subscription with an activation code, you cannot access Add License from the Admin Area. You must access Add License directly from the URL, /admin/license/new. + +## LICENSE + +This project is licensed under the WTFPL License. + +Copyrigth (c) 2023, Tim Cook, All Rights Not Reserved. From 23530f8822a5809b67d1d5279e2967f7a84f9c42 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:57:57 +0800 Subject: [PATCH 22/62] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 86d9d35..eb39ad1 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,12 @@ See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/li > In GitLab 14.7.x to 14.9.x, you can add the license file with the UI. In GitLab 14.1.x to 14.7, if you have already activated your subscription with an activation code, you cannot access Add License from the Admin Area. You must access Add License directly from the URL, /admin/license/new. +### Disable Service Ping + +> Service Ping is a GitLab process that collects and sends a weekly payload to GitLab. The payload provides important high-level data that helps our product, support, and sales teams understand how GitLab is used. + +See (GitLab Documents)[https://docs.gitlab.com/ee/development/internal_analytics/service_ping/] for details. + ## LICENSE This project is licensed under the WTFPL License. From e8c2e2632ec7c2ac0dcb61e1eaa277059215c636 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:58:32 +0800 Subject: [PATCH 23/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb39ad1..b603c57 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/li > Service Ping is a GitLab process that collects and sends a weekly payload to GitLab. The payload provides important high-level data that helps our product, support, and sales teams understand how GitLab is used. -See (GitLab Documents)[https://docs.gitlab.com/ee/development/internal_analytics/service_ping/] for details. +See [GitLab Documents](https://docs.gitlab.com/ee/development/internal_analytics/service_ping) for details. ## LICENSE From 11655378ff33a2c5392c5d435b7e00ce2d4c7bd2 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:58:52 +0800 Subject: [PATCH 24/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b603c57..9c832ef 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/li > Service Ping is a GitLab process that collects and sends a weekly payload to GitLab. The payload provides important high-level data that helps our product, support, and sales teams understand how GitLab is used. -See [GitLab Documents](https://docs.gitlab.com/ee/development/internal_analytics/service_ping) for details. +See [GitLab Document](https://docs.gitlab.com/ee/development/internal_analytics/service_ping) for details. ## LICENSE From 20ad8448f2c8608ffe413423d6cca14e25abe2d9 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Wed, 24 Jan 2024 00:39:24 +0800 Subject: [PATCH 25/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c832ef..b34854f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.7.0-ee . +Last tested on GitLab v16.8.0-ee . ## Principles From 95b17b7359bcd5ee2afd31f844d69e6f3e9e14a9 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:32:02 +0800 Subject: [PATCH 26/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b34854f..36e4c62 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.8.0-ee . +Last tested on GitLab v16.9.1-ee . ## Principles From a53c3c2b9a75ed5cd4f693b62ff0b66f2c6b9190 Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:28:24 +0900 Subject: [PATCH 27/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36e4c62..0f3967d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.9.1-ee . +Last tested on GitLab v16.9.2-ee . ## Principles From 06e26eddc5c9ee8f7db7deeb3a069c9867bda93d Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Sun, 24 Mar 2024 11:27:09 +0800 Subject: [PATCH 28/62] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f3967d..932e8cc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.9.2-ee . +Last tested on GitLab v16.10.0-ee . ## Principles From b3a013d4a001e6008a3fffe649e47a03d7e838aa Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:02:34 +0200 Subject: [PATCH 29/62] changed tested version Tested on v16.11.0-ee --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 932e8cc..d034c42 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.10.0-ee . +Last tested on GitLab v16.11.0-ee . ## Principles From 84fc4dad114d5ffa1d0dafa4bf411ef2e68bfbc7 Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Sun, 9 Jun 2024 12:57:06 +0200 Subject: [PATCH 30/62] Update test compatibility to v17.0.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d034c42..8b88c66 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v16.11.0-ee . +Last tested on GitLab v17.0.1-ee . ## Principles From 16e597f4822b63fac1314c1381ca9b7e25f0c972 Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:29:21 +0200 Subject: [PATCH 31/62] Update last tested version on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b88c66..d3db400 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v17.0.1-ee . +Last tested on GitLab v17.1.1-ee . ## Principles From cfb26f0c210fed016273e2697d8bb3d6ee9f61f4 Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:37:01 +0200 Subject: [PATCH 32/62] Fix make.sh linux support --- make.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/make.sh b/make.sh index 4321673..5dd23d6 100755 --- a/make.sh +++ b/make.sh @@ -49,8 +49,23 @@ popd > /dev/null pushd lib > /dev/null echo "[*] patching lib requirements gem..." + +# Determine the operating system +OS_TYPE="$(uname -s)" + +case "$OS_TYPE" in + Linux*) + sed_i_cmd="sed -i";; + Darwin*) + sed_i_cmd="sed -i ''";; + *) + echo "Unsupported OS: $OS_TYPE"; + exit 1;; +esac + # replace `require 'gitlab/license/` with `require 'license/` to make it work -find . -type f -exec sed -i '' 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; +find . -type f -exec $sed_i_cmd 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; + popd > /dev/null echo "[*] updated gem" @@ -103,4 +118,4 @@ LICENSE_JSON_FILE=$BUILD_DIR/license.json -o $LICENSE_FILE \ --plain-license $LICENSE_JSON_FILE -echo "[*] done $(basename $0)" \ No newline at end of file +echo "[*] done $(basename $0)" From 48e10872f5fbd646b9b4f2c529cdc9db9e48f466 Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:29:06 +0200 Subject: [PATCH 33/62] Update tested version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3db400..e65c457 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v17.1.1-ee . +Last tested on GitLab v17.2-ee . ## Principles From 545dbd26f04273e9d51191346e201f6136050695 Mon Sep 17 00:00:00 2001 From: Root Date: Fri, 30 Aug 2024 19:59:14 +0300 Subject: [PATCH 34/62] tested version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e65c457..50ac208 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v17.2-ee . +Last tested on GitLab v17.3-ee . ## Principles From c3df4717e57bd1336d42d2bad11c09d322d33f09 Mon Sep 17 00:00:00 2001 From: Gabriele Cabrini <71121134+gabrielecabrini@users.noreply.github.com> Date: Wed, 18 Sep 2024 00:51:18 +0200 Subject: [PATCH 35/62] docs: update last tested version in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50ac208..ac9013d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v17.3-ee . +Last tested on GitLab v17.3.2-ee . ## Principles From 2bd45c83de31e7f5bf412bcf00f7d65d68031dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20V=2E=20=7C=20Ov=E1=B4=87=CA=80Styl=E1=B4=87FR?= <94577363+OverStyleFR@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:25:47 +0200 Subject: [PATCH 36/62] Update | 'README.md' Tested version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac9013d..4b05fb0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. -Last tested on GitLab v17.3.2-ee . +Last tested on GitLab v17.4.1-ee . ## Principles From b7e2311d609a16411c5bf3473b6dcdc0df9a2903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20V=2E=20=7C=20Ov=E1=B4=87=CA=80Styl=E1=B4=87FR?= <94577363+OverStyleFR@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:55:33 +0200 Subject: [PATCH 37/62] Update | 'README.md' improve guide tutorial --- README.md | 146 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 109 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 4b05fb0..19c4a2e 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,144 @@ # GitLab License Generator -This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself. +This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. -Last tested on GitLab v17.4.1-ee . +Last tested on GitLab v17.4.1-ee. ## Principles -**src/generator.keys.rb** +### **src/generator.keys.rb** -The GitLab uses public/private key pair to encrypt the license. The public key is shipped with the GitLab distro and the private key is kept privately. The license it self is just a json dictionary. Since GitLab made their code open source, we can easily generate a license by our own. +GitLab uses a public/private key pair to encrypt its license. The public key is shipped with the GitLab distribution, while the private key is kept secure. The license itself is simply a JSON dictionary. Since GitLab has made its code open-source, we can easily generate our own license. -**src/generator.license.rb** +### **src/generator.license.rb** -The `lib` folder is extracted from GitLab's source. It is used for building and validating the license. Script `src/generator.license.rb` will load it. +The `lib` folder is extracted from GitLab's source code. It is used to build and validate the license. The script `src/generator.license.rb` loads this functionality. -**src/scan.features.rb** +### **src/scan.features.rb** -The features is extracted from a object full of constant. The most powerful plan for a license is ultimate, but features like geo mirror is not included in any type of the plan. So here by we add them manually. +Features are extracted from an object filled with constants. The most comprehensive plan for a license is **Ultimate**, but features like Geo Mirroring are not included in any standard plan. Therefore, we manually add these features. ## Usage -Follow the procedure below to generate and install a license for your development use. +### Prerequisites -### Get License +Before starting, ensure your environment is properly configured. -**GitHub Action** +#### 1. Install Ruby and gem +To run this project, you need **Ruby** and the **gem** package manager. -Navigate to GitHub Action to download an artifact. +- **On Linux (Ubuntu/Debian)**: + ```bash + sudo apt update + sudo apt install ruby-full + ``` -**make.sh** +- **On macOS** (via Homebrew): + ```bash + brew install ruby + ``` -This script is only tested on macOS. To build on Linux or other platform, you need to setup ruby with gem. +#### 2. Install Bundler and necessary gems +After installing Ruby, you need to install **Bundler** to manage Ruby dependencies. -### Install Test Key +```bash +gem install bundler +``` + +#### 3. Install the `gitlab-license` gem +The project requires the `gitlab-license` gem, which will be automatically downloaded and used by the script. -You will need to replace the public key shipped within GitLab distro. It is located at `/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub` most of the time. +```bash +gem install gitlab-license +``` -If you are using Docker, there is a easy way to do this. +### Steps to Generate the GitLab License -```yml -image: "gitlab/gitlab-ee:latest" -# ... -volumes: - - "public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub" +#### 1. Clone the project repository +Clone this project to your local machine. + +```bash +git clone https://github.com/Lakr233/GitLab-License-Generator.git +cd GitLab-License-Generator ``` -### Install License +#### 2. Run the `make.sh` script +Once all the prerequisites are met, run the script: + +```bash +./make.sh +``` + +The script will perform the following actions: +- Download and extract the `gitlab-license` gem. +- Copy and modify the required files. +- Clone the GitLab source code from GitLab.com. +- Generate a public/private key pair. +- Generate a GitLab license. + +#### 3. Replace the public key in GitLab +The script generates a public key located in `build/public.key`. You need to replace GitLab’s existing public key with this newly generated one to ensure the license is accepted. + +- **If GitLab is installed on your server**: + ```bash + sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` + +- **If GitLab is installed via Docker**: + Modify your `docker-compose.yml` file to mount the new public key inside the container: + + ```yaml + volumes: + - "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub" + ``` + + Then restart the container: + ```bash + docker-compose down + docker-compose up -d + ``` + +#### 4. Install the license in GitLab +Once the public key is replaced, log in to GitLab’s admin interface to install the generated license. + +1. Log in to GitLab as an administrator. +2. Navigate to the **Admin Area** from the upper-right corner. +3. Go to **Settings > General** and upload the generated license file (`build/result.gitlab-license`). +4. Check the **Terms of Service** checkbox and click **Add License**. + +If necessary, you can directly access the license upload page via: +``` +/admin/license/new +``` -See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/license_file.html). Follow are part of the document. +#### 5. Disable Service Ping (optional) +If you want to disable GitLab’s usage data collection (Service Ping), modify GitLab’s configuration file: -- Sign in to GitLab as an administrator. -- On the left sidebar, expand the top-most chevron. -- Select Admin Area. -- Select Settings > General. -- or entering the key. -- Select the Terms of Service checkbox. -- Select Add license. +- Open the configuration file: + ```bash + sudo nano /etc/gitlab/gitlab.rb + ``` -> In GitLab 14.7.x to 14.9.x, you can add the license file with the UI. In GitLab 14.1.x to 14.7, if you have already activated your subscription with an activation code, you cannot access Add License from the Admin Area. You must access Add License directly from the URL, /admin/license/new. +- Add the following line: + ```bash + gitlab_rails['usage_ping_enabled'] = false + ``` -### Disable Service Ping +- Reconfigure and restart GitLab: + ```bash + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` -> Service Ping is a GitLab process that collects and sends a weekly payload to GitLab. The payload provides important high-level data that helps our product, support, and sales teams understand how GitLab is used. +### Troubleshooting -See [GitLab Document](https://docs.gitlab.com/ee/development/internal_analytics/service_ping) for details. +- **HTTP 502 Error**: + If you encounter this error, wait for GitLab to finish starting up (it may take some time). ## LICENSE -This project is licensed under the WTFPL License. +This project is licensed under the **WTFPL License**. -Copyrigth (c) 2023, Tim Cook, All Rights Not Reserved. +Copyright (c) 2023, Tim Cook, All Rights Not Reserved. From d7fca25b578dbaaa0ec45772b80f3ebf21102f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20V=2E=20=7C=20Ov=E1=B4=87=CA=80Styl=E1=B4=87FR?= <94577363+OverStyleFR@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:58:45 +0200 Subject: [PATCH 38/62] Add | 'README_FR.md' Readme for FR language --- README_FR.md | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 README_FR.md diff --git a/README_FR.md b/README_FR.md new file mode 100644 index 000000000..1a70ff3 --- /dev/null +++ b/README_FR.md @@ -0,0 +1,144 @@ +# Générateur de Licence GitLab + +Ce projet permet de générer une licence GitLab à des **fins de développement**. Si vous rencontrez des problèmes, merci de les résoudre par vous-même. + +Dernier test effectué sur GitLab v17.4.1-ee. + +## Principes + +### **src/generator.keys.rb** + +GitLab utilise une paire de clés publique/privée pour chiffrer sa licence. La clé publique est fournie avec la distribution GitLab, tandis que la clé privée est conservée de manière sécurisée. La licence est simplement un dictionnaire JSON. Comme GitLab a rendu son code open-source, il est facile de générer sa propre licence. + +### **src/generator.license.rb** + +Le dossier `lib` est extrait du code source de GitLab. Il est utilisé pour générer et valider la licence. Le script `src/generator.license.rb` le charge pour effectuer cette tâche. + +### **src/scan.features.rb** + +Les fonctionnalités sont extraites d'un objet contenant des constantes. Le plan le plus complet est **Ultimate**, mais des fonctionnalités comme le Geo Mirroring ne sont incluses dans aucun plan standard. Nous les ajoutons donc manuellement. + +## Utilisation + +### Prérequis + +Avant de commencer, assurez-vous que votre environnement est correctement configuré. + +#### 1. Installer Ruby et gem +Pour exécuter ce projet, vous devez installer **Ruby** et le gestionnaire de paquets **gem**. + +- **Sous Linux (Ubuntu/Debian)** : + ```bash + sudo apt update + sudo apt install ruby-full + ``` + +- **Sous macOS** (via Homebrew) : + ```bash + brew install ruby + ``` + +#### 2. Installer Bundler et les gems nécessaires +Une fois Ruby installé, vous devez installer **Bundler** pour gérer les dépendances Ruby. + +```bash +gem install bundler +``` + +#### 3. Installer le gem `gitlab-license` +Le projet nécessite le gem `gitlab-license`, qui sera automatiquement téléchargé et utilisé par le script. + +```bash +gem install gitlab-license +``` + +### Étapes pour générer la licence GitLab + +#### 1. Cloner le dépôt du projet +Clonez ce projet sur votre machine locale. + +```bash +git clone https://github.com/Lakr233/GitLab-License-Generator.git +cd GitLab-License-Generator +``` + +#### 2. Exécuter le script `make.sh` +Une fois que tous les prérequis sont en place, exécutez le script : + +```bash +./make.sh +``` + +Le script effectuera les actions suivantes : +- Téléchargement et extraction du gem `gitlab-license`. +- Copie et modification des fichiers nécessaires. +- Clonage du code source GitLab depuis GitLab.com. +- Génération d’une paire de clés publique/privée. +- Génération d’une licence GitLab. + +#### 3. Remplacer la clé publique dans GitLab +Le script génère une clé publique dans le fichier `build/public.key`. Vous devez remplacer la clé publique utilisée par GitLab avec celle générée pour que la licence soit acceptée. + +- **Si GitLab est installé sur votre serveur** : + ```bash + sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` + +- **Si GitLab est installé via Docker** : + Modifiez votre fichier `docker-compose.yml` pour monter la nouvelle clé publique dans le conteneur : + + ```yaml + volumes: + - "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub" + ``` + + Puis redémarrez le conteneur : + ```bash + docker-compose down + docker-compose up -d + ``` + +#### 4. Installer la licence dans GitLab +Une fois la clé publique remplacée, connectez-vous à l'interface d'administration de GitLab pour installer la licence générée. + +1. Connectez-vous à GitLab en tant qu’administrateur. +2. Accédez à **Admin Area** via le coin supérieur droit. +3. Allez dans **Settings > General** et téléchargez le fichier de licence généré (`build/result.gitlab-license`). +4. Cochez la case **Terms of Service** et cliquez sur **Add License**. + +Si nécessaire, accédez directement à la page de téléchargement de la licence via : +``` +/admin/license/new +``` + +#### 5. Désactiver Service Ping (optionnel) +Si vous souhaitez désactiver la collecte de données d'utilisation par GitLab (Service Ping), modifiez le fichier de configuration GitLab : + +- Ouvrez le fichier de configuration : + ```bash + sudo nano /etc/gitlab/gitlab.rb + ``` + +- Ajoutez la ligne suivante : + ```bash + gitlab_rails['usage_ping_enabled'] = false + ``` + +- Reconfigurez et redémarrez GitLab : + ```bash + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` + +### Résolution des problèmes + +- **Erreur HTTP 502** : + Si vous obtenez cette erreur, patientez simplement, car GitLab peut mettre du temps à démarrer. + +## LICENCE + +Ce projet est sous licence **WTFPL License**. + +Copyright (c) 2023, Tim Cook, All Rights Not Reserved. From 40ba6c555e6c98450b21f75f3c7eb30088e0fb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20V=2E=20=7C=20Ov=E1=B4=87=CA=80Styl=E1=B4=87FR?= <94577363+OverStyleFR@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:02:35 +0200 Subject: [PATCH 39/62] Update | 'README.md' Add language select --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 19c4a2e..44b9333 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ +
+ # GitLab License Generator -This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. +

+ English | + Français +

+ +
+ +## Description + +**GitLab License Generator** This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. Last tested on GitLab v17.4.1-ee. From 3652c1b25a1a291691f0e06be2d96df55136a9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20V=2E=20=7C=20Ov=E1=B4=87=CA=80Styl=E1=B4=87FR?= <94577363+OverStyleFR@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:04:27 +0200 Subject: [PATCH 40/62] Update | 'README_FR.md' Add language select --- README_FR.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README_FR.md b/README_FR.md index 1a70ff3..8269293 100644 --- a/README_FR.md +++ b/README_FR.md @@ -1,6 +1,17 @@ -# Générateur de Licence GitLab +
-Ce projet permet de générer une licence GitLab à des **fins de développement**. Si vous rencontrez des problèmes, merci de les résoudre par vous-même. +# GitLab License Generator + +

+ English | + Français +

+ +
+ +## Description + +**GitLab License Generator** Ce projet permet de générer une licence GitLab à des **fins de développement**. Si vous rencontrez des problèmes, merci de les résoudre par vous-même. Dernier test effectué sur GitLab v17.4.1-ee. From 6f67bc0716ecf857140392363be5645b3a133f99 Mon Sep 17 00:00:00 2001 From: RootShell-coder Date: Fri, 11 Oct 2024 23:51:02 +0300 Subject: [PATCH 41/62] tested ver 17.4.2-ee --- README.md | 7 +- README_FR.md => lang/README_FR.md | 3 +- lang/README_RU.md | 154 ++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+), 5 deletions(-) rename README_FR.md => lang/README_FR.md (98%) create mode 100644 lang/README_RU.md diff --git a/README.md b/README.md index 44b9333..a95f8aa 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ # GitLab License Generator

- English | - Français + English | + Français | + Russian

@@ -13,7 +14,7 @@ **GitLab License Generator** This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. -Last tested on GitLab v17.4.1-ee. +> Last tested on GitLab v17.4.2-ee. ## Principles diff --git a/README_FR.md b/lang/README_FR.md similarity index 98% rename from README_FR.md rename to lang/README_FR.md index 8269293..c96e30f 100644 --- a/README_FR.md +++ b/lang/README_FR.md @@ -3,8 +3,7 @@ # GitLab License Generator

- English | - Français + English

diff --git a/lang/README_RU.md b/lang/README_RU.md new file mode 100644 index 000000000..c893f66 --- /dev/null +++ b/lang/README_RU.md @@ -0,0 +1,154 @@ +
+ +# Генератор лицензий GitLab + +

+ English +

+ +
+ +## Описание + +**GitLab License Generator** Этот проект генерирует лицензию GitLab для **целей разработки**. Если у вас возникнут какие-либо проблемы, пожалуйста, устраните их самостоятельно. + +> [Последнее тестирование](../README.md). + +## Принципы + +### **src/generator.keys.rb** + +GitLab использует пару открытого/закрытого ключа для шифрования своей лицензии. Открытый ключ поставляется с дистрибутивом GitLab, а закрытый ключ хранится в безопасности. Сама лицензия представляет собой просто словарь JSON. Поскольку GitLab сделал свой код открытым, мы можем легко сгенерировать собственную лицензию. + +### **src/generator.license.rb** + +Папка `lib` извлекается из исходного кода GitLab. Она используется для сборки и проверки лицензии. Скрипт `src/generator.license.rb` загружает эту функциональность. + +### **src/scan.features.rb** + +Функции извлекаются из объекта, заполненного константами. Самый полный план лицензии — **Ultimate**, но такие функции, как Geo Mirroring, не включены ни в один стандартный план. Поэтому мы вручную добавляем эти функции. + +## Использование + +### Предпосылки + +Перед началом убедитесь, что ваша среда правильно настроена. + +#### 1. Установите Ruby и gem +Для запуска этого проекта вам понадобится **Ruby** и менеджер пакетов **gem**. + +- **В Linux (Ubuntu/Debian)**: + ```bash + sudo apt update + sudo apt install ruby-full + ``` + +- **На macOS** (через Homebrew): + ```bash + brew install ruby + ``` + +#### 2. Установите Bundler и необходимые gems +После установки Ruby вам необходимо установить **Bundler** для управления зависимостями Ruby. + +```bash +gem install bundler +``` + +#### 3. Установите gem `gitlab-license` +Для проекта требуется gem `gitlab-license`, который будет автоматически загружен и использован скриптом. + +```bash +gem install gitlab-license +``` + +### Шаги по созданию лицензии GitLab + +#### 1. Клонируйте репозиторий проекта +Скопируйте этот проект на свой локальный компьютер. + +```bash +git clone https://github.com/Lakr233/GitLab-License-Generator.git +cd GitLab-License-Generator +``` + +#### 2. Запустите скрипт `make.sh` +После выполнения всех предварительных условий запустите скрипт: + +```bash +./make.sh +``` + +Скрипт выполнит следующие действия: +- Загрузит и распакует gem-файл `gitlab-license`. +- Скопирует и изменит необходимые файлы. +- Клонирует исходный код GitLab с GitLab.com. +- Сгенерирует пару открытого и закрытого ключей. +- Создаст лицензию GitLab. + +#### 3. Замена открытого ключа в GitLab +Скрипт генерирует открытый ключ, расположенный в `build/public.key`. Вам необходимо заменить существующий открытый ключ GitLab на этот недавно сгенерированный, чтобы убедиться, что лицензия принята. + +- **Если на вашем сервере установлен GitLab**: + ```bash + sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` + +- **Если GitLab установлен через Docker**: + Измените файл `docker-compose.yml`, чтобы смонтировать новый открытый ключ внутрь контейнера: + + ```yaml + volumes: + - "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub" + ``` + + Затем перезапустите контейнер: + ```bash + docker-compose down + docker-compose up -d + ``` + +#### 4. Установите лицензию в GitLab +После замены открытого ключа войдите в интерфейс администратора GitLab, чтобы установить сгенерированную лицензию. + +1. Войдите в GitLab как администратор. +2. Перейдите в **Admin Area** из верхнего правого угла. +3. Перейдите в **Settings > General** и загрузите сгенерированный файл лицензии (`build/result.gitlab-license`). +4. Установите флажок **Terms of Service** и нажмите **Add License**. + +При необходимости вы можете напрямую перейти на страницу загрузки лицензии через: +``` +/admin/license/new +``` + +#### 5. Отключить Service Ping (необязательно) +Если вы хотите отключить сбор данных об использовании GitLab (Service Ping), измените файл конфигурации GitLab: + +- Откройте файл конфигурации: + ```bash + sudo nano /etc/gitlab/gitlab.rb + ``` + +- Добавьте следующую строку: + ```bash + gitlab_rails['usage_ping_enabled'] = false + ``` + +- Перенастройте и перезапустите GitLab: + ```bash + sudo gitlab-ctl reconfigure + sudo gitlab-ctl restart + ``` + +### Поиск неисправностей + +- **Ошибка HTTP 502**: + Если вы столкнулись с этой ошибкой, дождитесь завершения запуска GitLab (это может занять некоторое время). + +## ЛИЦЕНЗИЯ + +Данный проект лицензирован по **WTFPL License**. + +Авторские права (c) 2023, Тим Кук, Все права не защищены. From 7c9210364e5228d0f6f76ba1894b6690a481ee32 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:05:13 +0330 Subject: [PATCH 42/62] minor: updated the latest version to 17.5.1-ee --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a95f8aa..ab981df 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ **GitLab License Generator** This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. -> Last tested on GitLab v17.4.2-ee. +> Last tested on GitLab v17.5.1-ee. ## Principles From eb436ed42944996cc5b6b621978f1429aa37648e Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:05:53 +0330 Subject: [PATCH 43/62] minor: updated the latest version to 17.5.1-ee --- lang/README_FR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/README_FR.md b/lang/README_FR.md index c96e30f..a34fa0a 100644 --- a/lang/README_FR.md +++ b/lang/README_FR.md @@ -12,7 +12,7 @@ **GitLab License Generator** Ce projet permet de générer une licence GitLab à des **fins de développement**. Si vous rencontrez des problèmes, merci de les résoudre par vous-même. -Dernier test effectué sur GitLab v17.4.1-ee. +Dernier test effectué sur GitLab v17.5.1-ee. ## Principes From 4291bd13bcdd575c1a610cd113c5e50d7d81493e Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:21:46 +0330 Subject: [PATCH 44/62] feat: added more parameters to cli --- src/generator.license.rb | 51 +++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/generator.license.rb b/src/generator.license.rb index eccc57b..db22961 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -6,6 +6,12 @@ public_key_path = nil private_key_path = nil features_json_path = nil +license_name="Tim Cook" +license_company="Apple Computer, Inc." +license_email="tcook@apple.com" +license_plan='ultimate' +license_user_count=2147483647 +license_expire_year=2500 require 'optparse' OptionParser.new do |opts| @@ -31,6 +37,30 @@ license_json_path = File.expand_path(v) end + opts.on("--license-name ", "Specify license name (optional) [#{license_name}]") do |v| + license_name = v + end + + opts.on("--license-company ", "Specify license company (optional) [#{license_company}]") do |v| + license_company = v + end + + opts.on("--license-email ", "Specify license email address (optional) [#{license_email}]") do |v| + license_email = v + end + + opts.on("--license-plan ", "Specify license plan (optional) [#{license_plan}(default),premium,starter]") do |v| + license_plan = v + end + + opts.on("--license-user-count ", "Specify license user count (optional) [#{license_user_count}(default)]") do |v| + license_user_count = v.to_i + end + + opts.on("--license-expire-year ", "Specify license expire year (optional) [#{license_expire_year}(default)]") do |v| + license_expire_year = v.to_i + end + opts.on("-h", "--help", "Prints this help") do puts opts exit @@ -44,6 +74,11 @@ exit 1 end +if license_plan != 'ultimate' && license_plan != 'premium' && license_plan != 'starter' && + puts "[!] license plan is set to #{license_plan} which is not one of [ultimate, premium, starter]" + puts "[!] use -h for help" + exit 1 +end # ========== puts "[*] loading keys..." @@ -74,29 +109,29 @@ # don't use gitlab inc, search `gl_team_license` in lib for details license.licensee = { - "Name" => "Tim Cook", - "Company" => "Apple Computer, Inc.", - "Email" => "tcook@apple.com" + "Name" => license_name, + "Company" => license_company, + "Email" => license_email } # required of course license.starts_at = Date.new(1976, 4, 1) # required since gem gitlab-license v2.2.1 -license.expires_at = Date.new(2500, 4, 1) +license.expires_at = Date.new(license_expire_year, 4, 1) # prevent gitlab crash at # notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at -license.block_changes_at = Date.new(2500, 4, 1) +license.block_changes_at = Date.new(license_expire_year, 4, 1) # required license.restrictions = { - plan: 'ultimate', + plan: license_plan, # STARTER_PLAN = 'starter' # PREMIUM_PLAN = 'premium' # ULTIMATE_PLAN = 'ultimate' - active_user_count: 2147483647, + active_user_count: license_user_count, # required, just dont overflow } @@ -105,7 +140,7 @@ # so here by we inject all features into restrictions # see scan.rb for a list of features that we are going to inject for feature in FEATURE_LIST - license.restrictions[feature] = 2147483647 + license.restrictions[feature] = license_user_count end puts "[*] validating license..." From 284a103f69b391af533b950b0ee6f2eaa48b4054 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:35:22 +0330 Subject: [PATCH 45/62] fix: license_plan condition --- src/generator.license.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator.license.rb b/src/generator.license.rb index db22961..6002263 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -74,7 +74,7 @@ exit 1 end -if license_plan != 'ultimate' && license_plan != 'premium' && license_plan != 'starter' && +if license_plan != 'ultimate' && license_plan != 'premium' && license_plan != 'starter' puts "[!] license plan is set to #{license_plan} which is not one of [ultimate, premium, starter]" puts "[!] use -h for help" exit 1 From 7117fd48e0bf836606d6517de5bd9573725d2bf9 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:37:53 +0330 Subject: [PATCH 46/62] Update generator.license.rb --- src/generator.license.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generator.license.rb b/src/generator.license.rb index 6002263..e1012fb 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -37,27 +37,27 @@ license_json_path = File.expand_path(v) end - opts.on("--license-name ", "Specify license name (optional) [#{license_name}]") do |v| + opts.on("--license-name NAME", "Specify license name (optional) [#{license_name}]") do |v| license_name = v end - opts.on("--license-company ", "Specify license company (optional) [#{license_company}]") do |v| + opts.on("--license-company COMPANY", "Specify license company (optional) [#{license_company}]") do |v| license_company = v end - opts.on("--license-email ", "Specify license email address (optional) [#{license_email}]") do |v| + opts.on("--license-email EMAIL-ADDRESS", "Specify license email address (optional) [#{license_email}]") do |v| license_email = v end - opts.on("--license-plan ", "Specify license plan (optional) [#{license_plan}(default),premium,starter]") do |v| + opts.on("--license-plan PLAN", "Specify license plan (optional) [#{license_plan}(default),premium,starter]") do |v| license_plan = v end - opts.on("--license-user-count ", "Specify license user count (optional) [#{license_user_count}(default)]") do |v| + opts.on("--license-user-count COUNT", "Specify license user count (optional) [#{license_user_count}(default)]") do |v| license_user_count = v.to_i end - opts.on("--license-expire-year ", "Specify license expire year (optional) [#{license_expire_year}(default)]") do |v| + opts.on("--license-expire-year YEAR", "Specify license expire year (optional) [#{license_expire_year}(default)]") do |v| license_expire_year = v.to_i end From 66e00738a2b5e3e6cad337d4fd1a7338637a23d0 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 20:40:04 +0330 Subject: [PATCH 47/62] minor: optimized arg help messages --- src/generator.license.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generator.license.rb b/src/generator.license.rb index e1012fb..1ea589a 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -49,15 +49,15 @@ license_email = v end - opts.on("--license-plan PLAN", "Specify license plan (optional) [#{license_plan}(default),premium,starter]") do |v| + opts.on("--license-plan PLAN", "Specify license plan (optional) [#{license_plan} (default), premium, starter]") do |v| license_plan = v end - opts.on("--license-user-count COUNT", "Specify license user count (optional) [#{license_user_count}(default)]") do |v| + opts.on("--license-user-count COUNT", "Specify license user count (optional) [#{license_user_count} (default)]") do |v| license_user_count = v.to_i end - opts.on("--license-expire-year YEAR", "Specify license expire year (optional) [#{license_expire_year}(default)]") do |v| + opts.on("--license-expire-year YEAR", "Specify license expire year (optional) [#{license_expire_year} (default)]") do |v| license_expire_year = v.to_i end From 9a70dabcfb0b68ad43d26deb35c3d341badd7011 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Tue, 29 Oct 2024 21:08:26 +0330 Subject: [PATCH 48/62] fix: added year and user count validations --- src/generator.license.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/generator.license.rb b/src/generator.license.rb index 1ea589a..304b3cb 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -48,19 +48,19 @@ opts.on("--license-email EMAIL-ADDRESS", "Specify license email address (optional) [#{license_email}]") do |v| license_email = v end - + opts.on("--license-plan PLAN", "Specify license plan (optional) [#{license_plan} (default), premium, starter]") do |v| license_plan = v end - + opts.on("--license-user-count COUNT", "Specify license user count (optional) [#{license_user_count} (default)]") do |v| license_user_count = v.to_i end - + opts.on("--license-expire-year YEAR", "Specify license expire year (optional) [#{license_expire_year} (default)]") do |v| license_expire_year = v.to_i end - + opts.on("-h", "--help", "Prints this help") do puts opts exit @@ -79,6 +79,19 @@ puts "[!] use -h for help" exit 1 end + +if Time.now.year > license_expire_year + puts "[!] license expiry year is set to #{license_expire_year} which is less than current year, this value must be greater than current year" + puts "[!] use -h for help" + exit 1 +end + +if license_user_count < 1 + puts "[!] license user count is set to #{license_user_count} which is less minumum user count possible" + puts "[!] use -h for help" + exit 1 +end + # ========== puts "[*] loading keys..." @@ -94,7 +107,7 @@ puts "[*] loading features from #{features_json_path}" require 'json' FEATURE_LIST = JSON.parse(File.read(features_json_path)) -else +else FEATURE_LIST = [] end puts "[*] total features to inject: #{FEATURE_LIST.size}" @@ -116,7 +129,7 @@ # required of course license.starts_at = Date.new(1976, 4, 1) - +puts Date.new() # required since gem gitlab-license v2.2.1 license.expires_at = Date.new(license_expire_year, 4, 1) From ca692192be1d8cae56ee280bd750770864c498ec Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Thu, 31 Oct 2024 08:56:23 +0000 Subject: [PATCH 49/62] fix: disable the need to download full gitlab source code during make.sh execution --- make.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/make.sh b/make.sh index 5dd23d6..a7ca851 100755 --- a/make.sh +++ b/make.sh @@ -71,20 +71,13 @@ popd > /dev/null echo "[*] updated gem" echo "[*] fetching gitlab source code..." -GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src/ -if [ -d "$GITLAB_SOURCE_CODE_DIR" ]; then - echo "[*] gitlab source code already exists, skipping cloning..." -else - echo "[*] cloning gitlab source code..." - git clone https://gitlab.com/gitlab-org/gitlab.git $GITLAB_SOURCE_CODE_DIR -fi +GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src + +mkdir -p "$GITLAB_SOURCE_CODE_DIR" +chmod 0755 -R "$GITLAB_SOURCE_CODE_DIR" +echo "[*] downloading features file..." +curl -L https://gitlab.com/gitlab-org/gitlab/-/raw/master/ee/app/models/gitlab_subscriptions/features.rb?inline=false -o "$GITLAB_SOURCE_CODE_DIR/features.rb" -echo "[*] updating gitlab source code..." -pushd $GITLAB_SOURCE_CODE_DIR > /dev/null -git clean -fdx -f > /dev/null -git reset --hard > /dev/null -git pull > /dev/null -popd > /dev/null BUILD_DIR=$(pwd)/build mkdir -p $BUILD_DIR @@ -94,7 +87,7 @@ FEATURE_LIST_FILE=$BUILD_DIR/features.json rm -f $FEATURE_LIST_FILE || true ./src/scan.features.rb \ -o $FEATURE_LIST_FILE \ - -s $GITLAB_SOURCE_CODE_DIR + -f "$GITLAB_SOURCE_CODE_DIR/features.rb" echo "[*] generating key pair..." PUBLIC_KEY_FILE=$BUILD_DIR/public.key From 619994531240fd7ef783dafcafe66bf48d7938e2 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Thu, 31 Oct 2024 09:04:02 +0000 Subject: [PATCH 50/62] feat: added envvars for optional fields in make.sh --- make.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/make.sh b/make.sh index a7ca851..de0991f 100755 --- a/make.sh +++ b/make.sh @@ -2,7 +2,12 @@ echo "[i] GitLab License Generator" echo "[i] Copyright (c) 2023 Tim Cook, All Rights Not Reserved" - +LICENSE_NAME="${LICENSE_NAME:-"Tim Cook"}" +LICENSE_COMPANY="${LICENSE_COMPANY:-"Apple Computer, Inc."}" +LICENSE_EMAIL="${LICENSE_EMAIL:-"tcook@apple.com"}" +LICENSE_PLAN="${LICENSE_PLAN:-'ultimate'}" +LICENSE_USER_COUNT="${LICENSE_USER_COUNT:-'2147483647'}" +LICENSE_EXPIRE_YEAR="${LICENSE_EXPIRE_YEAR:-'2500'}" set -e cd "$(dirname "$0")" @@ -109,6 +114,12 @@ LICENSE_JSON_FILE=$BUILD_DIR/license.json --public-key $PUBLIC_KEY_FILE \ --private-key $PRIVATE_KEY_FILE \ -o $LICENSE_FILE \ + --license-name "$LICENSE_NAME" \ + --license-company "$LICENSE_COMPANY" \ + --license-email "$LICENSE_EMAIL" \ + --license-plan "$LICENSE_PLAN" \ + --license-user-count "$LICENSE_USER_COUNT" \ + --license-expire-year "$LICENSE_EXPIRE_YEAR" \ --plain-license $LICENSE_JSON_FILE echo "[*] done $(basename $0)" From 0edb66ed69eaf08962b150569540444ee7d49954 Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Thu, 31 Oct 2024 09:06:23 +0000 Subject: [PATCH 51/62] fix: optional flag issue --- make.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/make.sh b/make.sh index de0991f..75bcc9a 100755 --- a/make.sh +++ b/make.sh @@ -5,9 +5,9 @@ echo "[i] Copyright (c) 2023 Tim Cook, All Rights Not Reserved" LICENSE_NAME="${LICENSE_NAME:-"Tim Cook"}" LICENSE_COMPANY="${LICENSE_COMPANY:-"Apple Computer, Inc."}" LICENSE_EMAIL="${LICENSE_EMAIL:-"tcook@apple.com"}" -LICENSE_PLAN="${LICENSE_PLAN:-'ultimate'}" -LICENSE_USER_COUNT="${LICENSE_USER_COUNT:-'2147483647'}" -LICENSE_EXPIRE_YEAR="${LICENSE_EXPIRE_YEAR:-'2500'}" +LICENSE_PLAN="${LICENSE_PLAN:-ultimate}" +LICENSE_USER_COUNT="${LICENSE_USER_COUNT:-2147483647}" +LICENSE_EXPIRE_YEAR="${LICENSE_EXPIRE_YEAR:-2500}" set -e cd "$(dirname "$0")" From 47ba50d35beb6126d34f848152b2a17e867d49ba Mon Sep 17 00:00:00 2001 From: Motalleb Fallahnezhad Date: Thu, 31 Oct 2024 09:56:02 +0000 Subject: [PATCH 52/62] fix: removed redundant `chmod` --- make.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/make.sh b/make.sh index 75bcc9a..469aea0 100755 --- a/make.sh +++ b/make.sh @@ -79,7 +79,6 @@ echo "[*] fetching gitlab source code..." GITLAB_SOURCE_CODE_DIR=$(pwd)/temp/src mkdir -p "$GITLAB_SOURCE_CODE_DIR" -chmod 0755 -R "$GITLAB_SOURCE_CODE_DIR" echo "[*] downloading features file..." curl -L https://gitlab.com/gitlab-org/gitlab/-/raw/master/ee/app/models/gitlab_subscriptions/features.rb?inline=false -o "$GITLAB_SOURCE_CODE_DIR/features.rb" From 67979fa1ace9e6de8a8a8bbb82893ef31d0192b3 Mon Sep 17 00:00:00 2001 From: FMotalleb Date: Thu, 31 Oct 2024 14:01:46 +0330 Subject: [PATCH 53/62] fix,minor: safely handle env vars --- make.sh | 64 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/make.sh b/make.sh index 469aea0..7953bd3 100755 --- a/make.sh +++ b/make.sh @@ -17,7 +17,7 @@ if [ ! -f ".root" ]; then fi WORKING_DIR=$(pwd) -mkdir temp 2> /dev/null || true +mkdir temp 2>/dev/null || true echo "[*] fetching ruby gem version..." RB_GEM_NAME="gitlab-license" @@ -30,14 +30,14 @@ while IFS= read -r line; do RB_GEM_VERSION=${RB_GEM_VERSION%")"} break fi -done <<< "$RB_GEM_LIST_OUTPUT" +done <<<"$RB_GEM_LIST_OUTPUT" echo "[*] gitlab-license version: $RB_GEM_VERSION" RB_GEM_DOWNLOAD_URL="https://rubygems.org/downloads/gitlab-license-$RB_GEM_VERSION.gem" RB_GEM_DOWNLOAD_PATH=$(pwd)/temp/gem/gitlab-license.gem -mkdir -p $(dirname $RB_GEM_DOWNLOAD_PATH) -curl -L $RB_GEM_DOWNLOAD_URL -o $RB_GEM_DOWNLOAD_PATH 1> /dev/null 2> /dev/null -pushd $(dirname $RB_GEM_DOWNLOAD_PATH) > /dev/null +mkdir -p "$(dirname "$RB_GEM_DOWNLOAD_PATH")" +curl -L "$RB_GEM_DOWNLOAD_URL" -o "$RB_GEM_DOWNLOAD_PATH" 1>/dev/null 2>/dev/null +pushd "$(dirname "$RB_GEM_DOWNLOAD_PATH")" >/dev/null tar -xf gitlab-license.gem tar -xf data.tar.gz @@ -47,31 +47,34 @@ if [ ! -f "./lib/gitlab/license.rb" ]; then fi echo "[*] copying gem..." -rm -rf "$WORKING_DIR/lib" || true +rm -rf "${WORKING_DIR:?}/lib" || true mkdir -p "$WORKING_DIR/lib" -cp -r ./lib/gitlab/* $WORKING_DIR/lib -popd > /dev/null +cp -r ./lib/gitlab/* "$WORKING_DIR/lib" +popd >/dev/null -pushd lib > /dev/null +pushd lib >/dev/null echo "[*] patching lib requirements gem..." # Determine the operating system OS_TYPE="$(uname -s)" -case "$OS_TYPE" in - Linux*) - sed_i_cmd="sed -i";; - Darwin*) - sed_i_cmd="sed -i ''";; - *) - echo "Unsupported OS: $OS_TYPE"; - exit 1;; +case "$OS_TYPE" in +Linux*) + sed_i_cmd="sed -i" + ;; +Darwin*) + sed_i_cmd="sed -i ''" + ;; +*) + echo "Unsupported OS: $OS_TYPE" + exit 1 + ;; esac # replace `require 'gitlab/license/` with `require 'license/` to make it work -find . -type f -exec $sed_i_cmd 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; +find . -type f -exec "$sed_i_cmd" 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; -popd > /dev/null +popd >/dev/null echo "[*] updated gem" @@ -82,22 +85,21 @@ mkdir -p "$GITLAB_SOURCE_CODE_DIR" echo "[*] downloading features file..." curl -L https://gitlab.com/gitlab-org/gitlab/-/raw/master/ee/app/models/gitlab_subscriptions/features.rb?inline=false -o "$GITLAB_SOURCE_CODE_DIR/features.rb" - BUILD_DIR=$(pwd)/build -mkdir -p $BUILD_DIR +mkdir -p "$BUILD_DIR" echo "[*] scanning features..." FEATURE_LIST_FILE=$BUILD_DIR/features.json -rm -f $FEATURE_LIST_FILE || true +rm -f "${FEATURE_LIST_FILE:?}" || true ./src/scan.features.rb \ - -o $FEATURE_LIST_FILE \ + -o "$FEATURE_LIST_FILE" \ -f "$GITLAB_SOURCE_CODE_DIR/features.rb" echo "[*] generating key pair..." PUBLIC_KEY_FILE=$BUILD_DIR/public.key PRIVATE_KEY_FILE=$BUILD_DIR/private.key -cp -f ./keys/public.key $PUBLIC_KEY_FILE -cp -f ./keys/private.key $PRIVATE_KEY_FILE +cp -f ./keys/public.key "$PUBLIC_KEY_FILE" +cp -f ./keys/private.key "$PRIVATE_KEY_FILE" # execute following command to generate new keys # ./src/generator.keys.rb \ @@ -109,16 +111,16 @@ LICENSE_FILE=$BUILD_DIR/result.gitlab-license LICENSE_JSON_FILE=$BUILD_DIR/license.json ./src/generator.license.rb \ - -f $FEATURE_LIST_FILE \ - --public-key $PUBLIC_KEY_FILE \ - --private-key $PRIVATE_KEY_FILE \ - -o $LICENSE_FILE \ + -f "$FEATURE_LIST_FILE" \ + --public-key "$PUBLIC_KEY_FILE" \ + --private-key "$PRIVATE_KEY_FILE" \ + -o "$LICENSE_FILE" \ --license-name "$LICENSE_NAME" \ --license-company "$LICENSE_COMPANY" \ --license-email "$LICENSE_EMAIL" \ --license-plan "$LICENSE_PLAN" \ --license-user-count "$LICENSE_USER_COUNT" \ --license-expire-year "$LICENSE_EXPIRE_YEAR" \ - --plain-license $LICENSE_JSON_FILE + --plain-license "$LICENSE_JSON_FILE" -echo "[*] done $(basename $0)" +echo "[*] done $(basename "$0")" From fbb51de76116d2eed3c8cee5989fb8eaed017fc1 Mon Sep 17 00:00:00 2001 From: FMotalleb Date: Thu, 31 Oct 2024 14:02:00 +0330 Subject: [PATCH 54/62] feat: docker image --- .dockerignore | 6 ++++ .github/workflows/docker-image.yml | 47 ++++++++++++++++++++++++++++++ Dockerfile | 15 ++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..8785de2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +langs/ +README.md +LICENSE +.github/ +Dockerfile +.*ignore diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..915761c --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,47 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Container to Github at dev + +on: + push: + branches: + - 'main' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..9aa7585 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ruby:bookworm +WORKDIR /license-generator +COPY ./ ./ +RUN < Date: Thu, 31 Oct 2024 14:09:12 +0330 Subject: [PATCH 55/62] fix: failed `exec` in `find` cmd --- make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.sh b/make.sh index 7953bd3..6aa858e 100755 --- a/make.sh +++ b/make.sh @@ -72,7 +72,7 @@ Darwin*) esac # replace `require 'gitlab/license/` with `require 'license/` to make it work -find . -type f -exec "$sed_i_cmd" 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; +find . -type f -exec $sed_i_cmd 's/require '\''gitlab\/license\//require_relative '\''license\//g' {} \; popd >/dev/null From 8332c4588021c64653f61ba465037a2b587f7b73 Mon Sep 17 00:00:00 2001 From: FMotalleb Date: Thu, 31 Oct 2024 14:26:48 +0330 Subject: [PATCH 56/62] docs: added docker usage --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ab981df..90aa238 100644 --- a/README.md +++ b/README.md @@ -32,25 +32,46 @@ Features are extracted from an object filled with constants. The most comprehens ## Usage -### Prerequisites +### Using Docker image (Zero setup) + +Using this method license files are generated under `./license` directory +> Please note that in standard docker installations, owner of the files generated in license directory will be root + +```bash +docker run --rm -it \ + -v "./license:/license-generator/build" \ + -e LICENSE_NAME="Tim Cook" \ + -e LICENSE_COMPANY="Apple Computer, Inc." \ + -e LICENSE_EMAIL="tcook@apple.com" \ + -e LICENSE_PLAN="ultimate" \ + -e LICENSE_USER_COUNT="2147483647" \ + -e LICENSE_EXPIRE_YEAR="2500" \ + ghcr.io/lakr233/gitlab-license-generator:main +``` + +### Manual: Prerequisites Before starting, ensure your environment is properly configured. #### 1. Install Ruby and gem + To run this project, you need **Ruby** and the **gem** package manager. - **On Linux (Ubuntu/Debian)**: + ```bash sudo apt update sudo apt install ruby-full ``` - **On macOS** (via Homebrew): + ```bash brew install ruby ``` #### 2. Install Bundler and necessary gems + After installing Ruby, you need to install **Bundler** to manage Ruby dependencies. ```bash @@ -58,6 +79,7 @@ gem install bundler ``` #### 3. Install the `gitlab-license` gem + The project requires the `gitlab-license` gem, which will be automatically downloaded and used by the script. ```bash @@ -67,6 +89,7 @@ gem install gitlab-license ### Steps to Generate the GitLab License #### 1. Clone the project repository + Clone this project to your local machine. ```bash @@ -75,6 +98,7 @@ cd GitLab-License-Generator ``` #### 2. Run the `make.sh` script + Once all the prerequisites are met, run the script: ```bash @@ -82,6 +106,7 @@ Once all the prerequisites are met, run the script: ``` The script will perform the following actions: + - Download and extract the `gitlab-license` gem. - Copy and modify the required files. - Clone the GitLab source code from GitLab.com. @@ -89,9 +114,11 @@ The script will perform the following actions: - Generate a GitLab license. #### 3. Replace the public key in GitLab + The script generates a public key located in `build/public.key`. You need to replace GitLab’s existing public key with this newly generated one to ensure the license is accepted. - **If GitLab is installed on your server**: + ```bash sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub sudo gitlab-ctl reconfigure @@ -107,12 +134,14 @@ The script generates a public key located in `build/public.key`. You need to rep ``` Then restart the container: + ```bash docker-compose down docker-compose up -d ``` #### 4. Install the license in GitLab + Once the public key is replaced, log in to GitLab’s admin interface to install the generated license. 1. Log in to GitLab as an administrator. @@ -121,24 +150,29 @@ Once the public key is replaced, log in to GitLab’s admin interface to install 4. Check the **Terms of Service** checkbox and click **Add License**. If necessary, you can directly access the license upload page via: + ``` /admin/license/new ``` #### 5. Disable Service Ping (optional) + If you want to disable GitLab’s usage data collection (Service Ping), modify GitLab’s configuration file: - Open the configuration file: + ```bash sudo nano /etc/gitlab/gitlab.rb ``` - Add the following line: + ```bash gitlab_rails['usage_ping_enabled'] = false ``` - Reconfigure and restart GitLab: + ```bash sudo gitlab-ctl reconfigure sudo gitlab-ctl restart From ba60714ab7954f2faa5f63405ea40fbc24f65246 Mon Sep 17 00:00:00 2001 From: FMotalleb Date: Thu, 31 Oct 2024 14:33:14 +0330 Subject: [PATCH 57/62] feat: added build image method --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 90aa238..c9d9749 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Features are extracted from an object filled with constants. The most comprehens Using this method license files are generated under `./license` directory > Please note that in standard docker installations, owner of the files generated in license directory will be root +#### Method (1): Pull image + ```bash docker run --rm -it \ -v "./license:/license-generator/build" \ @@ -49,6 +51,22 @@ docker run --rm -it \ ghcr.io/lakr233/gitlab-license-generator:main ``` +#### Method (2): Build image + +```bash +git clone https://github.com/Lakr233/GitLab-License-Generator.git +docker build GitLab-License-Generator -t gitlab-license-generator:main +docker run --rm -it \ + -v "./license:/license-generator/build" \ + -e LICENSE_NAME="Tim Cook" \ + -e LICENSE_COMPANY="Apple Computer, Inc." \ + -e LICENSE_EMAIL="tcook@apple.com" \ + -e LICENSE_PLAN="ultimate" \ + -e LICENSE_USER_COUNT="2147483647" \ + -e LICENSE_EXPIRE_YEAR="2500" \ + gitlab-license-generator:main +``` + ### Manual: Prerequisites Before starting, ensure your environment is properly configured. From 9191b28b8fabc6cb560c0ec0244e9e6e189589f1 Mon Sep 17 00:00:00 2001 From: cody Date: Mon, 4 Nov 2024 11:55:25 +0100 Subject: [PATCH 58/62] add a script that can modify existing licenses --- src/modify.license.rb | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 src/modify.license.rb diff --git a/src/modify.license.rb b/src/modify.license.rb new file mode 100755 index 000000000..f62a5c1 --- /dev/null +++ b/src/modify.license.rb @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +require 'base64' +require 'json' +require 'openssl' +require 'tempfile' +require 'optparse' +require_relative '../lib/license/encryptor' + +public_key_path = nil +in_file = nil + +OptionParser.new do |opts| + opts.banner = "Usage: xxx.rb [options]" + + opts.on("-k", "--public-key PATH", "Specify public key file (required)") do |v| + public_key_path = File.expand_path(v) + end + + opts.on("-i", "--in PATH", "input license path") do |v| + in_file = File.expand_path(v) + end + + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end + .parse! + +if in_file.nil? || public_key_path.nil? + puts "[!] missing required options" + puts "[!] use -h for help" + exit 1 +end + +content = File.read(in_file) +attributes = JSON.parse(Base64.decode64(content)) + +PUBLIC_KEY = OpenSSL::PKey::RSA.new File.read(public_key_path) +decryptor = Gitlab::License::Encryptor.new(PUBLIC_KEY) +plain_license = decryptor.decrypt(content) +edited_json = nil + +Tempfile.create(['json_edit', '.json']) do |file| + file.write(JSON.pretty_generate(JSON.parse(plain_license))) + file.flush + + system("vim #{file.path}") + file.rewind + edited_json = file.read +end + +edited_json = JSON.generate(JSON.parse(edited_json)) + +cipher = OpenSSL::Cipher::AES128.new(:CBC) +cipher.encrypt +cipher.key = PUBLIC_KEY.public_decrypt(Base64.decode64(attributes['key'])) +cipher.iv = Base64.decode64(attributes['iv']) + +encrypted_data = cipher.update(edited_json) + cipher.final + +encryption_data = { + 'data' => Base64.encode64(encrypted_data), + 'key' => attributes['key'], + 'iv' => attributes['iv'] +} + +json_data = JSON.dump(encryption_data) +puts Base64.encode64(json_data) From 8cd929f1ca836da78580d375bd26f5506392d865 Mon Sep 17 00:00:00 2001 From: Alexey Sazonov Date: Mon, 18 Nov 2024 14:37:13 +0300 Subject: [PATCH 59/62] offline cloud license --- src/generator.license.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/generator.license.rb b/src/generator.license.rb index 304b3cb..e709130 100755 --- a/src/generator.license.rb +++ b/src/generator.license.rb @@ -148,6 +148,9 @@ # required, just dont overflow } +license.cloud_licensing_enabled = true +license.offline_cloud_licensing_enabled = true + # restricted_attr will access restrictions # add_ons will access restricted_attr(:add_ons, {}) # so here by we inject all features into restrictions From 63608658aa789b616a2cfb5f8a38dcbee92c28db Mon Sep 17 00:00:00 2001 From: "Fifo F." <8145202+FifoF@users.noreply.github.com> Date: Sat, 23 Nov 2024 07:43:46 +0100 Subject: [PATCH 60/62] Update README.md tested on v17.6.0-ee --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9d9749..e2fd980 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ **GitLab License Generator** This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own. -> Last tested on GitLab v17.5.1-ee. +> Last tested on GitLab v17.6.0-ee. ## Principles @@ -163,7 +163,7 @@ The script generates a public key located in `build/public.key`. You need to rep Once the public key is replaced, log in to GitLab’s admin interface to install the generated license. 1. Log in to GitLab as an administrator. -2. Navigate to the **Admin Area** from the upper-right corner. +2. Navigate to the **Admin Area** from the bottom-left corner. 3. Go to **Settings > General** and upload the generated license file (`build/result.gitlab-license`). 4. Check the **Terms of Service** checkbox and click **Add License**. From ab54764d4c8150331b478a8e18bf45bd755b7ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Fri, 6 Dec 2024 09:54:22 +0800 Subject: [PATCH 61/62] Put Empty scan.features.rb --- src/scan.features.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/scan.features.rb diff --git a/src/scan.features.rb b/src/scan.features.rb new file mode 100644 index 000000000..f994516 --- /dev/null +++ b/src/scan.features.rb @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +require 'json' +require 'optparse' + +# +# this file was removed due to DMCA report +# following action was taken +# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository +# + +OptionParser.new do |opts| + opts.banner = "Usage: scan.features.rb [options]" + + opts.on("-s", "--src-dir PATH", "") do |v| + # empty block + end + + opts.on("-f", "--features-file PATH", "") do |v| + # empty block + end + + opts.on("-o", "--output PATH", "Output to json file (required)") do |v| + EXPORT_JSON_FILE = File.expand_path(v) + end + + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end +.parse! + +File.open(EXPORT_JSON_FILE, 'w') { |file| file.write("{}") } From c512add083e0176c22a486de79761bc36e198217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=8D=E7=A0=8D?= Date: Fri, 6 Dec 2024 09:56:55 +0800 Subject: [PATCH 62/62] Update README --- README.md | 4 +++- lang/README_FR.md | 4 +++- lang/README_RU.md | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e2fd980..ec47e73 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,9 @@ The `lib` folder is extracted from GitLab's source code. It is used to build and ### **src/scan.features.rb** -Features are extracted from an object filled with constants. The most comprehensive plan for a license is **Ultimate**, but features like Geo Mirroring are not included in any standard plan. Therefore, we manually add these features. +Removed with a script to generate empty json file due to DMCA takedown request. + +~~Features are extracted from an object filled with constants. The most comprehensive plan for a license is **Ultimate**, but features like Geo Mirroring are not included in any standard plan. Therefore, we manually add these features.~~ ## Usage diff --git a/lang/README_FR.md b/lang/README_FR.md index a34fa0a..a82f2ca 100644 --- a/lang/README_FR.md +++ b/lang/README_FR.md @@ -26,7 +26,9 @@ Le dossier `lib` est extrait du code source de GitLab. Il est utilisé pour gén ### **src/scan.features.rb** -Les fonctionnalités sont extraites d'un objet contenant des constantes. Le plan le plus complet est **Ultimate**, mais des fonctionnalités comme le Geo Mirroring ne sont incluses dans aucun plan standard. Nous les ajoutons donc manuellement. +**Ce fichier a été retiré suite à une demande de retrait DMCA.** + +~~Les fonctionnalités sont extraites d'un objet contenant des constantes. Le plan le plus complet est **Ultimate**, mais des fonctionnalités comme le Geo Mirroring ne sont incluses dans aucun plan standard. Nous les ajoutons donc manuellement.~~ ## Utilisation diff --git a/lang/README_RU.md b/lang/README_RU.md index c893f66..357f6db 100644 --- a/lang/README_RU.md +++ b/lang/README_RU.md @@ -26,7 +26,9 @@ GitLab использует пару открытого/закрытого кл ### **src/scan.features.rb** -Функции извлекаются из объекта, заполненного константами. Самый полный план лицензии — **Ultimate**, но такие функции, как Geo Mirroring, не включены ни в один стандартный план. Поэтому мы вручную добавляем эти функции. +**Этот файл был удален по запросу на удаление DMCA.** + +~~Функции извлекаются из объекта, заполненного константами. Самый полный план лицензии — **Ultimate**, но такие функции, как Geo Mirroring, не включены ни в один стандартный план. Поэтому мы вручную добавляем эти функции.~~ ## Использование