Skip to content

Commit 2b5c56c

Browse files
Fix license exception compliance parsing bug
Reference: #1719 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 23d6724 commit 2b5c56c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

scanpipe/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ def compute_compliance_alert(self):
25852585
return ""
25862586

25872587
licensing = get_licensing()
2588-
parsed_symbols = licensing.parse(license_expression, simple=True).symbols
2588+
parsed_symbols = licensing.license_symbols(license_expression, simple=True)
25892589

25902590
alerts = [
25912591
self.get_alert_for_symbol(policy_index, symbol) for symbol in parsed_symbols

scanpipe/tests/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ def make_mock_response(url, content=b"\x00", status_code=200, headers=None):
368368
"label": "Prohibited License",
369369
"compliance_alert": "error",
370370
},
371+
"gpl-2.0-plus": {
372+
"license_key": "gpl-2.0-plus",
373+
"compliance_alert": "warning",
374+
},
375+
"font-exception-gpl": {
376+
"license_key": "font-exception-gpl",
377+
"compliance_alert": "warning",
378+
},
371379
"OFL-1.1": {
372380
"license_key": "OFL-1.1",
373381
"compliance_alert": "warning",

scanpipe/tests/test_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,14 @@ def test_scanpipe_codebase_resource_model_compliance_alert_update_fields(self):
16011601
# Reset the index value
16021602
scanpipe_app.license_policies_index = None
16031603

1604+
def test_scanpipe_codebase_resource_model_can_compute_compliance_alert_for_exceptions(self):
1605+
scanpipe_app.license_policies_index = license_policies_index
1606+
resource = CodebaseResource.objects.create(project=self.project1, path="file")
1607+
license_expression = "gpl-2.0-plus WITH font-exception-gpl"
1608+
resource.update(detected_license_expression=license_expression)
1609+
resource.compute_compliance_alert()
1610+
self.assertEqual("warning", resource.compliance_alert)
1611+
16041612
def test_scanpipe_scan_fields_model_mixin_methods(self):
16051613
expected = [
16061614
"detected_license_expression",

0 commit comments

Comments
 (0)