Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
'Henka' is Japanese for 'change'.
DelayHenka
is a Rails engine for managing delayed update of attributes. This is built to ensure that important attributes (such as price of a product, for instance) can be updated anytime but will not impact users until a specific time later in the day (maybe 2am in the morning, when it's safe to apply those changes).
Granted, there're other strategies with higher level of integrity (such as versioning the resources). This implementation is merely a low-cost solution that solves the problem to a reasonable extent.
In the including application,
# copy over migrations
`bundle exec rails delay_henka:install:migrations`
`bundle exec rails db:migrate`
# config/routes.rb
mount DelayHenka::Engine, at: '/delay_henka'
# Create an initilazer delay_henka.rb
DelayHenka.setup do |config|
# Sets the base controller of the engine views
config.base_view_controller = 'Backend::BaseController'
end
# In your model that you want to have delayed updates,
class SomeModel < ApplicationRecord
# This gives instances of this class `#upcoming_changes` association with staged ScheduledChange
include DelayHenka::Model
end
# In your controller (or factory service),
class SomeController
def update
@product = SomeModel.find(params[:id])
delayed_changes = some_params.extract!(:discount_pct, :price)
if @product.update some_params.except(:discount_pct, :price)
result = DelayHenka::ScheduledChange.schedule(record: @product, changes: delayed_changes, by_id: current_user.id)
if result.ok? # returns a Keka object
redirect_to #..., success
else
# no change is scheduled. display error and have user try again.
flash.now[:error] = result.msg
render :edit
end
else
render :edit
end
end
end
# To view scheduled changes associated with a record,
# some_view.html.haml
- if @product.upcoming_changes.any?
= render 'delay_henka/web/admin/scheduled_changes/summary_table', scheduled_changes: @product.upcoming_changes
# To view all scheduled changes, use this link:
delay_henka.web_admin_scheduled_changes_path
# To schedule the worker that applies all changes,
# in your sidekiq config/schedule.yml,
apply_scheduled_changes:
cron: "0 1 * * *"
class: DelayHenka::ApplyChangesWorker
queue: default
Add this line to your application's Gemfile:
gem 'delay_henka'
And then execute:
$ bundle
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Note that a mock AR class - Foo
- is created dynamically in rails_helper.rb for testing.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that delay_henka 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.