Skip to content

✨ Core v1.7 Enablement#37

Merged
jkowalleck merged 3 commits into
CycloneDX:masterfrom
pboling:feat/spec-v1.7
Dec 18, 2025
Merged

✨ Core v1.7 Enablement#37
jkowalleck merged 3 commits into
CycloneDX:masterfrom
pboling:feat/spec-v1.7

Conversation

@pboling
Copy link
Copy Markdown
Contributor

@pboling pboling commented Oct 26, 2025

# 📍 NOTE What
1️⃣ #38 is first Modernize gem structure Merged!
2️⃣ Then see #37 next Upgrade to v1.7 spec <=== You are here
3️⃣ Then see #39 Add --validate feature
4️⃣ Then see #40 Add --include-metadata feature
  • Add spec version selection end-to-end with a new --spec-version flag (default 1.7).
  • Update JSON and XML outputs to honor the selected spec version.
  • Update fixtures, help text, tests, and docs.

NOTE:

  • Additional fields like bom-ref, publisher, metadata.tools, dependencies are optional and can be added incrementally.

Files:

  • lib/bom_helpers.rb:
    • Added SUPPORTED_SPEC_VERSIONS, cyclonedx_xml_namespace helper. build_bom now accepts spec_version and routes to:
      • build_json_bom(gems, spec_version) sets specVersion to the provided version.
      • build_bom_xml(gems, spec_version) sets xmlns to http://cyclonedx.org/schema/bom/.
  • lib/bom_builder.rb:
    • Added --spec-version with validation; default is 1.7.
    • Pass @spec_version into build_bom(@gems, @bom_output_format, @spec_version).

Copilot AI review requested due to automatic review settings October 26, 2025 00:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables CycloneDX specification version selection (default 1.7) across the BOM generation pipeline. Users can now specify their desired spec version via a new --spec-version flag, and the output will conform to that version's schema.

  • Added --spec-version flag with validation (supports 1.1–1.7, defaults to 1.7)
  • Updated JSON and XML BOM generation to use the selected spec version
  • Refactored path handling to use absolute paths and improved error message formatting

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/bom_helpers.rb Added SUPPORTED_SPEC_VERSIONS, cyclonedx_xml_namespace() helper, and propagated spec_version to JSON/XML builders
lib/bom_builder.rb Added --spec-version option parsing, validation, and normalized project path handling; improved backtrace formatting
spec/bom_helpers_spec.rb Added tests verifying spec version is correctly set in JSON and XML outputs
spec/spec_helper.rb Added require 'ostruct' for test utilities
features/step_definitions/json_bom_matching.rb Added .rstrip to normalize trailing whitespace in JSON comparisons
features/help.feature Updated help text to document new --spec-version option
features/json_format.feature Removed trailing blank line
features/fixtures/simple/bom.xml.expected Updated fixture to expect CycloneDX 1.7 namespace
features/fixtures/simple/bom.json.expected Updated fixture to expect specVersion: 1.7
features/fixtures/simple/Gemfile Pinned gem versions for deterministic test output
cyclonedx-ruby.gemspec Updated cucumber and aruba dev dependencies
README.md Documented new --spec-version flag with examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/bom_helpers.rb Outdated
Comment thread lib/bom_builder.rb Outdated
@pboling pboling marked this pull request as draft October 26, 2025 00:15
@pboling pboling changed the title ✨ Core v1.7 Enablement [WIP] ✨ Core v1.7 Enablement Oct 26, 2025
@pboling pboling mentioned this pull request Oct 26, 2025
@pboling pboling changed the title [WIP] ✨ Core v1.7 Enablement ✨ Core v1.7 Enablement Oct 26, 2025
@pboling pboling marked this pull request as ready for review October 26, 2025 05:15
@pboling pboling requested a review from a team as a code owner October 30, 2025 07:34
@pboling pboling force-pushed the feat/spec-v1.7 branch 5 times, most recently from d636cf3 to 7b47555 Compare November 3, 2025 23:47
@jkowalleck
Copy link
Copy Markdown
Member

#38 was merged.

@pboling would you mind rebasing/updating this PR?

@pboling
Copy link
Copy Markdown
Contributor Author

pboling commented Nov 5, 2025

Will do today!

- Add spec version selection end-to-end with a new --spec-version flag (default 1.7).
- Update JSON and XML outputs to honor the selected spec version.
- Update fixtures, help text, tests, and docs.

Files:
- lib/bom_helpers.rb:
  - Added SUPPORTED_SPEC_VERSIONS, cyclonedx_xml_namespace helper.
build_bom now accepts spec_version and routes to:
    - build_json_bom(gems, spec_version) sets specVersion to the provided version.
    - build_bom_xml(gems, spec_version) sets xmlns to http://cyclonedx.org/schema/bom/<version>.</version>
- lib/bom_builder.rb:
  - Added --spec-version with validation; default is 1.7.
  - Pass @spec_version into build_bom(@Gems, @bom_output_format, @spec_version).

Signed-off-by: Peter H. Boling <peter.boling@gmail.com>
Signed-off-by: Peter H. Boling <peter.boling@gmail.com>
Signed-off-by: Peter H. Boling <peter.boling@gmail.com>
@pboling
Copy link
Copy Markdown
Contributor Author

pboling commented Nov 6, 2025

@jkowalleck rebase complete

@pboling
Copy link
Copy Markdown
Contributor Author

pboling commented Nov 6, 2025

@jkowalleck It seems like I should be able to get to the Codacy report somehow but I'm not sure where to find the link to it from the CI results.

@andrew
Copy link
Copy Markdown

andrew commented Dec 18, 2025

LGTM

@jkowalleck jkowalleck requested a review from Copilot December 18, 2025 12:06
@jkowalleck jkowalleck merged commit 0f3e5f6 into CycloneDX:master Dec 18, 2025
9 of 10 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +120 to +127
# Spec version selection
requested_spec = @options[:spec_version] || '1.7'
if SUPPORTED_SPEC_VERSIONS.include?(requested_spec)
@spec_version = requested_spec
else
@logger.error("Unrecognized CycloneDX spec version '#{requested_spec}'. Please choose one of #{SUPPORTED_SPEC_VERSIONS}")
abort
end
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The new spec version validation logic lacks test coverage. While other features like format validation have integration tests in the features directory (e.g., xml_format.feature, json_format.feature), there are no tests verifying the spec version flag behavior, such as testing that an invalid version is rejected or that a valid version like 1.3 produces the correct output with the appropriate namespace/version.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +34
def cyclonedx_xml_namespace(spec_version)
"http://cyclonedx.org/schema/bom/#{spec_version}"
end
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The new cyclonedx_xml_namespace helper method lacks test coverage. Similar to how the purl method has unit tests in bom_helpers_spec.rb, this new method should have tests verifying it correctly constructs namespace URLs for different spec versions.

Copilot uses AI. Check for mistakes.
@jkowalleck
Copy link
Copy Markdown
Member

thank you so much for this upgrade, @pboling .
thank you so much for the review, @andrew .

@jkowalleck jkowalleck added the enhancement New feature or request label Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants