Skip to content

Commit 9e57e56

Browse files
committed
Merge hotfix branch for v31.2.6
Signed-off-by: Philippe Ombredanne <[email protected]>
2 parents 132884d + 4f498ce commit 9e57e56

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

CHANGELOG.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,27 @@ the latest release v32.x, and is also being backported
215215
now to v31.2.x
216216

217217

218+
v31.2.6 - 2023-04-25
219+
----------------------------------
220+
221+
This is a minor hotfix release.
222+
223+
This fix a crash when parsing a .deb Dbeian package filename
224+
reported in https://github.com/nexB/scancode-toolkit/issues/3259
225+
226+
227+
v31.2.5 - 2023-01-09
228+
----------------------------------
229+
230+
This is a minor fix backport release.
231+
232+
This adds license rule changes and was requested here:
233+
https://github.com/nexB/scancode-toolkit/issues/3310
234+
This was originally merged in #3218 and included in
235+
the latest release v32.x, and is also being backported
236+
now to v31.2.x
237+
238+
218239
v31.2.4 - 2023-01-09
219240
----------------------------------
220241

src/packagedcode/debian.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from debian_inspector.debcon import get_paragraph_data_from_file
1616
from debian_inspector.debcon import get_paragraphs_data_from_file
1717
from debian_inspector.package import DebArchive
18+
from debian_inspector.version import Version as DebVersion
1819
from packageurl import PackageURL
1920

2021
from packagedcode import models
@@ -516,7 +517,7 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
516517
return models.DatafileHandler.assign_package_to_resources(package, root, codebase, package_adder)
517518

518519

519-
def build_package_data_from_package_filename(filename, datasource_id, package_type,):
520+
def build_package_data_from_package_filename(filename, datasource_id, package_type):
520521
"""
521522
Return a PackageData built from the filename of a Debian package archive.
522523
"""
@@ -529,11 +530,15 @@ def build_package_data_from_package_filename(filename, datasource_id, package_ty
529530
else:
530531
qualifiers = {}
531532

533+
version = deb.version
534+
if isinstance(version, DebVersion):
535+
version = str(version)
536+
532537
return models.PackageData(
533538
datasource_id=datasource_id,
534539
type=package_type,
535540
name=deb.name,
536-
version=deb.version,
541+
version=version,
537542
qualifiers=qualifiers,
538543
)
539544

tests/packagedcode/test_debian.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from scancode.cli_test_utils import check_json_scan
1818
from scancode.cli_test_utils import run_scan_click
1919
from scancode_config import REGEN_TEST_FIXTURES
20+
from packagedcode.debian import build_package_data_from_package_filename
21+
from packagedcode.debian import DebianDebPackageHandler
2022

2123

2224
@skipIf(on_windows, 'These tests contain files that are not legit on Windows.')
@@ -146,3 +148,35 @@ def test_parse_debian_files_list_with_arch(self):
146148

147149
expected_loc = self.get_test_loc('debian/files-md5sums/mokutil-amd64.md5sums.expected.json', must_exist=False)
148150
self.check_packages_data(results, expected_loc, must_exist=False, regen=REGEN_TEST_FIXTURES)
151+
152+
def test_build_package_data_from_package_filename_deb_does_not_crash_on_version(self):
153+
filename = 'libapache2-mod-md_2.4.38-3+deb10u10_amd64.deb'
154+
result = build_package_data_from_package_filename(
155+
filename=filename,
156+
datasource_id='debian_deb',
157+
package_type='deb',
158+
)
159+
assert str(result.purl) == 'pkg:deb/[email protected]%2Bdeb10u10?architecture=amd64'
160+
161+
def test_build_package_data_from_package_filename_orig_sdoes_not_crash_on_version(self):
162+
filename = 'abseil_0~20200923.3.orig.tar.gz'
163+
result = build_package_data_from_package_filename(
164+
filename=filename,
165+
datasource_id='debian_deb',
166+
package_type='deb',
167+
)
168+
assert str(result.purl) == 'pkg:deb/abseil@0~20200923.3'
169+
170+
def test_build_package_data_from_package_filename_debian_tar_sdoes_not_crash_on_version(self):
171+
filename = 'abseil_20220623.1-1.debian.tar.xz'
172+
result = build_package_data_from_package_filename(
173+
filename=filename,
174+
datasource_id='debian_deb',
175+
package_type='deb',
176+
)
177+
assert str(result.purl) == 'pkg:deb/[email protected]'
178+
179+
def test_DebianDebPackageHandler_parse_does_not_crash_on_version(self):
180+
location = 'foo/bar/libapache2-mod-md_2.4.38-3+deb10u10_amd64.deb'
181+
result = list(DebianDebPackageHandler.parse(location))[0]
182+
assert str(result.purl) == 'pkg:deb/[email protected]%2Bdeb10u10?architecture=amd64'

0 commit comments

Comments
 (0)