Skip to content

Conversation

bxf12315
Copy link
Contributor

@bxf12315 bxf12315 commented Sep 29, 2025

Summary by Sourcery

Backport license support for Purl endpoints by returning detailed license and reference mappings populated from SBOM, updating models, OpenAPI schema, and tests.

New Features:

  • Return licenses and licenses_ref_mapping arrays in the Purl details API

Enhancements:

  • Implement extract_license_ref_mappings to parse SPDX expressions and build mapping entries
  • Refactor LicenseInfo and LicenseRefMapping into common module and expose get_licensing_infos in SbomService

Documentation:

  • Update OpenAPI spec to include new licenses and licenses_ref_mapping schema fields

Tests:

  • Add integration test for verifying license details and reference mappings in Purl API

Copy link
Contributor

sourcery-ai bot commented Sep 29, 2025

Reviewer's Guide

Backport of Packages List API enhancements: adds licenses array and reference mappings by querying SBOM data, introduces new types and helper, updates endpoint models and OpenAPI spec, and adds tests.

Entity relationship diagram for updated license data structures

erDiagram
    PurlDetails {
        UUID id
        ...
        LicenseInfo[] licenses
        LicenseRefMapping[] licenses_ref_mapping
    }
    LicenseInfo {
        string license_name
        LicenseCategory license_type
    }
    LicenseRefMapping {
        string license_id
        string license_name
    }
    PurlDetails ||--o{ LicenseInfo : contains
    PurlDetails ||--o{ LicenseRefMapping : contains
Loading

Class diagram for new and updated license-related types

classDiagram
    class PurlDetails {
        +VersionedPurlHead version
        +BasePurlHead base
        +Vec~PurlAdvisory~ advisories
        +Vec~LicenseInfo~ licenses
        +Vec~LicenseRefMapping~ licenses_ref_mapping
    }
    class LicenseInfo {
        +String license_name
        +LicenseCategory license_type
    }
    class LicenseRefMapping {
        +String license_id
        +String license_name
    }
    class PurlLicenseResult {
        +Uuid sbom_id
        +String license_name
        +i32 license_type
    }
    PurlDetails "1" -- "*" LicenseInfo : contains
    PurlDetails "1" -- "*" LicenseRefMapping : contains
    LicenseInfo <|-- LicenseBasicInfo : from
    LicenseInfo <|-- LicenseCategory : license_type
    PurlLicenseResult <|.. LicenseInfo : conversion
Loading

File-Level Changes

Change Details Files
Query and populate license data in PurlDetails
  • Define PurlLicenseResult and query sbom tables for license entries
  • Iterate results to build LicenseInfo list and extract LicenseRefMapping
  • Populate PurlDetails with licenses and licenses_ref_mapping
modules/fundamental/src/purl/model/details/purl.rs
Introduce LicenseInfo & LicenseRefMapping and extraction helper
  • Add extract_license_ref_mappings to parse SPDX expressions
  • Define LicenseInfo and LicenseRefMapping structs with conversion from basic info
modules/fundamental/src/common/service.rs
modules/fundamental/src/common/mod.rs
Expose and instrument get_licensing_infos in SbomService
  • Make get_licensing_infos public
  • Add tracing instrumentation to get_licensing_infos
modules/fundamental/src/sbom/service/sbom.rs
Update OpenAPI spec for licenses arrays
  • Add licenses_ref_mapping property and update licenses schema to LicenseInfo
  • Remove obsolete PurlLicenseSummary schema
openapi.yaml
Add integration test for Purl license details endpoint
  • Write test verifying licenses and reference mapping in API response
modules/fundamental/src/purl/endpoints/test.rs
Remove duplicate license types from sbom model
  • Delete redundant LicenseInfo and LicenseRefMapping definitions
modules/fundamental/src/sbom/model/mod.rs

Possibly linked issues

  • #2826: The PR ensures that all licenses associated with a package are returned by the API, resolving the issue where licenses disappeared when filtering.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants