Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
protoc-gen-twirp_ruby
Advanced tools
protoc
plugin for Twirp-Ruby.This gem is a protoc
plugin that generates Twirp-Ruby services and clients.
Twirp-Ruby already does this
via a go
module. So why use this version?
The Go version works fine (we used it for years) but it was missing features that we wanted. Building in Ruby allows us to iterate quicker and makes it easier for others to contribute.
protoc
The Protocol Buffers protoc
command is used to auto-generate code from .proto
files.
brew install protobuf
sudo apt-get install -y protobuf
protoc
is able to read .proto
files and generate the message parsers in multiple languages, including Ruby (using
the --ruby_out
option). It does not generate Twirp services and clients; that is where our plugin comes in.
protoc-gen-twirp_ruby
pluginRun gem install protoc-gen-twirp_ruby
or add it to your Gemfile:
gem "protoc-gen-twirp_ruby", group: :development
If you previously used the Go version, see our Migration Instructions.
Pass --twirp_ruby_out
to protoc
to generate Twirp-Ruby code:
protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. ./path/to/service.proto
You can configure the code generation. Pass options by specifying --twirp_ruby_opt=<option>
on the protoc
command line.
generate=<service|client|both>
: Customize generated output to include generated services, clients, or both. Optional,
defaults to both to preserve backwards compatibility.
generate=service
- only generate ::Twirp::Service
s.generate=client
- only generate ::Twirp::Client
s.generate=both
- default; generate both services and clients.Example :
protoc --proto_path=. --ruby_out=. --twirp_ruby_out=. --twirp_ruby_opt=generate=client ./path/to/service.proto
If you previously installed the protoc-gen-twirp_ruby
Go module via the Twirp-Ruby's Code Generation wiki page
instructions, then you'll want to uninstall it before invoking the protoc
command.
rm `go env GOPATH`/bin/protoc-gen-twirp_ruby
This gem generates nearly identical Twirp-Ruby output as the Go version. Some notable differences that might affect migration include:
ruby_package
in .proto
filesAfter checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To experiment with development changes, route protoc
to the local plugin when generating code
via the --plugin=protoc-gen-twirp_ruby=./exe/protoc-gen-twirp_ruby
option. For example:
protoc --plugin=protoc-gen-twirp_ruby=./exe/protoc-gen-twirp_ruby --ruby_out=. --twirp_ruby_out=. ./example/hello_world.proto
Alternatively, install the local gem before invoking protoc
:
bundle exec rake install
protoc --ruby_out=. --twirp_ruby_out=. ./example/hello_world.proto
Install the GitHub CLI: brew install gh
or follow the instructions.
To release a new version:
version.rb
bundle exec rake example
main
is up-to-date, run bundle exec rake release
.Bug reports and pull requests are welcome on GitHub at https://github.com/collectiveidea/protoc-gen-twirp_ruby.
FAQs
Unknown package
We found that protoc-gen-twirp_ruby demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.