From dc40ea8289285a1ab0af19eeb5fdc4acea70befb Mon Sep 17 00:00:00 2001 From: ziad hany Date: Sat, 21 Feb 2026 02:35:05 +0200 Subject: [PATCH 1/3] Add API support for Patch/PackageCommitPatch Signed-off-by: ziad hany --- vulnerabilities/models.py | 16 +++++ .../templates/advisory_detail.html | 34 ++++++++++- .../templates/advisory_package_details.html | 61 +++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) diff --git a/vulnerabilities/models.py b/vulnerabilities/models.py index 4efc04766..bebcdcaaf 100644 --- a/vulnerabilities/models.py +++ b/vulnerabilities/models.py @@ -73,6 +73,8 @@ from vulnerabilities.severity_systems import EPSS from vulnerabilities.severity_systems import SCORING_SYSTEMS from vulnerabilities.utils import compute_patch_checksum +from vulnerabilities.utils import generate_commit_url +from vulnerabilities.utils import generate_patch_url from vulnerabilities.utils import normalize_list from vulnerabilities.utils import normalize_purl from vulnerabilities.utils import normalize_text @@ -2857,6 +2859,20 @@ class PackageCommitPatch(models.Model): patch_text = models.TextField(blank=True, null=True) patch_checksum = models.CharField(max_length=128, blank=True, null=True) + @property + def commit_url(self): + """ + Generates Commit URL using the VCS URL and Commit Hash. + """ + return generate_commit_url(self.vcs_url, self.commit_hash) + + @property + def patch_url(self): + """ + Generates Patch URL using the VCS URL and Commit Hash. + """ + return generate_patch_url(self.vcs_url, self.commit_hash) + def save(self, *args, **kwargs): if self.patch_text: self.patch_checksum = compute_patch_checksum(self.patch_text) diff --git a/vulnerabilities/templates/advisory_detail.html b/vulnerabilities/templates/advisory_detail.html index 90f1d6d8b..08ea8d572 100644 --- a/vulnerabilities/templates/advisory_detail.html +++ b/vulnerabilities/templates/advisory_detail.html @@ -80,7 +80,16 @@ {% endif %} - + +
  • + + + {% with pcp_length=package_commit_patches|length %} + Patches: ({{ advisory.patches.count|add:pcp_length }}) + {% endwith %} + + +