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.
Introducing a versatile value loader for your Ruby on Rails views, designed to optimize parallel loading of information on a page. This solution is perfect for scenarios where you need to display multiple stats, each taking 1-2 seconds to compute, thus causing a delay in page loading time.
Functioning similarly to lazy Turbo frames, this value loader has no reliance on Turbo and eliminates the need for creating new actions to load data. Make your page loading experience smoother and more efficient with this practical solution.
It's strongly suggested to configure initializer (can be generated with rails g lazy_value initializer
). You can put your credentials/secrets/env variable. It's needed to use the same encryption key between deploys or server instances.
LazyValue.setup do |config|
config.salt = ENV["LAZY_VALUE_SALT"].presence || SecureRandom.random_bytes(ActiveSupport::MessageEncryptor.key_len)
config.key = ENV["LAZY_VALUE_KEY"].presence || SecureRandom.hex(32)
end
And now you can use lazy_value_tag
helper in your views:
<div class="column is-one-quarter">
<div class="box has-text-centered">
<h2 class="subtitle">Number 2</h2>
<%= lazy_value_tag do %>
<p class="title"><%= Project.pending.count %>%</p>
<% end %>
</div>
</div>
<div class="column is-one-quarter">
<div class="box has-text-centered">
<h2 class="subtitle">Number 3</h2>
<p class="title">
<%= lazy_value_tag { User.active.count } %>
</p>
</div>
</div>
It also works with partials:
<div class="box">
<%= lazy_value_tag do %>
<strong>Random 5 users</strong>
<%= render "/home/users", users: User.limit(5).order("random()") %>
<% end %>
</div>
And even compatible with Turbo.
<turbo-frame id="messages" target="_top">
This content is from lazy loaded turbo frame.
<%= lazy_value_tag do %>
<h3 class="title"><%= rand(1000) %></h3>
<% end %>
<%= lazy_value_tag do %>
<%= "I'm lazy loaded from the turbo frame" %>
<% end %>
</turbo-frame>
Add this line to your application's Gemfile:
gem "lazy_value"
And then execute:
$ bundle
And that is it. Start using it.
lazy_value_tag
in the viewcaller_locations.first
), file + line number.ActiveSupport::MessageEncryptor
, creating span with spinner, and JS snippet that will call /lazy_value/show?payload=
bin/rails test:system
.
You are welcome to contribute.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that lazy_value 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
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.