Skip to content

Commit fef275d

Browse files
committed
Remove the internal database ID index from the API
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 9074e2b commit fef275d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

vulnerabilities/api_v2.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ class PackageCommitPatchSerializer(serializers.ModelSerializer):
344344
class Meta:
345345
model = PackageCommitPatch
346346
fields = [
347-
"id",
348347
"commit_hash",
349348
"vcs_url",
350349
"commit_url",
@@ -374,7 +373,7 @@ class PatchSerializer(serializers.ModelSerializer):
374373

375374
class Meta:
376375
model = Patch
377-
fields = ["id", "patch_url", "in_advisories"]
376+
fields = ["patch_url", "in_advisories"]
378377

379378
def get_in_advisories(self, obj):
380379
return [advisory.avid for advisory in obj.advisories.all()]
@@ -944,7 +943,7 @@ class PackageCommitPatchFilter(filters.FilterSet):
944943

945944
class Meta:
946945
model = PackageCommitPatch
947-
fields = ["id", "advisory_avid", "purl", "commit_hash", "vcs_url"]
946+
fields = ["advisory_avid", "purl", "commit_hash", "vcs_url"]
948947

949948
def filter_by_advisory(self, queryset, name, value):
950949
return queryset.filter(
@@ -980,7 +979,7 @@ class PatchFilter(filters.FilterSet):
980979

981980
class Meta:
982981
model = Patch
983-
fields = ["id", "advisory_avid"]
982+
fields = ["advisory_avid"]
984983

985984

986985
class PatchViewSet(viewsets.ReadOnlyModelViewSet):

vulnerabilities/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
from cwe2.database import Database
3535
from cwe2.database import InvalidCWEError
3636
from packageurl import PackageURL
37-
from packageurl.contrib import purl2url
3837
from packageurl.contrib.django.utils import without_empty_values
39-
from packageurl.contrib.purl2url import purl2url
4038
from packageurl.contrib.url2purl import url2purl
4139
from univers.version_range import RANGE_CLASS_BY_SCHEMES
4240
from univers.version_range import AlpineLinuxVersionRange
@@ -908,6 +906,8 @@ def generate_commit_url(vcs_url, commit_hash):
908906
"""
909907
Generate commit URL from VCS URL and commit hash.
910908
"""
909+
from packageurl.contrib import purl2url
910+
911911
if not vcs_url or not commit_hash:
912912
return
913913

@@ -930,6 +930,7 @@ def generate_patch_url(vcs_url, commit_hash):
930930
"""
931931
Generate patch URL from VCS URL and commit hash.
932932
"""
933+
from packageurl.contrib import purl2url
933934

934935
if not vcs_url or not commit_hash:
935936
return

0 commit comments

Comments
 (0)