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.
ActiveRecord-like way to interact with Vindi API
Vindi is a brazilian fintech, that was recently acquired by Locaweb, that helps other companies to work with recurring payments.
You may ask: Why create another gem if there is already one that's official? And I'll tell you, little grasshopper: Because MIT licenses are better than GPLv3.
Add this line to your application's Gemfile:
gem "vindi-hermes"
And then execute:
$ bundle install
Or install it yourself as:
$ gem install vindi-hermes
# config/initializers/vindi.rb
Vindi.config do |c|
c.sandbox = true # default is false
c.api_key = "YOUR API KEY"
c.webhook_name = "BASIC AUTH NAME"
c.webhook_password = "BASIC AUTH PASSWORD"
end
# Let's say that Gandalf wants to borrow Saruman's Palantir
# promising he'll give it back before the end of the 3rd era.
#
# But Saruman is wise and he thinks he could make a good money
# charging a rent for the use of the magic ball.
#
# So, Saruman went on to Vindi and there created a product...
#
palantir = Vindi::Product.new.tap do |p|
p.code = "palantir"
p.name = "Palantir"
p.description = "The Twitch of Istari folk"
p.pricing_schema = { price: 42.42 }
p.save
end
# ...then created a recurring plan.
one_plan = Vindi::Plan.new.tap do |p|
p.code = "the-one-plan"
p.name = "Monthly Plan"
p.description = "The One Plan To Rule Them All"
p.period = "monthly"
p.recurring = true
p.plan_items = [
{
cycles: nil, # untill the end of time
product_id: palantir.id
}
]
p.save
end
# Gandalf uses his fellow Bilbo's address to receive the invoices...
gandalf = Vindi::Customer.new.tap do |c|
c.code = 1
c.name = "Gandalf the Grey"
c.email = "mithrandir@middlearth.io"
c.address = {
street: "Bagshot Row",
number: "Bag End",
neighborhood: "Hobbiton",
city: "Shire"
}
c.save
end
# ...uses Elrond's credit card to create a payment profile...
pp = Vindi::PaymentProfile.new.tap do |pp|
pp.holder_name = "Elrond Half-elven"
pp.card_expiration = "12/3021"
pp.card_number = "5167454851671773"
pp.card_cvv = "123"
pp.customer_id = gandalf.id
pp.save
end
# ...subscribes and then get the palantir.
subscription = Vindi::Subscription.new.tap do |s|
s.plan_id = one_plan.id
s.customer_id = gandalf.id
s.payment_method_code = "credit_card"
s.save
end
# Active customers
customers = Vindi::Customer.active
# Active subscriptions
subscriptions = Vindi::Subscriptions.active
# Subscriptions for the-one-plan
subscriptions = Vindi::Plan.find_by(code: "the-one-plan").subscriptions
# Filter Gandalf
gandalf = Vindi::Customer.find_by(email: "mithrandir@middlearth.io")
# All Gandalf's subscriptions
subscriptions = gandalf.subscriptions.active
# Cancel Gandalf's subscription
gandalf.subscriptions.active.last.cancel!
# Refund the last Gandalf's payment
gandalf.charges.last.refund!
You must validate incoming data from Vindi.
You can validate webhook calls using baisc auth.
Just configure a webhook call with something like this https://NAME:PASSWORD@www.startupmassa.com/vindi/webhook
.
On Vindi admin dashboard
https://vindi:123456@www.startupmassa.com/vindi/webhook
On your project
# config/initializers/vindi.rb
Vindi.config do |c|
c.api_key = "123456"
c.webhook_name = "vindi"
c.webhook_password = "123456"
end
# routes.rb
namespace :vindi do
post :webhook, to: "webhook#listener"
end
# vindi/webhook_controller.rb
class Vindi::Webhook < ActionController::Base
http_basic_authenticate_with name: Vindi.webhook_name, password: Vindi.webhook_password
# POST https://usuario:senha@www.startupmassa.com/vindi/webhook
def listener
case event_params[:type]
when "charge_rejected" # defaulting user?
when "bill_paid" # do the magic
else
head :ok
end
end
private
def event_params
params.require(:event).permit!
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/wedsonlima/vindi-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Vindi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that vindi-hermes 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
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.