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.
multi-sitemap
Advanced tools
Painless creation of large dynamic sitemaps that consist of multiple files.
Painless creation of large dynamic sitemaps that consist of multiple files.
SitemapWriterXml
, SitemapWriterTxt
or build your own (e.g. create a sitemap at a remote static file host).import {SitemapProcessor, SitemapWriterXml} from 'multi-sitemap';
(async () => {
const processor = new SitemapProcessor({
// The domain where the sitemap is hosted. A sitemap is
// required to include a full URL including the host.
publicHost: 'http://domain.tld',
// The public path on the host where the sitemap can be
// found. This will be concatenated with `publicHost`.
publicDirectory: '/sitemap',
// One of the pluggable writers.
writer: new SitemapWriterXml({directory: './static/sitemap'});
});
await processor.addStatic({
name: 'pages',
entries: ['/', '/about']
});
await processor.addDynamic({
name: 'products',
reader: new SitemapProductsReader()
});
await processor.addIndex();
})();
All methods of SitemapProcessor
return promises that should be waited for before calling other methods. The addIndex
method should be called last, as this is the time the processor knows about all child sitemaps.
Create a reader class that implements the following interface:
interface ISitemapReader {
hasNext(): boolean;
getNext(): Promise<SitemapEntryConfig[]>;
}
// Given the following types:
type SitemapEntryConfig = /* url */ string | ISitemapEntry;
interface ISitemapEntry {
url: string;
lastModified?: Date;
changeFrequency?:
| 'always'
| 'hourly'
| 'daily'
| 'weekly'
| 'monthly'
| 'yearly'
| 'never';
priority?: number;
}
An instance of such a class can be passed to the sitemap processor. An example would be:
/**
* Fetches 7 pages of products, each consisting
* of 20 entities that are written to a sitemap.
*/
class SitemapProductsReader {
i = 0;
hasNext() {
return this.i < 7;
}
getNext() {
const size = 20;
const offset = this.i * size;
this.i++;
return fetch(`/api/products?offset=${offset}&size=${size}`)
.then(products => products.map(product => `/products/${product.id}`))
}
}
processor.addDynamic({
name: 'products',
reader: new SitemapProductsReader()
});
FAQs
Painless creation of large dynamic sitemaps that consist of multiple files.
We found that multi-sitemap 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.