
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A Hashstring is an object that I wanted to experiment with. I was annoyed that i18n translations don't have a nice way of nesting under logical trees.
For example, given:
# en.yml
reports:
marketing: Marketing Reports
sales: Sales Reports
Trying to call I18n.t(:reports)
returns the hash of marketing and sales with their values. The solution would be to have two keys: an actual name and a namespace:
# en.yml
reports: Reports
report_types:
marketing: Marketing Reports
sales: Sales Reports
I wanted to experiment with a pattern that wouldn't require sacrifice. Enter the Hashtring:
reports = "Reports" ** {
marketing: "Marketing Reports",
sales: "Sales Reports"
}
puts reports # "Reports"
puts reports.marketing # "Marketing Reports"
Sure, it may not be entirely practical, and it probably doesn't solve any real problems, but it was something I wanted to play around with.
Add this line to your application's Gemfile:
gem 'hashtring'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hashtring
To create a Hashtring, simply call the #**
method on a string and give it a hash.
"label" ** {
key1: "value1",
key2: "value2"
}
One-liner:
"label" ** key: "value"
You can even nest Hashtrings:
orders = "Orders" ** {
line_items: "Line Items",
additional_charges: "Summary" ** {
tax: "NYS Tax",
shipping: "UPS Shipping"
}
}
Call up values just like you would with a normal hash, but root nodes can be output as strings.
puts orders # orders
puts orders[:line_items] # "Line Items"
puts orders[:additional_charges] # "Summary"
puts orders[:additional_charges][:tax] # "NYS Tax"
For fun, I leveraged method_missing to give an i18n-like syntax
puts orders.line_items # "Line Items"
puts orders.additional_charges.tax # "NYS Tax"
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that hashtring 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
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.