Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8c44551
Add is_unknown flag in license data model
akugarg Jun 11, 2021
ff6ce3d
Add is_unknown flag in license data model
akugarg Jun 11, 2021
540f502
Add is_unknown flag in data model for unknown licenses
akugarg Jun 11, 2021
4fa04ff
Add is_unknown flag in data model for unknown licenses
akugarg Jun 14, 2021
3dc3c3c
Add is_unknown flag for unknown-spdx
akugarg Jun 14, 2021
1d7872d
Add a test for validation of rules
akugarg Jun 14, 2021
4d61111
Update Test cases
akugarg Jun 15, 2021
a451a9c
Add is_unknown flag for license class
akugarg Jun 17, 2021
e62be42
Add is_unknown flag to data files of unknown licenses
akugarg Jun 17, 2021
5136b4d
Merge branch 'nexB:develop' into add_new_flag
akugarg Jun 20, 2021
477573a
Add is_unknown flag to data files of unknown licenses
akugarg Jun 20, 2021
40ce57b
Update test cases for new flag addition
akugarg Jun 20, 2021
c3fb603
Update test cases for new flag addition
akugarg Jun 21, 2021
0a0e54a
Add new validation rules
akugarg Jun 22, 2021
777e491
Update test cases for new flag addition
akugarg Jun 25, 2021
343b403
Fix failing test cases
akugarg Jun 28, 2021
1156c18
Merge branch 'nexB:develop' into add_new_flag
akugarg Jul 7, 2021
a1843cf
Add is_unknown flag in data model for unknown licenses
akugarg Jul 8, 2021
ad0c151
Merge branch 'develop' into add_new_flag
akugarg Jul 11, 2021
808bbbb
Update test cases upto expectations
akugarg Jul 14, 2021
b83ec88
Add is_unknown flag in data model for unknown licenses
akugarg Jul 21, 2021
3b51763
Merge remote-tracking branch 'upstream/develop' into add_new_flag
pombredanne Aug 6, 2021
f1b8085
Update changelog
pombredanne Aug 6, 2021
2690500
Add comment, docstring and format code
pombredanne Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ Package detection:
- Add support to track installed files for each Package type.


License detection:
~~~~~~~~~~~~~~~~~~~

- Unknown licenses have a new flag "is_unknown" to identify them
beyond just the naming convention of having "unknown" as part of their name.

- Rules that match at least one unknown license have a flag "has_unknown" set
in the returned match results.


Many thanks to every contributors that made this possible and in particular:

- Akanksha Garg @akugarg
- Ayan Sinha Mahapatra @AyanSinhaMahapatra
- Jono Yang @JonoYang
- Philippe Ombredanne @pombredanne



v21.8.4
---------

Expand Down
1 change: 1 addition & 0 deletions docs/source/cli-reference/output-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ following options.
"short_name": "MIT Old Style",
"category": "Permissive",
"is_exception": false,
"is_unknown": false,
"owner": "MIT",
"homepage_url": "http://fedoraproject.org/wiki/Licensing:MIT#Old_Style",
"text_url": "http://fedoraproject.org/wiki/Licensing:MIT#Old_Style",
Expand Down
1 change: 1 addition & 0 deletions docs/source/cli-reference/synopsis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ A sample JSON output for an individual file will look like::
"short_name": "MIT Old Style",
"category": "Permissive",
"is_exception": false,
"is_unknown": false,
"owner": "MIT",
"homepage_url": "http://fedoraproject.org/wiki/Licensing:MIT#Old_Style",
"text_url": "http://fedoraproject.org/wiki/Licensing:MIT#Old_Style",
Expand Down
2 changes: 2 additions & 0 deletions src/licensedcode/data/licenses/free-unknown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ short_name: Free unknown
name: Free unknown license detected but not recognized
category: Unstated License
owner: Unspecified
is_unknown: yes
spdx_license_key: LicenseRef-scancode-free-unknown

