Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add models.OrganizationalEntity.bom_ref #801

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Yowgf
Copy link

@Yowgf Yowgf commented Mar 12, 2025

Changes for the issue #799

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @Yowgf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses issue #799 by adding the bom_ref property to the OrganizationalEntity class in cyclonedx/model/contact.py. This allows for referencing the organizational entity elsewhere in the BOM using a unique identifier. The pull request also includes corresponding tests in tests/test_model.py to ensure the new functionality works as expected, including initialization with and without a bom_ref, and serialization from JSON.

Highlights

  • Feature Addition: Adds the bom_ref property to the OrganizationalEntity class, enabling unique identification and referencing of organizational entities within a BOM.
  • Model Changes: Modifies the OrganizationalEntity class in cyclonedx/model/contact.py to include the bom_ref property with appropriate serialization and deserialization support.
  • Testing: Includes new tests in tests/test_model.py to validate the functionality of the bom_ref property, including initialization and JSON serialization.

Changelog

  • cyclonedx/model/contact.py
    • Added bom_ref parameter to the OrganizationalEntity's __init__ method (line 291).
    • Added _bom_ref attribute to store the bom_ref value (line 297).
    • Implemented the bom_ref property with JSON and XML serialization support (lines 303-316).
  • tests/test_model.py
    • Added import for OrganizationalEntity and PostalAddress (line 43).
    • Added TestModelOrganizationalEntity class with tests for initialization with and without bom_ref (lines 467-495).
    • Added a test case to initialize OrganizationalEntity from JSON, asserting the correct parsing of name, urls, and bom-ref (lines 497-511).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Trivia time!

What is the purpose of a Bill of Materials (BOM) in software development?

Click here for the answer
A Bill of Materials (BOM) in software development is a comprehensive inventory of all the components, libraries, and dependencies used in a software project. It helps in managing dependencies, ensuring security, and facilitating compliance.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the bom_ref attribute to the OrganizationalEntity class, enhancing its ability to be referenced within a BOM. The addition of tests is also a good practice. Here are some suggestions for improvement.

Summary of Findings

  • Missing from_json test coverage: The OrganizationalEntity class now has a bom_ref attribute, but the from_json method in the test suite does not cover this new attribute. Adding a test case to ensure that bom_ref is correctly deserialized from JSON would improve the robustness of the code.

Merge Readiness

The code changes introduce a new feature and include unit tests, which is good. However, there's a missing test case for the from_json method to ensure the bom_ref attribute is correctly deserialized. I recommend addressing this before merging. I am unable to approve this pull request, and other reviewers should review and approve this code before merging.

@Yowgf Yowgf marked this pull request as ready for review March 12, 2025 14:34
@Yowgf Yowgf requested a review from a team as a code owner March 12, 2025 14:34
@jkowalleck
Copy link
Member

@Yowgf ,
please add or modify a test case model in https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/tests/_data/models.py

Afterwards, run update test snapshots as described here: https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/tests/_data/snapshots/README.md

@Yowgf
Copy link
Author

Yowgf commented Mar 13, 2025

@jkowalleck done. Thanks for the heads up.

"""regression test for issue #799
see https://github.com/CycloneDX/cyclonedx-python-lib/issues/799
"""
return _make_bom(
Copy link
Member

Choose a reason for hiding this comment

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

please don't use the $.metadata.tools.services for this use case, as this particular structure is not available in all versions of CycloneDX, as this would render this test case almost unused.

please use $.components[].supplier instead.

@jkowalleck jkowalleck changed the title feat: add bom_ref to OrganizationalEntity feat: add models.OrganizationalEntity.bom_ref Mar 14, 2025
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