From e265eb6a6c99499254ee959e41ca80c99a8f67ea Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 22 Oct 2019 10:40:54 -0600 Subject: Remove feature flags and temporary mappings --- lib/license/management/report/v1.rb | 8 +------- lib/license/management/report/v2.rb | 2 +- lib/license/management/repository.rb | 20 +++++++------------- 3 files changed, 9 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/license/management/report/v1.rb b/lib/license/management/report/v1.rb index 02fd9bd..1cc8728 100644 --- a/lib/license/management/report/v1.rb +++ b/lib/license/management/report/v1.rb @@ -14,7 +14,7 @@ module License private # when a dependency has multiple licenses, this will join the licenses into a single name - # this defect was backported from the html2json version of this script. + # this defect was backported from the [html2json](https://gitlab.com/gitlab-org/security-products/license-management/blob/7f175952a5a047d785b5ea72c15a10642523c62a/html2json.js) version of this script. def license_summary dependencies .map { |dependency| join_license_names(dependency.licenses) } @@ -67,17 +67,11 @@ module License end def license_data(license) - return repository.item_for(license, spdx: false) if canonicalize? - { 'name' => license.name.split(/[\r\n]+/)[0], 'url' => license.url || '' } end - - def canonicalize? - ENV.fetch('LM_V1_CANONICALIZE', 'false') == 'true' - end end end end diff --git a/lib/license/management/report/v2.rb b/lib/license/management/report/v2.rb index 5df6af7..810d191 100644 --- a/lib/license/management/report/v2.rb +++ b/lib/license/management/report/v2.rb @@ -26,7 +26,7 @@ module License end def data_for(license) - repository.item_for(license, spdx: true) + repository.item_for(license) end def map_from(dependency) diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb index 164653c..0c428dd 100644 --- a/lib/license/management/repository.rb +++ b/lib/license/management/repository.rb @@ -14,24 +14,18 @@ module License @spdx_data = load_spdx_data_from(spdx_path) end - def item_for(license, spdx: true) - if spdx - item = spdx_data_for(license) - return item if item - end - - id = id_for(license) - item = id ? compatibility_data['licenses'][id] : nil - item ? { 'id' => id }.merge(item) : generate_item_for(license) + def item_for(license) + spdx_data_for(id_for(license)) || + spdx_data_for(license.send(:short_name)) || + generate_item_for(license) end private attr_reader :spdx_data, :compatibility_data - def spdx_data_for(license) - id = id_for(license) - data = id ? spdx_data[id] : spdx_data[license.send(:short_name)] + def spdx_data_for(id) + data = spdx_data[id] if data { 'id' => data['licenseId'], @@ -39,7 +33,7 @@ module License 'url' => data['seeAlso'][-1] } else - log_info("could not find license named `#{license.send(:short_name)}` in SPDX index") + log_info("Could not find license `#{id}` in SPDX") nil end end -- cgit v1.2.3 From 02b972cf32f8625bc5d7c1d4ca7d01d0de574937 Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 22 Oct 2019 13:01:37 -0600 Subject: Add changelog entry --- CHANGELOG.md | 6 ++++++ lib/license/management/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/CHANGELOG.md b/CHANGELOG.md index a7e3d6a..942ff56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # GitLab License management changelog +## v1.7.2 + +- Remove `LM_V1_CANONICALIZE` feature flag +- Remove `FEATURE_RUBY_REPORT` feature flag +- Remove `html2json.js` script + ## v1.7.1 - Add mappings for legacy license names diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb index 8e65182..b61aa01 100644 --- a/lib/license/management/version.rb +++ b/lib/license/management/version.rb @@ -2,6 +2,6 @@ module License module Management - VERSION = '1.7.1' + VERSION = '1.7.2' end end -- cgit v1.2.3