summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-31 14:04:36 +0000
committermo khan <mo.khan@gmail.com>2019-10-31 14:04:36 +0000
commit18357d73e9b804af4f0ad3e1e866c8c3a8d523b6 (patch)
tree41b987bbcf1a9d54f9394c037d60c5328ae628cf
parent13fd9dab34909eaf228534e0fd399b845c5e614a (diff)
parentf9dc40152a4453f9a02ece91c6291c0cc87bd68f (diff)
Merge branch 'add-name-mappings' into 'master'v1.8.1
Normalize `Apache License v2.0` See merge request gitlab-org/security-products/license-management!78
-rw-r--r--CHANGELOG.md4
-rw-r--r--README.md3
-rw-r--r--lib/license/management/repository.rb2
-rw-r--r--normalized-licenses.yml1
-rw-r--r--spec/license/management/repository_spec.rb11
5 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39fae56..4354ab0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# GitLab License management changelog
+## v1.8.1
+
+- Add mapping for `Apache License v2.0` to `Apache-2.0` (!78)
+
## v1.8.0
- Add ability to configure the `license_finder` execution via `LICENSE_FINDER_CLI_OPTS` (!77)
diff --git a/README.md b/README.md
index 583125f..8129648 100644
--- a/README.md
+++ b/README.md
@@ -128,3 +128,6 @@ Please check the [Release Process documentation](https://gitlab.com/gitlab-org/s
# Contributing
If you want to help, read the [contribution guidelines](CONTRIBUTING.md).
+
+If an unknown license is detected, please consider updating the mapping defined
+in [normalized-licenses.yml](https://gitlab.com/gitlab-org/security-products/license-management/blob/master/normalized-licenses.yml). A mapping can be for a detected name or url and must correspond to an SDPX identifier found in [spdx-licenses.json](https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spdx-licenses.json).
diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb
index ed2519f..9490af2 100644
--- a/lib/license/management/repository.rb
+++ b/lib/license/management/repository.rb
@@ -60,7 +60,7 @@ module License
end
def generate_item_for(license)
- log_info("detected unknown license named `#{license.send(:short_name)}`:`#{license.url}`")
+ log_info("Detected unknown license `#{license.send(:short_name)}`. Contribute to https://gitlab.com/gitlab-org/security-products/license-management#contributing.")
name = take_first_line_from(license.name)
{
'id' => name.downcase,
diff --git a/normalized-licenses.yml b/normalized-licenses.yml
index 0c8635d..4ae5b98 100644
--- a/normalized-licenses.yml
+++ b/normalized-licenses.yml
@@ -3,6 +3,7 @@ ids:
Apache1_1: Apache-1.1
Apache 2.0: Apache-2.0
Apache2: Apache-2.0
+ Apache License v2.0: Apache-2.0
ASL, version 2: Apache-2.0
BSD: BSD-4-Clause
BSD style: BSD-3-Clause
diff --git a/spec/license/management/repository_spec.rb b/spec/license/management/repository_spec.rb
index dbc0a22..6ebc09e 100644
--- a/spec/license/management/repository_spec.rb
+++ b/spec/license/management/repository_spec.rb
@@ -23,5 +23,16 @@ RSpec.describe License::Management::Repository do
end
end
end
+
+ [
+ ['Apache License v2.0', 'Apache-2.0'],
+ ].each do |short_name, spdx_id|
+ context "when mapping a `#{short_name}` license" do
+ let(:license) { LicenseFinder::License.new(short_name: short_name, matcher: LicenseFinder::License::NoneMatcher.new, url: nil) }
+ let(:dependency) { double(name: 'x', summary: '', description: '', homepage: '', licenses: [license]) }
+
+ it { expect(subject.item_for(license)['id']).to eql(spdx_id) }
+ end
+ end
end
end