diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/license/management/report/v1.rb | 8 | ||||
| -rw-r--r-- | lib/license/management/report/v2.rb | 2 | ||||
| -rw-r--r-- | lib/license/management/repository.rb | 20 | ||||
| -rw-r--r-- | lib/license/management/version.rb | 2 |
4 files changed, 10 insertions, 22 deletions
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 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 |
