Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support unmbargoing for closed trackers (OSIDB-3729)
- Prioritize affects with subpath in PURL in v1 (OSIDB-4645)
- Move label creation from SECONDARY_ASSESSMENT to PRE_SECONDARY_ASSESSMENT (OSIDB-4448)
- Use centralize library for PURL parse

## [5.2.1] - 2025-11-13
### Fixed
Expand Down
15 changes: 3 additions & 12 deletions osidb/models/affect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import re
import uuid

import particular_purl_parse as purl_parser
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method and the new library's function had the same name ps_component_from_purl.

having ps_component_from_purl inside ps_component_from_purl seemed like it would cause confusion and renaming ps_component_from_purl seemed also wrong and particular_purl_parse.ps_component_from_purl seems too long so I rename the library to just do purl_parser.ps_component_from_purl

import pghistory
from django.contrib.postgres import fields
from django.contrib.postgres.indexes import GinIndex
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from packageurl import PackageURL
from psqlextra.fields import HStoreField

from apps.bbsync.constants import RHSCL_BTS_KEY
Expand Down Expand Up @@ -262,17 +262,8 @@ def ps_component_from_purl(self, should_raise=False):
try:
# try to parse the PS component from the PURL but do not raise any
# error on failure as that will be done as part of the validations
purl = PackageURL.from_string(self.purl)
if purl.type == "oci":
try:
prefix = purl.qualifiers["repository_url"].split("/")[1]
return f"{prefix}/{purl.name}"
except (KeyError, IndexError):
raise ValueError("Invalid repository_url in OCI PURL")
elif "rpmmod" in purl.qualifiers:
return f"{purl.qualifiers['rpmmod']}/{purl.name}"
else:
return purl.name
purl = purl_parser.ps_component_from_purl(self.purl)
return purl
except ValueError:
if should_raise:
raise
Expand Down
8 changes: 8 additions & 0 deletions osidb/models/tests/test_affect.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def test_resolved_dt_auto_update(
"pkg:oci/example-component?repository_url=registry.example.io/namespace/example-component",
"namespace/example-component",
),
(
"pkg:generic/redhat/rhsm-api-proxy/rhsm-auto-registration-listener",
"rhsm-auto-registration-listener",
),
(
"pkg:generic/redhat/rhsm-api-proxy/subscription-central-ui",
"subscription-central-ui",
),
],
)
def test_ps_component_from_purl(self, purl, ps_component):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies = [
"markdown>=3.3.6",
"nvdlib>=0.7.6",
"packageurl-python>=0.16.0",
"particular-purl-parse @ git+https://github.com/RedHatProductSecurity/particular-purl-parse.git#subdirectory=py",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library is not publish on Pypi so I use the library.

"psycogreen>=1.0.2",
"psycopg2>=2.9.2",
"pydantic-settings>=2.9.1",
Expand Down
16 changes: 13 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading