Skip to content

feat(ruby): emit dependency relationships from Gemfile.lock#4986

Open
cgreeno wants to merge 1 commit into
anchore:mainfrom
cgreeno:feat/ruby-gemfile-lock-relationships
Open

feat(ruby): emit dependency relationships from Gemfile.lock#4986
cgreeno wants to merge 1 commit into
anchore:mainfrom
cgreeno:feat/ruby-gemfile-lock-relationships

Conversation

@cgreeno

@cgreeno cgreeno commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

The Ruby Gemfile.lock parser catalogued gems but discarded the indented dependency lines beneath each spec, so it emitted no relationships. Those lines already encode the dependency graph (the gems listed under each spec are exactly its dependencies), so the graph is derivable from data already in the file — no new inputs required.

This change emits dependency-of relationships between locked gems. They are built inline in the parser, the way cpp/conan and dotnet derive relationships from their lockfiles — Gemfile.lock packages carry no metadata struct, so there is nothing to hang a dependency.Specifier off, and a relationships-only change needs no metadata type. No new metadata type and no JSON schema change.

Changeset:

File Change
syft/pkg/cataloger/ruby/parse_gemfile_lock.go gather each spec's indented dependency lines; emit dependency-of relationships (gemfileLockRelationships); split line detection into isGemSpecLine (4-space) and isGemDependencyLine (6-space)
parse_gemfile_lock_test.go assert the full dependency graph over the existing real-world Gemfile.lock fixture
parse_gemfile_lock_relationships_test.go (new) unit tests for the spec/dependency line detection and the relationship builder, including the unresolved-dependency skip path

Type of change: New feature (non-breaking) — adds relationship data without altering existing package output; no schema impact.

This mirrors the Elixir mix.lock change in #4985.

@oss-housekeeper

oss-housekeeper Bot commented Jun 24, 2026

Copy link
Copy Markdown

Schema Change Detection

New Schemas

  • schema/json/schema-16.1.9.json

@spiffcs

spiffcs commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@cgreeno since I merged your other elixir PR first this now has some schema conflicts. Can you do a quick rebase and regenerate the schema with the composite changes?

Parse each gem's dependency list from Gemfile.lock into a new
RubyGemfileLockEntry metadata type and use the shared dependency.Processor
to resolve dependency-of relationships between locked gems, matching the
pattern used by the other lockfile catalogers (elixir, python, rust, ...).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Chris Greeno <cgreeno@gmail.com>
@cgreeno cgreeno force-pushed the feat/ruby-gemfile-lock-relationships branch from 829b3f6 to ee6164d Compare July 1, 2026 22:47
@cgreeno

cgreeno commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@spiffcs - ok fixed

@cgreeno

cgreeno commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@spiffcs - gentle nudge :)

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