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.
image-resolver
Advanced tools
ImageResolver.js is a library that extracts the main image of a URL while saving resources. Instead of loading all images of a URL, it will try to guess the main image from the URL or the webpage. It's like Readability for images.
Demo : http://mauricesvay.github.com/ImageResolver/
ImageResolver works in browsers and Node.js.
To detect images, ImageResolver comes with built-in plugins:
Of course, you can create your own plugins.
In Node.js:
npm install image-resolver
In a browser:
<script src="dist/ImageResolver.js" type="text/javascript"></script>
var resolver = new ImageResolver();
resolver.register(new ImageResolver.FileExtension());
resolver.register(new ImageResolver.MimeType());
resolver.register(new ImageResolver.Opengraph());
resolver.register(new ImageResolver.Webpage());
resolver.resolve( "http://example.com/", function( result ){
if ( result ) {
console.log( result.image );
} else {
console.log( "No image found" );
}
});
Create a new instance of ImageResolver
Register the given plugin for resolving images. You must register at least one plugin. Plugins are executed in the order of their registration.
Extract main image from given url. Callback will be called with null
when
no image is found, or an object when the image is found.
To create a plugin, create an object that has resolve
method.
The resolve
method must have this signature:
function( url, clbk, options, utils ) {
...
}
When your plugin has found an image, you must call clbk
with the image as
parameter:
clbk( image_url );
If your plugin can not find an image, you must call clbk
with null as
parameter
clbk( null );
If your plugin needs to make HTTP GET requests, it is recommended to use
utils.fetch
. This function lets you make GET requests, works in browsers and Node.js,
and the result will be cached and shared between plugins.
If you need more control over HTTP requests, you can use utils.request
that
gives you access to the raw superagent library.
ImageResolver comes with a series of tests.
To run those tests:
npm install
npm install -g gulp
gulp
to build the browser libFAQs
Extract main image for a given URL
We found that image-resolver 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.