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.
EventMachine timers are great, but they work by waiting for a specified
time interval before firing. Instead, EM::ScheduledTimer
lets you
specify a Time
, Date
or DateTime
object (or indeed anything that will
respond to to_time
).
Imagine you're polling an HTTP-based API for changes. Because the API is
nice, it will set Expires
response headers so you know when to make
the next request. With EM::ScheduledTimer
(and the
em-http-request gem),
this becomes very easy:
def poll_api
http = EM::HttpRequest.new("http://api.example.com/changes")
http.callback do
expires = http.response_header['EXPIRES']
time = Time.httpdate(expires)
EM::ScheduledTimer.new(time) { poll_api }
end
end
Generally speaking, the API for a ScheduledTimer
is modelled after
that of a regular EM::Timer
.
You can create EM::ScheduledTimer
instances and pass in a block:
EM::ScheduledTimer.new(some_future_time) do
puts "Fire!"
end
Alternatively, you can pass in any object that responds to #call
(including a Proc
):
callback = -> { puts "Fire!" }
EM::ScheduledTimer.new(some_future_time, callback)
A ScheduledTimer
can also be cancelled:
timer = EM::ScheduledTimer.new(some_future_time) do
puts "Fire!"
end
timer.cancel # The timer won't fire
As with regular timers, a convenience method is available on the
EventMachine
module:
EM.add_scheduled_timer(some_future_time) do
puts "Fire!"
end
Note that in the latter case, you won't be able to cancel a timer that you've scheduled.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that em-scheduled-timer 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.