
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Set of shared security based functions to be used across all E-Bot7 applications.
The package is about a set of tools which help to deal with security and help to prevent XSS attacks.
The installation process is pretty common and it doesn't have any other peer dependencies.
npm install @ebot7/xss
import { sanitize } from "@ebot7/xss";
const dirtyHTML = "<h1>Hello world!</h1><p>We use <a href='https://quilljs.com' onmouseenter='alert(\"XSS\");'>Quill</a> as a wysiwyg editor</p>";
const cleanHTML = sanitize(dirtyHTML);
console.log(cleanHTML); //"<p>We use <a href='https://quilljs.com'>Quill</a> as a wysiwyg editor</p>"
It uses sanitize-html
package under the hood with some preconfigured options. However, you could pass you own ones which will be deep merged with default options.
import { sanitize } from "@ebot7/xss";
const dirtyHTML = "<h1>Hello world!</h1><p>We use <a href='https://quilljs.com' onmouseenter='alert(\"XSS\");'>Quill</a> as a wysiwyg editor</p>";
const cleanHTML = sanitize(dirtyHTML, {allowedTags: ['h1']});
console.log(cleanHTML); //"<h1>Hello world!</h1><p>We use <a href='https://quilljs.com'>Quill</a> as a wysiwyg editor</p>"
Default options are deepe merged with given ones, that's why you could see an h1
tag in a result above.
To get default options you can import them like:
import { DEFAULT_SANITIZE_OPTIONS } from "@ebot7/xss";
And they are:
{
allowedTags: [
'a',
'b',
'br',
'div',
'em',
'i',
'img',
'li',
'ol',
'p',
'span',
'strong',
'u',
'ul',
],
allowedAttributes: {
a: ['href', 'name', 'target', 'rel'],
img: ['src', 'alt', 'width', 'height', 'align', 'style'],
},
}
FAQs
Set of shared security based functions to be used across all E-Bot7 applications.
The npm package @ebot7/xss receives a total of 5 weekly downloads. As such, @ebot7/xss popularity was classified as not popular.
We found that @ebot7/xss demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.