
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
The stupidest JS utility you can ever think of:
freshen-up
lets you cache the product of a
function and refresh its value at a given interval.
It might be useful when you need to cache some values (reading files from the filesystem, API result) and want to refresh those values every now and then.
npm install freshen-up
The library is pretty straightforward:
var freshenUp = require('freshen-up');
function loadConfigurationFromTheDatabase() {
// ...
// ...
};
var config = freshenUp(loadConfigurationFromTheDatabase);
config.get().someValue; // will be something
config.get().someValue; // will be something else
As you might understand, freshen-up
accepts your
function and exposes the get
method to access the
value of that function.
Another example:
var freshenUp = require('freshen-up');
function pingGoogleDotComToCheckWhetherWeHaveInternetAccess() {
// will return true or false
};
var ping = freshenUp(pingGoogleDotComToCheckWhetherWeHaveInternetAccess);
ping.get(); // true
// disconnect from the network
ping.get(); // false
By default, freshen-up
refreshes every 50ms, but
you can override this setting by just specifying your
custom interval:
// set an interval of 1s
var ping = freshenUp(pingGoogleDotComToCheckWhetherWeHaveInternetAccess, 1000);
ping.get(); // true
// disconnect from the network
// the value of the function hasn't been refreshed yet
ping.get(); // true
// if we check after 1s, the value has changed
setTimeout(function(){
ping.get(); // false
}, 1000);
You can simply run mocha
and meet greenland.
Cache invalidation. But that's too much of a problem.
But yeah, seriously, you can think of a 100 ways to do this more efficiently.
FAQs
Cache objects for a specified TTL. After that, freshen them up!
We found that freshen-up 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 researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.