Skip to content

Commit

Permalink
Adjust licence checking script
Browse files Browse the repository at this point in the history
  • Loading branch information
kiron-mx committed Jan 9, 2024
1 parent 0b8e207 commit 79577e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions resources/allowed-licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ MIT
EPL-2.0
BSD-3-Clause
EPL-1.0
CDDL-1.1
Bouncy Castle Licence
Eclipse Distribution License - Version 1.0
# In the entry below we interpret it as CDDL-1.0
(CDDL-1.0 OR GPL-2.0-with-classpath-exception)
14 changes: 11 additions & 3 deletions scripts/license-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def generate_license_report(sbom):
try:
license_id = entry['license']['id']
except KeyError:
license_id = entry['license']['name']
try:
license_id = entry['license']['name']
except KeyError:
license_id = entry['expression']
entries.append((name, version, license_id))
return entries

Expand Down Expand Up @@ -100,8 +103,13 @@ def check_license_compliance(sbom, allowed):
try:
license_id = license['license']['id']
except KeyError:
license_id = license['license']['name']
if license_id not in allowed:
try:
license_id = license['license']['name']
except KeyError:
license_id = license['expression']
if license_id in allowed:
break
else:
errors.append((name, version, f'`{license_id}` not allowed'))

if not errors:
Expand Down

0 comments on commit 79577e7

Please sign in to comment.