Skip to content

Add Gemfile.lock parser for Ruby/Rails projects#49

Open
Ayush-Bulbule wants to merge 6 commits intotiluckdave:mainfrom
Ayush-Bulbule:feat/gemfile-lock-parser
Open

Add Gemfile.lock parser for Ruby/Rails projects#49
Ayush-Bulbule wants to merge 6 commits intotiluckdave:mainfrom
Ayush-Bulbule:feat/gemfile-lock-parser

Conversation

@Ayush-Bulbule
Copy link
Copy Markdown

@Ayush-Bulbule Ayush-Bulbule commented Mar 24, 2026

What does this PR do?

Adds support for parsing Gemfile.lock files from Ruby/Rails projects, enabling vulnerability scanning and license checking for RubyGems dependencies.

Closes #40

Why?

Ruby/Rails projects use Gemfile.lock to lock dependency versions, but Hound MCP previously only supported JavaScript (npm/yarn/pnpm), Python (pip), Rust (Cargo), and Go ecosystems. This adds Ruby/RubyGems support, allowing users to scan Rails applications and Ruby gems for security vulnerabilities and license compliance issues.

Type of change

  • Bug fix
  • New tool
  • New lockfile parser
  • Improvement to existing tool
  • Refactor / cleanup
  • Documentation
  • CI / tooling

Checklist

  • pnpm check passes (typecheck + lint + tests)
  • New functionality has tests
  • Tool output is human-readable text (not raw JSON)
  • No new dependencies that require API keys or accounts
  • CLAUDE.md updated if architecture changed

Testing

Unit Tests (23 test cases)

  • Basic Gemfile.lock parsing (GEM section only)
  • Platform-qualified version normalization (nokogiri 1.14.2-x86_64-darwin1.14.2)
  • Prerelease identifier preservation (7.1.0-beta.1 stays unchanged)
  • GIT/PATH section handling (intentionally excluded)
  • Gem names with hyphens, underscores, uppercase letters, and dots
  • Section boundary detection (PLATFORMS, DEPENDENCIES, etc.)
  • Version constraint formats (with and without = prefix)

Real-world Validation

Tested with Mastodon's production Gemfile.lock (348 gems):

  • Successfully parsed 100 dependencies (tool limit)
  • Found real vulnerability: [email protected] (GHSA-f27w-vcwj-c954)
  • Platform normalization working correctly (no OSV lookup errors)
  • End-to-end flow: parse → normalize → OSV query → report

Example Files

  • Added examples/audit-ruby-project/Gemfile.lock with real Rails dependencies
  • Added examples/audit-ruby-project/README.md with usage instructions

Tools Updated

  • hound_audit - now supports Gemfile.lock
  • hound_license_check - now supports Gemfile.lock
  • Documentation updated in docs/tools.md

- Add parseGemfileLock() function to parse Bundler lockfiles
- Extract gem dependencies from specs section with rubygems ecosystem
- Add comprehensive test coverage with 6 test cases
- Include real-world Rails 7 example in examples/audit-ruby-project/
- Support gems with hyphens, underscores, and version constraints
- Update hound_audit tool description and error messages
- Update hound_license_check input schema and error messages
- Update tools.md documentation to include Gemfile.lock
- Only parse gems from GEM section, ignore GIT/PATH sections
- Fix misleading comment about dependency line format
- Add test case for GIT section handling
- Ensure parser correctly tracks section boundaries
- Strip platform suffixes (e.g., -x86_64-darwin, -java, -mingw32) from gem versions
- Ensures OSV/deps.dev lookups succeed with base version (1.14.2 vs 1.14.2-x86_64-darwin)
- Preserve legitimate prerelease identifiers (beta, rc, alpha)
- Add comprehensive tests for platform normalization and prerelease preservation
Copilot AI review requested due to automatic review settings March 24, 2026 19:58
@Ayush-Bulbule Ayush-Bulbule changed the title Feat/gemfile lock parser Add Gemfile.lock parser for Ruby/Rails projects Mar 24, 2026
Copy link
Copy Markdown
Contributor

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

Adds Ruby/Rails dependency support by parsing Gemfile.lock and wiring that into the existing audit + license-check flows, enabling OSV vulnerability scanning and deps.dev license resolution for RubyGems.

Changes:

  • Extend parseLockfile to recognize and parse Gemfile.lock into rubygems dependencies.
  • Add unit tests covering Gemfile.lock parsing behaviors (section handling, name formats, version normalization).
  • Update tool/docs messaging and add an end-to-end Ruby audit example project.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/parsers/index.test.ts Adds Gemfile.lock parsing test coverage.
src/parsers/index.ts Introduces rubygems ecosystem + parseGemfileLock implementation.
src/tools/audit.ts Updates tool copy to include Gemfile.lock as supported.
src/tools/license-check.ts Updates tool copy to include Gemfile.lock as supported.
docs/tools.md Documents Gemfile.lock support for hound_audit.
examples/audit-ruby-project/README.md Adds usage instructions for Ruby audit example.
examples/audit-ruby-project/Gemfile.lock Provides a real-world sample Gemfile.lock for demos/testing.

@tiluckdave
Copy link
Copy Markdown
Owner

Thanks @Ayush-Bulbule 🙌

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.

Add Gemfile.lock parser

3 participants