Skip to content

feat: add rubygems and Go support to osv worker [CM-1241]#4333

Merged
mbani01 merged 4 commits into
mainfrom
feat/support_rubygems_in_osv_worker
Jul 14, 2026
Merged

feat: add rubygems and Go support to osv worker [CM-1241]#4333
mbani01 merged 4 commits into
mainfrom
feat/support_rubygems_in_osv_worker

Conversation

@mbani01

@mbani01 mbani01 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This pull request adds support for version comparison in the compareVersion utility for the Go and RubyGems ecosystems, ensuring consistent and accurate version ordering across more package types. It also expands test coverage and updates configuration to recognize these new ecosystems.

Ecosystem support and logic changes:

  • Added support for Go (go) and RubyGems (rubygems) ecosystems to the compareVersion function, including a new RubyGems version comparison algorithm that mimics Gem::Version behavior.
  • Updated the list of valid ecosystems in VALID_ECOSYSTEMS to include Go and RubyGems, ensuring these are recognized during schedule validation.

Testing improvements:

  • Added comprehensive test cases for Go and RubyGems version comparisons, including handling of pseudo-versions, pre-releases, and invalid input, to versionCompare.test.ts.

Note

Medium Risk
Changes affect vulnerability range matching (has_critical_vulnerability) for two new ecosystems; behavior is heavily tested but wrong ordering could mis-flag or miss critical CVEs.

Overview
Extends the OSV packages worker so Go and RubyGems advisories can be synced and version ranges evaluated consistently with other ecosystems.

Version ordering: go is routed through the existing loose semver path (including pseudo-versions). rubygems gets a new Gem::Version-style comparator (hyphen → prerelease, canonical segments, bigint for huge numeric segments) wired into compareVersion. Tests cover CVE-style boundaries, invalid input, and lowercase-only ecosystem keys.

OSV ingest: Local OSV_ECOSYSTEMS and VALID_ECOSYSTEMS now include RubyGems and Go (OSV bucket casing preserved). On worker startup, if the Temporal osv-advisories-sync schedule already exists, its workflow action is updated so a changed OSV_ECOSYSTEMS list is picked up without manual schedule edits.

Reviewed by Cursor Bugbot for commit dbed36f. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Copilot AI review requested due to automatic review settings July 13, 2026 14:16
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4359559. Configure here.

Comment thread services/apps/packages_worker/src/osv/versionCompare.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds RubyGems version comparison and OSV synchronization support.

Changes:

  • Implements and routes RubyGems version ordering.
  • Allows RubyGems OSV ingestion.
  • Adds comparator tests.

The comparator has blocking compatibility errors around prereleases, separators, and large numeric segments. Existing schedules also will not automatically ingest RubyGems.

Metadata: The title should end with (CM-1241), not [CM-1241].

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
osv/versionCompare.ts Adds RubyGems comparison logic.
osv/schedule.ts Adds RubyGems to the ecosystem allowlist.
osv/__tests__/versionCompare.test.ts Adds RubyGems comparison tests.

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

Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Comment thread services/apps/packages_worker/src/osv/__tests__/versionCompare.test.ts Outdated
Comment thread services/apps/packages_worker/src/osv/schedule.ts Outdated
Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Copilot AI review requested due to automatic review settings July 13, 2026 14:27
@mbani01 mbani01 changed the title feat: add rubygems support to osv worker [CM-1241] feat: add rubygems and Go support to osv worker [CM-1241] Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Comment thread services/apps/packages_worker/src/osv/__tests__/versionCompare.test.ts Outdated
Comment thread services/apps/packages_worker/src/osv/schedule.ts
Comment thread services/apps/packages_worker/src/osv/versionCompare.ts Outdated
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Copilot AI review requested due to automatic review settings July 13, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread services/apps/packages_worker/src/osv/versionCompare.ts
@mbani01
mbani01 requested a review from themarolt July 13, 2026 15:21
@mbani01 mbani01 self-assigned this Jul 14, 2026
Copilot AI review requested due to automatic review settings July 14, 2026 09:18
@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes drive OSV-derived vulnerability range matching for two new ecosystems; incorrect comparison logic could mis-set critical flags, though behavior is heavily tested and follows existing under-flag-over-mis-flag patterns.

Overview
Extends the OSV packages worker so Go and RubyGems advisories can be synced and version boundaries evaluated consistently with other ecosystems.

Version comparison: compareVersion routes go through the existing loose semver path (including pseudo-versions). rubygems gets a new Gem::Version-style comparator (hyphen → prerelease, canonical segments, letter vs numeric segment rules, bigint for huge numeric segments) so introduced/fixed ranges do not mis-rank.

OSV sync config: OSV_ECOSYSTEMS / VALID_ECOSYSTEMS now include RubyGems and Go (OSV bucket casing preserved). When the Temporal schedule already exists, startup reconciles the schedule action (and overlap policy) so env changes to ecosystems apply without manual schedule edits.

Tests cover Go/RubyGems ordering, invalid input, and lowercase-only ecosystem keys.

Reviewed by Cursor Bugbot for commit 709685a. Bugbot is set up for automated code reviews on this repo. Configure here.

@mbani01
mbani01 merged commit 9f6f068 into main Jul 14, 2026
12 checks passed
@mbani01
mbani01 deleted the feat/support_rubygems_in_osv_worker branch July 14, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +145 to +159
// Mirrors Gem::Version#canonical_segments: drop trailing zero segments, then
// drop any zero segments that sit directly before the first letter segment.
function canonicalRubyGemsSegments(segments: (bigint | string)[]): (bigint | string)[] {
const trimmed = [...segments]
while (trimmed.length > 1 && trimmed[trimmed.length - 1] === BigInt(0)) trimmed.pop()

const firstLetterIndex = trimmed.findIndex((segment) => typeof segment === 'string')
if (firstLetterIndex === -1) return trimmed

let zeroRunStart = firstLetterIndex
while (zeroRunStart > 0 && trimmed[zeroRunStart - 1] === BigInt(0)) zeroRunStart--
trimmed.splice(zeroRunStart, firstLetterIndex - zeroRunStart)

return trimmed
}
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