Skip to content

Conversation

@pboling
Copy link

@pboling pboling commented Oct 26, 2025

# 📍 NOTE What
1️⃣ This one first Modernize gem structure <=== You are here
2️⃣ Then see #37 next Upgrade to v1.7 spec
3️⃣ Then see #39 Add --validate feature
4️⃣ Then see #40 Add --include-metadata feature

🎨 modernize for 2025

Added

  • CONTRIBUTING.md file to help people find their way to contributing
  • CHANGELOG.md file to document notable changes in keep-a-changelog format
  • Cyclonedx::BomHelpers module to house helper methods, replacing global methods
  • Cyclonedx::BomBuilder class, replacing Bombuilder (note the capitalization change)
  • Cyclonedx::BomComponent class, replacing BomComponent
  • Cyclonedx::Ruby::Version::VERSION constant to hold the version number (also available as Cyclonedx::VERSION)
  • Cyclonedx::Ruby::Deprecation module to help manage deprecations
  • dev dependency: stone_checksums
    • For SHA-256 and SHA-512 checksum generation for each release.
  • signed gem releases
  • CI matrix testing on Ruby 3.3, 3.4

Changed

  • Updated gemspec metadata for clarity and consistency
  • Modernized Rakefile, dotfiles, and test setup
  • LICENSE => LICENSE.txt to simplify parsing consistency on various platforms and tools
  • cucumber v8 => v10
  • aruba v2.1 => v2.2

Deprecated

  • BomComponent => Cyclonedx::BomComponent
  • Bombuilder => Cyclonedx::BomBuilder (note the capitalization change)
  • Object.purl => Cyclonedx::BomHelpers.purl
  • Object.random_urn_uuid => Cyclonedx::BomHelpers.random_urn_uuid
  • Object.build_bom => Cyclonedx::BomHelpers.build_bom
  • Object.build_json_bom => Cyclonedx::BomHelpers.build_json_bom
  • Object.build_bom_xml => Cyclonedx::BomHelpers.build_bom_xml
  • Object.get_gem => Cyclonedx::BomHelpers.get_gem

Fixed

  • Nokogiri::XML::Builder context relies on method_missing
    • Globally defined Object#purl conflicted with <purl>.
    • Moved to Cyclonedx::BomHelpers.purl to avoid conflict in v2.0.0 (along with all other global methods)
    • Fixed existing usage via the built-in Nokogiri workaround of adding an underscore purl_
    • The XML tag is unchanged as <purl>

Signed-off-by: Peter H. Boling [email protected]

Copilot AI review requested due to automatic review settings October 26, 2025 03:19
@pboling pboling changed the title 🔨 binstubs: console, setup, rake, rspec, cucumber 🎨 modernize for 2025 Oct 26, 2025
Copy link

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 modernizes the cyclonedx-ruby gem for 2025 by refactoring the codebase to use proper namespacing under the Cyclonedx module, introducing a deprecation system for backward compatibility, and updating dependencies. The changes prepare for a v2.0.0 release while maintaining compatibility with existing code through deprecated aliases.

Key changes:

  • Refactored global methods and classes into the Cyclonedx namespace with deprecation warnings for legacy usage
  • Fixed Nokogiri XML builder conflict with globally-scoped purl method
  • Updated development dependencies (cucumber v8→v10, aruba v2.1→v2.2)

Reviewed Changes

