Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A middleware layer between a service and a client. The service could be an in-process library, a file, an external web service, anything. Any time the results from a resource call can be cached, you can use ASC as a proxy to that resource.
A middleware layer between a service and a client. The service could be an in-process library, a file, an external web service, anything. Any time the results from a resource call can be cached, you can use ASC as a proxy to that resource.
ASC is a good solution to cache data returned from a service if the following criteria can be met:
ascInstance( key, function( value ) {
// handle the value here
} );
Note: you don't need to have an update function at all. You can simply use the cache as a TTL cache where a TTL >= 1000 ms is acceptable. Simply omit the updateFunc param from the options passed to the .get( name, options ) method.
Soon to come:
Lets pretend you have a server that handles profiles, and it has a web service for looking up profiles which returns JSON. Lets also say that profile server takes 250ms to service a request. Lets also assume profiles can be up to 5 minutes old in your system to meet business requirements. The following code is one way you could cache the profile lookups.
var profileCache = require( 'asc' ).get( 'user.profile', {
ttl: 300000, // milliseconds to cache data. minimum is 1000ms
update: function( username, callback ) {
request( {
url: "http://profile-server.mydomain.com/" + username
},
function( result ) {
callback( JSON.parse(result.body) );
} );
}
} );
// now do all the profile lookups you want
// cache miss, triggers updates for next three gets
cache.get( 'anthony', function( profile ) {
console.log(value);
} );
cache.get( 'suzanne', function( value ) {
console.log(value);
} );
cache.get( 'jackson', function( value ) {
console.log(value);
} );
// good chance the first request for suzanne is not yet serviced, but this get does NOT trigger a second call to the profile server. This call to get will queue up and receive the same data that is passed to the first get for suzanne
cache.get( 'suzanne', function( value ) {
console.log( value );
} );
Some things to notice from the example. The name of the cache we returned from the cache factory, user.profile, is a singleton. If any other module does a getCache on that cache name, they will get the same cache, thereby allowing different modules to benefit from the same data cache for that resource. Also note, that passing a configuration object is optional. If you want a self-updating cache, you must pass the options with an update function once, but subsequent calls can simply be require( 'asc' ).getCache( 'user.profile' );
(The MIT License)
Copyright (c) 2012 BlueRival Software anthony@bluerival.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A middleware layer between a service and a client. The service could be an in-process library, a file, an external web service, anything. Any time the results from a resource call can be cached, you can use ASC as a proxy to that resource.
The npm package asc receives a total of 23 weekly downloads. As such, asc popularity was classified as not popular.
We found that asc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.