Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@types/dompurify
Advanced tools
The @types/dompurify package provides TypeScript type definitions for DOMPurify, a DOM-only XSS sanitizer for HTML, MathML, and SVG. It allows developers to use DOMPurify in TypeScript projects with type checking and autocompletion features.
Sanitizing HTML strings
This feature allows you to sanitize HTML strings to prevent XSS attacks. The sanitize function removes any malicious code from the input string.
import DOMPurify from 'dompurify';
const cleanHTML = DOMPurify.sanitize('<img src=x onerror=alert(1)//>');
Configuring DOMPurify
This feature allows you to configure DOMPurify to customize the sanitization process, such as specifying which tags are allowed.
import DOMPurify from 'dompurify';
const cleanHTML = DOMPurify.sanitize(dirtyHTML, { ALLOWED_TAGS: ['a', 'p'] });
Hooking into DOMPurify
This feature allows you to add hooks to DOMPurify's sanitization process, enabling you to manipulate nodes or their attributes after sanitization.
import DOMPurify from 'dompurify';
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
// manipulate node attributes after sanitization
});
sanitize-html is an HTML sanitizer that is similar to DOMPurify. It also removes unwanted HTML and protects from XSS attacks but is not limited to the DOM and can be used on the server-side with Node.js.
xss is another package that provides protection against XSS attacks. It includes a range of options for filtering and customizing the sanitization process, similar to DOMPurify, but it has a different API and may have different default settings.
npm install --save @types/dompurify
This package contains type definitions for DOM Purify (https://github.com/cure53/DOMPurify).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dompurify.
DOMPurify
These definitions were written by Dave Taylor (http://davetayls.me), Samira Bazuzi (https://github.com/bazuzi), FlowCrypt (https://github.com/FlowCrypt), and Exigerr (https://github.com/Exigerr).
FAQs
Stub TypeScript definitions entry for dompurify, which provides its own types definitions
We found that @types/dompurify demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.