1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/license-file-reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ short_name: license-file-reference
name: license-file-reference
category: Unstated License
owner: Unspecified
is_unknown: yes
notes: this was known before as "see-license" and is now unknown-license-reference
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/see-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ name: See License mention
category: Unstated License
owner: Unspecified
is_deprecated: yes
is_unknown: yes
notes: replaced by unknown-license-reference
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ short_name: Unknown License reference
name: Unknown License file reference
category: Unstated License
owner: Unspecified
is_unknown: yes
notes: This is reference to a license file with no clear license. this was known before as "see-license"
and "license-file-reference"
spdx_license_key: LicenseRef-scancode-unknown-license-reference
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/unknown-spdx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ short_name: unknown SPDX
name: Unknown SPDX license detected but not recognized
category: Unstated License
owner: Unspecified
is_unknown: yes
spdx_license_key: LicenseRef-scancode-unknown-spdx
notes: This is something that clearly ressembles a license in an SPDX license
expression but is not conclusively an SPDX license ID.
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/unknown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ short_name: unknown
name: Unknown license detected but not recognized
category: Unstated License
owner: Unspecified
is_unknown: yes
spdx_license_key: LicenseRef-scancode-unknown
notes: This is something that clearly ressembles a license but is not conclusive.
2 changes: 1 addition & 1 deletion src/licensedcode/data/rules/unknown_german_1.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
license_expression: unknown
is_license_reference: yes
notes: in german
notes: in german
15 changes: 15 additions & 0 deletions src/licensedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class License(object):
# if this is a license exception, the license key this exception applies to
is_exception = __attrib(default=False)

# if the license falls in unknwon category then this flag should be set to true
is_unknown = __attrib(default=False)
# SPDX key for SPDX licenses
spdx_license_key = __attrib(default=None)
# list of other keys, such as deprecated ones
Expand Down Expand Up @@ -342,6 +344,10 @@ def validate(licenses, verbose=False, no_dupe_urls=False):
if not lic.owner:
error('No owner')

if lic.is_unknown:
if not "unknown" in lic.key:
error('is_unknown should not be true')

# URLS dedupe and consistency
if no_dupe_urls:
if lic.text_urls and not all(lic.text_urls):
Expand Down Expand Up @@ -863,6 +869,15 @@ def setup(self):
self.license_expression = expression.render()
self.license_expression_object = expression

@property
def has_unknown(self):
"""
Return True if any of this rule licenses is an unknown license.
"""
# TODO: consider using the license_expression_object and the is_unknown
# license flag instead
return self.license_expression and 'unknown' in self.license_expression

def validate(self, licensing=None):
"""
Validate this rule using the provided ``licensing`` Licensing and yield
Expand Down
2 changes: 2 additions & 0 deletions src/scancode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def _licenses_data_from_match(
result['short_name'] = lic.short_name
result['category'] = lic.category
result['is_exception'] = lic.is_exception
result['is_unknown'] = lic.is_unknown
result['owner'] = lic.owner
result['homepage_url'] = lic.homepage_url
result['text_url'] = lic.text_urls[0] if lic.text_urls else ''
Expand Down Expand Up @@ -270,6 +271,7 @@ def _licenses_data_from_match(
matched_rule['is_license_reference'] = match.rule.is_license_reference
matched_rule['is_license_tag'] = match.rule.is_license_tag
matched_rule['is_license_intro'] = match.rule.is_license_intro
matched_rule['has_unknown'] = match.rule.has_unknown
Comment thread
pombredanne marked this conversation as resolved.
matched_rule['matcher'] = match.matcher
matched_rule['rule_length'] = match.rule.length
matched_rule['matched_length'] = match.len()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"short_name": "Apache 1.1",
"category": "Permissive",
"is_exception": false,
"is_unknown": false,
"owner": "Apache Software Foundation",
"homepage_url": "http://www.apache.org/licenses/",
"text_url": "http://apache.org/licenses/LICENSE-1.1",
Expand All @@ -69,6 +70,7 @@
"is_license_reference": false,
"is_license_tag": false,
"is_license_intro": false,
"has_unknown": false,
"matcher": "3-seq",
"rule_length": 367,
"matched_length": 367,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"short_name": "PyGres License 2.2",
"category": "Permissive",
"is_exception": false,
"is_unknown": false,
"owner": "Unspecified",
"homepage_url": null,
"text_url": "http://shell.vex.net/viewvc.cgi/pygresql/trunk/module/pgmodule.c?view=markup&pathrev=431",
Expand All @@ -69,6 +70,7 @@
"is_license_reference": false,
"is_license_tag": false,
"is_license_intro": false,
"has_unknown": false,
"matcher": "2-aho",
"rule_length": 145,
"matched_length": 145,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"short_name": "PCRE License",
"category": "Permissive",
"is_exception": false,
"is_unknown": false,
"owner": "University of Cambridge",
"homepage_url": "http://www.pcre.org/licence.txt",
"text_url": "http://www.pcre.org/licence.txt",
Expand All @@ -69,6 +70,7 @@
"is_license_reference": false,
"is_license_tag": false,
"is_license_intro": false,
"has_unknown": false,
"matcher": "1-hash",
"rule_length": 303,
"matched_length": 303,
Expand Down
Loading