Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/dompurify
Advanced tools
Stub TypeScript definitions entry for dompurify, which provides its own types definitions
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.
This is a stub types definition for @types/dompurify (https://github.com/cure53/DOMPurify).
dompurify provides its own type definitions, so you don't need @types/dompurify installed!
FAQs
Stub TypeScript definitions entry for dompurify, which provides its own types definitions
The npm package @types/dompurify receives a total of 1,834,940 weekly downloads. As such, @types/dompurify popularity was classified as popular.
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.