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.
A (mostly) drop-in replacement for Handlebars.rb based on MiniRacer rather than therubyracer.
An appropriately revised quote from the Handlebars.rb README:
This uses
therubyracerMiniRacer to bind to the actual JavaScript implementation of Handlebars.js so that you can use it from ruby.
Minibars is a stripped down implementation of Handlerbars.rb using MiniRacer. It eschews capabilities that require two-way binding with the JS runtime, making it a good choice for those with simple Handlebars templates who need an upgrade path for their ARM64 architecture.
require 'minibars'
minibars = Minibars::Context.new
template = minibars.compile("{{say}} {{what}}")
template.call(say: "Hey", what: "Yuh!") #=> "Hey Yuh!"
This feature differs from Handlebars.rb since Minibars templates won't pass a this
argument to property functions.
template.call(say: "Hey ", what: ->{ ("yo" * 2) + "!"}) #=> "Hey yoyo!"
JavaScript helpers can be loaded as individual files or as a glob
minibars.load_helpers("#{__dir__}/javascripts/helpers/**/*.js")
minibars.load_helper("#{__dir__}/javascripts/helpers/admin.js")
You can directly register partials
minibars.register_partial("whoami", "I am {{who}}")
minibars.compile("{{>whoami}}").call(who: 'Legend') #=> I am Legend
By default, handlebars will escape strings that are returned by your block helpers. To mark a string as safe:
template = minibars.compile("{{safe}}")
template.call(safe: Minibars::SafeString.new("<pre>Totally Safe!<pre>"))
Handlebars::Context
aliases Minibars::Context
and Handlebars::SafeString
aliases Minibars::SafeString
unless they are already defined.
require 'handlebars` # Applies the compatibility layer found in lib/handlebars.rb and loads minibars
In general, you should not trust user-provided templates: a template can call any method (with no arguments) or access any property on any object in the Minibars::Context
.
If you'd like to render user-provided templates, you'd want to make sure you do so in a sanitized Context, e.g. no filesystem access, read-only or no database access, etc.
FAQs
Unknown package
We found that minibars demonstrated a healthy version release cadence and project activity because the last version was released less than 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
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.