Skip to content

Conversation

@JimFuller-RedHat
Copy link
Contributor

@JimFuller-RedHat JimFuller-RedHat commented Nov 26, 2025

expirement

Summary by Sourcery

Adjust SBOM package–CPE joins to use a dedicated relation keyed by SBOM ID.

Bug Fixes:

  • Correct the SBOM package analysis query to join CPE references via SBOM ID instead of the previous CPE relation.

Enhancements:

  • Introduce a dedicated SeaORM relation from SBOM packages to CPE references keyed on SBOM ID for clearer modeling.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 26, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new SeaORM relation from sbom_package to sbom_package_cpe_ref keyed only by SbomId and switches an analysis loader join to use this new relation instead of the existing Cpe relation.

ER diagram for new sbom_package to sbom_package_cpe_ref relation (SbomId-only)

erDiagram
    sbom_package {
        bigint sbom_id
        bigint node_id
    }

    sbom_package_cpe_ref {
        bigint sbom_id
        bigint node_id
        bigint cpe_id
    }

    cpe {
        bigint id
    }

    sbom_package ||--o{ sbom_package_cpe_ref : CpeSbomId_SbomId
    sbom_package ||--o{ sbom_package_cpe_ref : Cpe_SbomId_NodeId
    sbom_package_cpe_ref }o--|| cpe : CpeRef_CpeId
Loading

Class diagram for updated sbom_package Relation enum and InnerService usage

classDiagram
    class sbom_package_Relation {
        <<enum>>
        Cpe
        CpeSbomId
    }

    class InnerService

    InnerService --> sbom_package_Relation : uses_CpeSbomId_for_join
Loading

File-Level Changes

Change Details Files
Define a new SeaORM belongs_to relation from sbom_package to sbom_package_cpe_ref using only SbomId as the key.
  • Extend the Relation enum with a new CpeSbomId variant.
  • Annotate the new enum variant with a SeaORM belongs_to attribute that maps Column::SbomId to sbom_package_cpe_ref::Column::SbomId.
entity/src/sbom_package.rs
Update the analysis loader query to join via the new CpeSbomId relation instead of the Cpe relation.
  • Change the SeaORM join in the InnerService load query to use sbom_package::Relation::CpeSbomId.def() in place of sbom_package::Relation::Cpe.def().
modules/analysis/src/service/load.rs

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The new CpeSbomId relation name is a bit opaque; consider renaming it to something more descriptive (e.g., CpeBySbomId or similar) to better convey how it differs from the existing Cpe relation.
  • Now that CpeSbomId is introduced and used in the analysis query, consider reviewing other usages of sbom_package::Relation::Cpe and either updating them or deprecating/removing that relation to avoid confusion between the two.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `CpeSbomId` relation name is a bit opaque; consider renaming it to something more descriptive (e.g., `CpeBySbomId` or similar) to better convey how it differs from the existing `Cpe` relation.
- Now that `CpeSbomId` is introduced and used in the analysis query, consider reviewing other usages of `sbom_package::Relation::Cpe` and either updating them or deprecating/removing that relation to avoid confusion between the two.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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