Skip to content

Commit

Permalink
Fix qualifier bug in debian purls
Browse files Browse the repository at this point in the history
See https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#deb
Here `arch is the qualifiers key for a package architecture`, and we
were using architecture, which was a bug. This commit is a fix for that.

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Feb 19, 2024
1 parent 3b29dcc commit 1b42eea
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 115 deletions.
4 changes: 2 additions & 2 deletions src/packagedcode/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def assemble(cls, package_data, resource, codebase, package_adder):

# We only need to adjust the md5sum/list path in the case of `same`
qualifiers = package_data.qualifiers or {}
architecture = qualifiers.get('architecture')
architecture = qualifiers.get('arch')

multi_arch = package_data.extra_data.get('multi_arch')

Expand Down Expand Up @@ -626,7 +626,7 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No
qualifiers = {}
architecture = debian_data.get('architecture')
if architecture:
qualifiers['architecture'] = architecture
qualifiers['arch'] = architecture

extra_data = {}
# Multi-Arch can be: "foreign", "same", "allowed", "all", "optional" or
Expand Down
28 changes: 14 additions & 14 deletions tests/packagedcode/data/debian/basic-rootfs-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "libncurses5",
"version": "6.1-1ubuntu1.18.04",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -180,7 +180,7 @@
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null,
"package_uid": "pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid": "pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758",
"datafile_paths": [
"basic-rootfs.tar.gz/var/lib/dpkg/status",
"basic-rootfs.tar.gz/usr/share/doc/libncurses5/copyright",
Expand All @@ -191,15 +191,15 @@
"debian_copyright_in_package",
"debian_installed_md5sums"
],
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libndp0",
"version": "1.4-2ubuntu0.16.04.1",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -319,7 +319,7 @@
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null,
"package_uid": "pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid": "pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758",
"datafile_paths": [
"basic-rootfs.tar.gz/var/lib/dpkg/status",
"basic-rootfs.tar.gz/usr/share/doc/libndp0/copyright",
Expand All @@ -330,7 +330,7 @@
"debian_copyright_in_package",
"debian_installed_md5sums"
],
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
}
],
"dependencies": [],
Expand Down Expand Up @@ -507,7 +507,7 @@
}
],
"for_packages": [
"pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand Down Expand Up @@ -619,7 +619,7 @@
}
],
"for_packages": [
"pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand Down Expand Up @@ -738,7 +738,7 @@
}
],
"for_packages": [
"pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand Down Expand Up @@ -820,7 +820,7 @@
}
],
"for_packages": [
"pkg:deb/ubuntu/[email protected]?architecture=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/ubuntu/[email protected]?arch=amd64&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand All @@ -834,7 +834,7 @@
"name": "libncurses5",
"version": "6.1-1ubuntu1.18.04",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -884,15 +884,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libndp0",
"version": "1.4-2ubuntu0.16.04.1",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -942,7 +942,7 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
}
],
"for_packages": [],
Expand Down
24 changes: 12 additions & 12 deletions tests/packagedcode/data/debian/basic/status.expected
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "libncurses5",
"version": "6.1-1ubuntu1.18.04",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -55,15 +55,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libcom-err2",
"version": "1.44.1-1ubuntu1.1",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -113,15 +113,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libapt-pkg5.0",
"version": "1.6.11",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -171,15 +171,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libaudit1",
"version": "1:2.8.2-1ubuntu1",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -229,15 +229,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/libaudit1@1:2.8.2-1ubuntu1?architecture=amd64"
"purl": "pkg:deb/ubuntu/libaudit1@1:2.8.2-1ubuntu1?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "perl-base",
"version": "5.26.1-6ubuntu0.3",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -285,15 +285,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
},
{
"type": "deb",
"namespace": "ubuntu",
"name": "libudev1",
"version": "237-3ubuntu10.22",
"qualifiers": {
"architecture": "amd64"
"arch": "amd64"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -343,6 +343,6 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_installed_status_db",
"purl": "pkg:deb/ubuntu/[email protected]?architecture=amd64"
"purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
}
]
32 changes: 16 additions & 16 deletions tests/packagedcode/data/debian/control.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "gzip",
"version": null,
"qualifiers": {
"architecture": "any"
"arch": "any"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -39,22 +39,22 @@
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null,
"package_uid": "pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid": "pkg:deb/debian/gzip?arch=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"datafile_paths": [
"control/debian/control"
],
"datasource_ids": [
"debian_control_in_source"
],
"purl": "pkg:deb/debian/gzip?architecture=any"
"purl": "pkg:deb/debian/gzip?arch=any"
},
{
"type": "deb",
"namespace": "debian",
"name": "gzip-win32",
"version": null,
"qualifiers": {
"architecture": "all"
"arch": "all"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -87,14 +87,14 @@
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null,
"package_uid": "pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid": "pkg:deb/debian/gzip-win32?arch=all&uuid=fixed-uid-done-for-testing-5642512d1758",
"datafile_paths": [
"control/debian/control"
],
"datasource_ids": [
"debian_control_in_source"
],
"purl": "pkg:deb/debian/gzip-win32?architecture=all"
"purl": "pkg:deb/debian/gzip-win32?arch=all"
}
],
"dependencies": [],
Expand All @@ -104,8 +104,8 @@
"type": "directory",
"package_data": [],
"for_packages": [
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/debian/gzip?arch=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?arch=all&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand All @@ -114,8 +114,8 @@
"type": "directory",
"package_data": [],
"for_packages": [
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/debian/gzip?arch=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?arch=all&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
},
Expand Down Expand Up @@ -183,7 +183,7 @@
"name": "gzip",
"version": null,
"qualifiers": {
"architecture": "any"
"arch": "any"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -219,15 +219,15 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_control_in_source",
"purl": "pkg:deb/debian/gzip?architecture=any"
"purl": "pkg:deb/debian/gzip?arch=any"
},
{
"type": "deb",
"namespace": "debian",
"name": "gzip-win32",
"version": null,
"qualifiers": {
"architecture": "all"
"arch": "all"
},
"subpath": null,
"primary_language": null,
Expand Down Expand Up @@ -263,12 +263,12 @@
"repository_download_url": null,
"api_data_url": null,
"datasource_id": "debian_control_in_source",
"purl": "pkg:deb/debian/gzip-win32?architecture=all"
"purl": "pkg:deb/debian/gzip-win32?arch=all"
}
],
"for_packages": [
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
"pkg:deb/debian/gzip?arch=any&uuid=fixed-uid-done-for-testing-5642512d1758",
"pkg:deb/debian/gzip-win32?arch=all&uuid=fixed-uid-done-for-testing-5642512d1758"
],
"scan_errors": []
}
Expand Down
Loading

0 comments on commit 1b42eea

Please sign in to comment.