
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.
Ruby HTTP client generator for APIs represented with JSON schema.
Add this line to your application's Gemfile:
gem 'heroics'
And then execute:
$ bundle
Or install it yourself as:
$ gem install heroics
If you don't want to pass config to the CLI, you can provide a Ruby config file to the heroics-generate
script as a single parameter.
The form of this configuration file is shown below.
require 'heroics'
Heroics.default_configuration do |config|
config.base_url = 'https://example.com'
config.module_name = 'ExampleClient'
config.schema_filepath = 'schema.json'
config.headers = { 'Accept' => 'application/vnd.example+json; version=1' }
# Note: Don't use doublequotes below -- we want to interpolate at runtime,
# not when the client is generated
config.cache_path = '#{Dir.home}/.heroics/example'
end
base_url
, module_name
, and schema_filepath
are required for a proper configuration.
The following keys are optional:
headers
cache_path
ruby_name_replacements
a hash of replacement patterns for converting endpoint paths to Ruby method names, such as:{ /[\s-]+/ => '_' }
For further details on config file usage, see the example/
directory in this repo.
Heroics generates an HTTP client from a JSON schema that describes your API. Look at prmd for tooling to help write a JSON schema. When you have a JSON schema prepared you can generate a client for your API:
heroics-generate MyApp schema.json https://api.myapp.com > client.rb
If you are using a configuration file, per above, just pass the path to it:
heroics-generate my-config-file.rb > client.rb
If your client needs to pass custom headers with each request these can be
specified using -H
:
heroics-generate \
-H "Accept: application/vnd.myapp+json; version=3" \
MyApp \
schema.json \
https://api.myapp.com > client.rb
Pass multiple -H
options if you need more than one custom header.
The generated client sends and caches ETags received from the server. By default, this data is cached in memory and is only used during the lifetime of a single instance. You can specify a directory for cache data:
heroics-generate \
-c "~/.heroics/myapp" \
MyApp \
schema.json \
https://api.myapp.com > client.rb
~
will automatically be expanded to the user's home directory. Be sure to
wrap such paths in quotes to avoid the shell expanding it to the directory you
built the client in.
The generated client has Yard-compatible docstrings.
You can generate documentation using yardoc
:
yard doc -m markdown client.rb
This will generate HTML in the docs
directory. Note that Yard creates an
_index.html
page won't be served by Jekyll on GitHub Pages. Add a
.nojekyll
file to your project to prevent GitHub from passing the content
through Jekyll.
The client uses Excon under the hood and raises Excon errors when failures occur.
begin
client.app.create({'name' => 'example'})
rescue Excon::Errors::Forbidden => error
puts error
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that heroics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
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.