
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
gRPC for Ruby on Rails
Add this line to your application's Gemfile:
gem 'rails_grpc'
gem "google-protobuf", git: "git@github.com:nishio-dens/protobuf.git", branch: "rails-grpc", glob: "ruby/google-protobuf.gemspec"
And then execute:
$ bundle
You need to put the protobuf definition in Rails.root/proto dir.
$ tree proto
proto
├── ec.deep.proto
├── ec.proto
└── other.proto
You need to be careful about the location of grpc service, lib, and model files.
# current working dir is Rails.root
$ tree grpc
grpc
├── lib
│ ├── ec.deep_pb.rb
│ ├── ec.deep_services_pb.rb
│ ├── ec_pb.rb
│ ├── ec_services_pb.rb
│ └── other_pb.rb
├── models
│ └── ec
│ └── product.rb
└── services
└── product_service.rb
lib files is the protobuf autogenerate files.
models is a models that you want to extend protobuf models.
services is the protobuf service files.
# grpc/models/ec/product.rb
# You can extend Ec::Product models
class Ec::Product
PORT = "127.0.0.1:8080"
def self.all
service = Ec::ProductService::Stub.new(PORT, :this_channel_is_insecure)
req = Ec::GetProductsRequest.new
res = service.get_products(req)
res.products
end
def self.find(id)
service = Ec::ProductService::Stub.new(PORT, :this_channel_is_insecure)
req = Ec::GetByProductIdRequest.new(product_id: id)
res = service.get_by_product_id(req)
res.product
end
end
# grpc/services/product\_service.rb
module Grpc
class ProductService < Ec::ProductService::Service
def get_products(req, _call)
products = Product.all
Ec::GetProductsResponse.new(products: products.map(&:to_proto))
end
def get_by_product_id(req, _call)
product = Product.find_by(id: req.product_id)
if product.present?
Ec::GetByProductIdResponse.new(product: product.to_proto)
else
fail GRPC::BadStatus.new_status_exception(
GRPC::Core::StatusCodes::ABORTED,
"product #{req.product_id} not found"
)
end
end
end
end
First, you put protobuf definition in /proto dir, and you need to run compile command.
bundle exec rake protoc:compile
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/nishio-dens/rails_grpc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the RailsGrpc project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that rails_grpc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.