Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lowercased purl fields on Package #210

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
6 changes: 3 additions & 3 deletions minecode/tests/testfiles/housekeeping/example_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Generated by Django 4.1.2 on 2023-11-03 01:58

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("packagedb", "0078_alter_package_release_date"),
]

operations = [
migrations.AlterField(
model_name="package",
name="name",
field=models.CharField(
blank=True, help_text="Name of the package.", max_length=100
),
),
migrations.AlterField(
model_name="package",
name="namespace",
field=models.CharField(
blank=True,
help_text="Package name prefix, such as Maven groupid, Docker image owner, GitHub user or organization, etc.",
max_length=255,
),
),
migrations.AlterField(
model_name="package",
name="qualifiers",
field=models.CharField(
blank=True,
help_text="Extra qualifying data for a package such as the name of an OS, architecture, distro, etc.",
max_length=1024,
),
),
migrations.AlterField(
model_name="package",
name="subpath",
field=models.CharField(
blank=True,
help_text="Extra subpath within a package, relative to the package root.",
max_length=200,
),
),
migrations.AlterField(
model_name="package",
name="type",
field=models.CharField(
blank=True,
help_text="A short code to identify the type of this package. For example: gem for a Rubygem, docker for a container, pypi for a Python Wheel or Egg, maven for a Maven Jar, deb for a Debian package, etc.",
max_length=16,
),
),
]
15 changes: 0 additions & 15 deletions packagedb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,21 +465,6 @@ class Package(
uuid = models.UUIDField(
verbose_name=_("UUID"), default=uuid.uuid4, unique=True, editable=False
)
type = LowerCaseField(
max_length=16,
)
namespace = LowerCaseField(
max_length=255,
)
name = LowerCaseField(
max_length=100,
)
qualifiers = LowerCaseField(
max_length=1024,
)
subpath = LowerCaseField(
max_length=200,
)
mining_level = models.PositiveIntegerField(
default=0,
help_text=_('A numeric indication of the highest depth and breadth '
Expand Down
8 changes: 4 additions & 4 deletions packagedb/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_package_api_list_endpoint_filter(self):
def test_package_api_list_endpoint_filter_by_purl_fields_ignores_case(self):
for key, value in self.package_data.items():
# Skip non-purl fields
if key not in ['type', 'namespace', 'name', 'version', 'qualifiers', 'subpath']:
if key not in ['type', 'namespace', 'name']:
continue

response = self.client.get('/api/packages/?{}={}'.format(key, value.lower()))
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_package_api_retrieve_endpoint(self):
continue

if key in ['type', 'namespace', 'name', 'version', 'qualifiers', 'subpath']:
self.assertEqual(value.lower(), getattr(self.package, key))
self.assertEqual(value, getattr(self.package, key))
continue

if key == 'history':
Expand Down Expand Up @@ -666,7 +666,7 @@ def test_reindex_package(self):
self.assertEqual('error', self.scannableuri.index_error)
self.assertEqual(self.scan_request_date, self.scannableuri.scan_request_date)
response = self.client.get(f'/api/packages/{self.package.uuid}/reindex_package/')
self.assertEqual('pkg:maven/sample/baz@90.12 has been queued for reindexing', response.data['status'])
self.assertEqual('pkg:maven/sample/Baz@90.12 has been queued for reindexing', response.data['status'])
self.scannableuri.refresh_from_db()
self.assertEqual(True, self.scannableuri.rescan_uri)
self.assertEqual(100, self.scannableuri.priority)
Expand All @@ -690,7 +690,7 @@ def test_reindex_packages_basic(self):
self.assertEqual('error', self.scannableuri2.index_error)
self.assertEqual(self.scan_request_date2, self.scannableuri2.scan_request_date)
existing_purls = [
'pkg:maven/sample/baz@90.12',
'pkg:maven/sample/Baz@90.12',
'pkg:npm/example/[email protected]',
]
nonexistent_purls = [
Expand Down
12 changes: 0 additions & 12 deletions packagedb/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ def setUp(self):
self.created_package = Package.objects.create(**self.created_package_data)
self.inserted_package = Package.objects.insert(**self.inserted_package_data)

def test_package_creation(self):
test_package = Package.objects.get(download_url=self.created_package_download_url)
self.assertIsNotNone(test_package)
for key, val in self.created_package_data.items():
self.assertEqual(val.lower(), getattr(test_package, key))

def test_package_insertion(self):
test_package = Package.objects.get(download_url=self.inserted_package_download_url)
self.assertIsNotNone(test_package)
for key, val in self.inserted_package_data.items():
self.assertEqual(val.lower(), getattr(test_package, key))

def test_package_download_url_is_unique(self):
self.assertIsNone(Package.objects.insert(download_url=self.created_package_download_url))
self.assertIsNone(Package.objects.insert(download_url=self.inserted_package_download_url))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"generic",
"namespace":"generic",
"name":"foo",
"name":"Foo",
"version":"12.34",
"qualifiers":"test_qual=qual",
"subpath":"test_subpath",
Expand Down Expand Up @@ -35,9 +35,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:generic/generic/foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"package_uid":"pkg:generic/generic/Foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"datasource_id":null,
"purl":"pkg:generic/generic/foo@12.34?test_qual=qual#test_subpath",
"purl":"pkg:generic/generic/Foo@12.34?test_qual=qual#test_subpath",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -46,7 +46,7 @@
{
"type":"npm",
"namespace":"example",
"name":"bar",
"name":"Bar",
"version":"56.78",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -79,9 +79,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:npm/example/bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:npm/example/Bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:npm/example/bar@56.78",
"purl":"pkg:npm/example/Bar@56.78",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -90,7 +90,7 @@
{
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.12",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -123,9 +123,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:jar/sample/baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:jar/sample/baz@90.12",
"purl":"pkg:jar/sample/Baz@90.12",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -134,7 +134,7 @@
{
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.123",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -167,9 +167,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:jar/sample/baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:jar/sample/baz@90.123",
"purl":"pkg:jar/sample/Baz@90.123",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
"filename":"Foo.zip",
"package_content":null,
"purl":"pkg:generic/generic/foo@12.34?test_qual=qual#test_subpath",
"purl":"pkg:generic/generic/Foo@12.34?test_qual=qual#test_subpath",
"type":"generic",
"namespace":"generic",
"name":"foo",
"name":"Foo",
"version":"12.34",
"qualifiers":"test_qual=qual",
"subpath":"test_subpath",
Expand Down Expand Up @@ -39,18 +39,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:generic/generic/foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"package_uid":"pkg:generic/generic/Foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Bar.zip",
"package_content":null,
"purl":"pkg:npm/example/bar@56.78",
"purl":"pkg:npm/example/Bar@56.78",
"type":"npm",
"namespace":"example",
"name":"bar",
"name":"Bar",
"version":"56.78",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -84,18 +84,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:npm/example/bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:npm/example/Bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Baz.zip",
"package_content":null,
"purl":"pkg:jar/sample/baz@90.12",
"purl":"pkg:jar/sample/Baz@90.12",
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.12",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -129,18 +129,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:jar/sample/baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Baz.zip",
"package_content":"binary",
"purl":"pkg:jar/sample/baz@90.123",
"purl":"pkg:jar/sample/Baz@90.123",
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.123",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -174,7 +174,7 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:jar/sample/baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
Expand Down
Loading