Copilot reviewed 25 out of 34 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/cyclonedx/ruby.rb New main entry point that requires all Cyclonedx module components
lib/cyclonedx/bom_helpers.rb Refactored helper methods into Cyclonedx::BomHelpers module
lib/cyclonedx/bom_component.rb Moved BomComponent class into Cyclonedx namespace
lib/cyclonedx/bom_builder.rb Moved Bombuilder class into Cyclonedx namespace as BomBuilder
lib/cyclonedx/ruby/version.rb New version constant structure
lib/cyclonedx/ruby/deprecation.rb New deprecation management module
lib/cyclonedx_deprecated.rb Compatibility layer providing deprecated aliases
lib/bom_*.rb Legacy entry points now redirect to new namespaced code
spec/spec_helper.rb Updated test configuration and loading logic
spec/cyclonedx/*.rb New namespaced test files
cyclonedx-ruby.gemspec Updated metadata and dependency versions
exe/cyclonedx-ruby Updated executable with backward compatibility logic
CHANGELOG.md New changelog documenting all changes

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

@jkowalleck
Copy link
Member

@pboling
Copy link
Author

pboling commented Oct 27, 2025

@jkowalleck there are 10 minor and 60 medium SCA violations. I'd like to focus on this PR not changing much runtime logic. Would you prefer to fix them in a separate PR, or just the medium ones here, or all of them here?

@jkowalleck
Copy link
Member

@jkowalleck there are 10 minor and 60 medium SCA violations. I'd like to focus on this PR not changing much runtime logic. Would you prefer to fix them in a separate PR, or just the medium ones here, or all of them here?

I dont know whether the SCA issue already existed, and were reported only because the code moved from one file to another.
Anyway, i believe in continuous improvements and small iterations. I would be okay with a follow-up ticket and PR to address these findings later, especially since we have PRs that build on the code in this PR.

@jkowalleck
Copy link
Member

jkowalleck commented Oct 28, 2025

there seams to be some CI/CT failing.
could you have a look? https://github.com/CycloneDX/cyclonedx-ruby-gem/actions/runs/18813396802?pr=38

@pboling
Copy link
Author

pboling commented Oct 28, 2025

Looking into the CI failures, and will fix the license link in README, and add CONTRIBUTING.md. I looked at other projects in this org, and it seems the are using contributor covenant v2.0. So following that pattern I'm adding contributor covenant v2.1, using the same contact email as the other projects have.
Rebasing the PRs that are on top of this one, is effort, but not horrible; the splits are pretty clean. :)

@mperham
Copy link

mperham commented Oct 29, 2025

I’d like to see this work integrated too. Thanks @pboling!

one request: remove unnecessary 3rd party dependencies. No real reason this lib needs nokogiri or rest-client.

@pboling pboling requested a review from a team as a code owner October 30, 2025 06:57
Signed-off-by: Peter H. Boling <[email protected]>
- .gitignore
- .rspec

Signed-off-by: Peter H. Boling <[email protected]>
Signed-off-by: Peter H. Boling <[email protected]>
### Added

- `CHANGELOG.md` file to document notable changes in keep-a-changelog format
- `Cyclonedx::BomHelpers` module to house helper methods, replacing global methods
- `Cyclonedx::BomBuilder` class, replacing `Bombuilder` (note the capitalization change)
- `Cyclonedx::BomComponent` class, replacing `BomComponent`
- `Cyclonedx::Ruby::Version::VERSION` constant to hold the version number (also available as `Cyclonedx::VERSION`)
- `Cyclonedx::Ruby::Deprecation` module to help manage deprecations

### Changed

- Updated gemspec metadata for clarity and consistency
- Modernized Rakefile, dotfiles, and test setup
- `LICENSE` => `LICENSE.txt` to simplify parsing consistency on various platforms and tools
- `cucumber` v8 => v10
- `aruba` v2.1 => v2.2

### Deprecated

- `BomComponent` => `Cyclonedx::BomComponent`
- `Bombuilder` => `Cyclonedx::BomBuilder` (note the capitalization change)
- `Object.purl` => `Cyclonedx::BomHelpers.purl`
- `Object.random_urn_uuid` => `Cyclonedx::BomHelpers.random_urn_uuid`
- `Object.build_bom` => `Cyclonedx::BomHelpers.build_bom`
- `Object.build_json_bom` => `Cyclonedx::BomHelpers.build_json_bom`
- `Object.build_bom_xml` => `Cyclonedx::BomHelpers.build_bom_xml`
- `Object.get_gem` => `Cyclonedx::BomHelpers.get_gem`

Signed-off-by: Peter H. Boling <[email protected]>
### Added

- `CHANGELOG.md` file to document notable changes in keep-a-changelog format
- `Cyclonedx::BomHelpers` module to house helper methods, replacing global methods
- `Cyclonedx::BomBuilder` class, replacing `Bombuilder` (note the capitalization change)
- `Cyclonedx::BomComponent` class, replacing `BomComponent`
- `Cyclonedx::Ruby::Version::VERSION` constant to hold the version number (also available as `Cyclonedx::VERSION`)
- `Cyclonedx::Ruby::Deprecation` module to help manage deprecations

### Changed

- Updated gemspec metadata for clarity and consistency
- Modernized Rakefile, dotfiles, and test setup
- `LICENSE` => `LICENSE.txt` to simplify parsing consistency on various platforms and tools
- `cucumber` v8 => v10
- `aruba` v2.1 => v2.2

### Deprecated

- `BomComponent` => `Cyclonedx::BomComponent`
- `Bombuilder` => `Cyclonedx::BomBuilder` (note the capitalization change)
- `Object.purl` => `Cyclonedx::BomHelpers.purl`
- `Object.random_urn_uuid` => `Cyclonedx::BomHelpers.random_urn_uuid`
- `Object.build_bom` => `Cyclonedx::BomHelpers.build_bom`
- `Object.build_json_bom` => `Cyclonedx::BomHelpers.build_json_bom`
- `Object.build_bom_xml` => `Cyclonedx::BomHelpers.build_bom_xml`
- `Object.get_gem` => `Cyclonedx::BomHelpers.get_gem`

### Fixed

- `Nokogiri::XML::Builder` context relies on `method_missing`
  - Globally defined `Object#purl` conflicted with `<purl>`.
  - Moved to `Cyclonedx::BomHelpers.purl` to avoid conflict in v2.0.0 (along with all other global methods)
  - Fixed existing usage via the built-in Nokogiri workaround of adding an underscore `purl_`
  - The XML tag is unchanged as `<purl>`

Signed-off-by: Peter H. Boling <[email protected]>
Signed-off-by: Peter H. Boling <[email protected]>
Signed-off-by: Peter H. Boling <[email protected]>
@pboling pboling force-pushed the fix/nokogiri-incompatible-with-global-purl branch from 1352653 to 6ebe091 Compare October 30, 2025 06:59
@pboling pboling force-pushed the fix/nokogiri-incompatible-with-global-purl branch 2 times, most recently from 39b4cb3 to 23ef3f8 Compare October 30, 2025 07:24
- Bigger build matrix changes are needed to continue running against older bunlders.
- will introduce the appraisal pattern later

Signed-off-by: Peter H. Boling <[email protected]>
Signed-off-by: Peter H. Boling <[email protected]>
@pboling
Copy link
Author

pboling commented Oct 30, 2025

@jkowalleck this is done, I tihnk. CI matrix should be passing now, and all comments have been addressed. LMK if there is anything else to be done here. I've got a lot more improvements I'd like to make, so these initial 4 PRs are just the beginning.
I had to drop the older versions of ruby, and added the newer ones to replace them.
The older ones will not work with latest version of bundler, because they are EOL, and thus continuing to run them in CI requires additional configuration, but I'd like to do that in an isolated PR, because it will be many lines of code (appraisals is a useful pattern for this usecase).

@pboling pboling force-pushed the fix/nokogiri-incompatible-with-global-purl branch from 23ef3f8 to e0de431 Compare October 30, 2025 07:31
@pboling
Copy link
Author

pboling commented Oct 30, 2025

The other 3 PRs have been fully rebased and re-stacked.

remote: .
specs:
cyclonedx-ruby (1.2.0)
activesupport (~> 7.0)
Copy link

Choose a reason for hiding this comment

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

~> 7.2

Previous are EOL

Copy link
Author

Choose a reason for hiding this comment

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

I'll be adding discrete support for testing against different versions of dependencies when I add appraisals in a different PR, and I'll also take that opportunity to rip out the active support dependency completely. It's way too much for this PR though.

Copy link
Member

Choose a reason for hiding this comment

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

note to self: create a ticket for this

@pboling pboling requested a review from jkowalleck October 30, 2025 16:33
@pboling
Copy link
Author

pboling commented Oct 30, 2025

@mperham - yes, I'll be trimming the dependencies in a future PR.

- '3.4.7'
- '3.3.9'
- '3.2.9'
# Not supported by latest bundler. These will be added back to the build matrix later.
Copy link
Member

Choose a reason for hiding this comment

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

note to self: create a followup ticket for this

remote: .
specs:
cyclonedx-ruby (1.2.0)
activesupport (~> 7.0)
Copy link
Member

Choose a reason for hiding this comment

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

note to self: create a ticket for this

bom.xml Outdated
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.1" version="1" serialNumber="urn:uuid:ffc51349-2d7d-408e-b2c1-3e3f220e6d2f">
<components>
Copy link
Member

Choose a reason for hiding this comment

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

why would we want to publish our own bom in the repo here?
why in CycloneDX1.1 format?

Copy link
Author

@pboling pboling Oct 30, 2025

Choose a reason for hiding this comment

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

These were test artifacts, and were added accidentally. They were v1.1 because that's all this gem supports in the current state. I've added them to .gitignore, and removed them from this PR... but now that I'm thinking about it,

why would we want to publish our own bom in the repo here?

should this gem dogfood itself, and ship its own BOM built with itself?

Seems like that could be a reasonable goal.

Copy link
Member

Choose a reason for hiding this comment

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

should this gem dogfood itself, and ship its own BOM built with itself?

creating a BOM could be part of the release, when the gem is compiled.
then, that BOM would be a welcome release artifact.

Copy link
Author

Choose a reason for hiding this comment

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

I like the idea. I'll work on that in a future PR! For this one the bom artifcats are removed.

Copy link
Member

Choose a reason for hiding this comment

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

why would we want the cert of developers/contributors/maintainers in our git repo?

see also my remarks on the CONTRIBUTING.md file

Copy link
Author

Choose a reason for hiding this comment

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

It is useful to track who the gem signers are, IMO. It definitely doesn't have to be done this way, but I expect people in the community would find value in seeing it.

Copy link
Author

@pboling pboling Oct 30, 2025

Choose a reason for hiding this comment

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

Additionally, until there is a proper signing key host we rely on as a community, this is the next best thing. Signing gems is pointless if the signing can't be verified, and that can only be done against the public cert. I've made mine available in a special "certs" project for longevity, but in order to facilitate other signers/releasers it makes sense to have a copy in the repo itself. I am certain that this pattern is in need of improvement, but I'm not sure if it is something that should be solved here / now.

Copy link
Author

Choose a reason for hiding this comment

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

FWIW: This is what I envision adding to the readme at some point (made less invasive by placing in details tag as I do on other projects perhaps).

🔒 Secure Installation

For Medium or High Security Installations

This gem is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums. Be sure the gem you install hasn’t been tampered with by following the instructions below.

Add signer's public key (if you haven’t already, expires 2045-04-29) as a trusted certificate:

gem cert --add <(curl -Ls https://raw.github.com/galtzo-floss/certs/main/pboling.pem)

You only need to do that once. Then proceed to install with:

gem install cyclonedx-ruby -P HighSecurity

The HighSecurity trust profile will verify signed gems, and not allow the installation of unsigned dependencies.

If you want to up your security game full-time:

bundle config set --global trust-policy MediumSecurity

MediumSecurity instead of HighSecurity is necessary if not all the gems you use are signed.

NOTE: Be prepared to track down certs for signed gems and add them the same way you added this signer's.

Copy link
Author

@pboling pboling Oct 30, 2025

Choose a reason for hiding this comment

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

That gem cert add command is the core of the question here.
I have a centralized certs project so I can use that same line in every gem I publish.
This one could alternatively use:

gem cert --add <(curl -Ls https://raw.github.com/CycloneDX/cyclonedx-ruby-gem/main/certs/pboling.pem)

but only if we keep the certs in this repo.

I'm open to other ideas. The gem signing infrastructure for Ruby is admittedly lackluster. I am trying to improve it, but that's a separate effort.

Copy link
Member

Choose a reason for hiding this comment

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

this signing process is premature. please remove it for now.

Copy link
Author

Choose a reason for hiding this comment

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

Premature is an accurate assessment. I'll remove it.

Copy link
Author

Choose a reason for hiding this comment

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

@jkowalleck it is worth noting that other signed gems that are developed by a team use a team cert, shared among those who publish the gem, and rotated when that set changes. It's a small improvement, but the entire process is still very under-developed.

Copy link
Author

Choose a reason for hiding this comment

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

@jkowalleck gem signing / cert logic is removed.

spec.metadata["source_code_uri"] = "#{spec.homepage}/tree/v#{spec.version}"
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
Copy link
Member

@jkowalleck jkowalleck Oct 30, 2025

Choose a reason for hiding this comment

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

please remove, as long as we don't host any docs there.

Copy link
Author

@pboling pboling Oct 30, 2025

Choose a reason for hiding this comment

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

https://github.com/docmeta/rubydoc.info is is the semi-official doc host for all rubygems (public service, community supported), so the docs will be hosted there regardless of whether we link to them or not. They host the docs of all public rubygems, without exceptions. Is there a preferred doc host we could link instead?

Copy link
Author

Choose a reason for hiding this comment

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

They are actually already hosted there, but the documentation isn't great in the current release. The next release will have excellent YARD documentation.

https://rubydoc.info/gems/cyclonedx-ruby

Copy link
Member

Choose a reason for hiding this comment

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

They are actually already hosted there, but the documentation isn't great in the current release. The next release will have excellent YARD documentation.

then better remove the link until we have docs worth reading.

Is there a preferred doc host we could link instead?

undecided.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

jkowalleck and others added 5 commits October 30, 2025 20:57
Signed-off-by: Jan Kowalleck <[email protected]>
- cleanup spec.files

Signed-off-by: Peter H. Boling <[email protected]>
Signed-off-by: Peter H. Boling <[email protected]>
@pboling
Copy link
Author

pboling commented Oct 31, 2025

@jkowalleck I'm not sure what happened, but it seems the Codacy issues are no longer extant. Maybe the linting auto-fixes resolved them? :)

@pboling pboling requested a review from jkowalleck November 1, 2025 05:32
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.

4 participants