
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
@radya/nuxt-dompurify
Advanced tools
A Nuxt 3 module that integrates DOMPurify for sanitizing HTML content and protecting against XSS attacks, with support for multiple profiles.
A Nuxt 3 module that integrates DOMPurify for sanitizing HTML content. This module helps protect your application from XSS attacks by sanitizing any potentially dangerous HTML inputs.
Install the module via Yarn:
yarn add -D @radya/nuxt-dompurify
Add the module to your Nuxt config file:
export default defineNuxtConfig({
modules: ['@radya/nuxt-dompurify'],
})
You can use the directive v-sanitize-html
to sanitize HTML content in your templates:
<template>
<div v-sanitize-html="dirtyHtml" />
</template>
<script setup>
const dirtyHtml = `
<div>
<h1>Welcome to My Website</h1>
<h3>This is H3 heading</h3>
<p>This is a <strong>simple</strong> paragraph.</p>
<img src="image.jpg" onerror="alert('Hacked!')" />
<a href="https://example.com" onclick="stealCookies()">Click me!</a>
<script>alert('This is an XSS attack!')</` + `script>
</div>`
</script>
This will sanitize the dirtyHtml
variable, ensuring it is safe to render in the DOM.
This module also supports profiles to allow different DOMPurify configurations for specific use cases. You can define profiles in your nuxt.config.ts
like this:
export default defineNuxtConfig({
modules: ['@radya/nuxt-dompurify'],
dompurify: {
profiles: {
profileName: {
ALLOWED_TAGS: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
}
}
},
})
To use a specific profile, you can pass the profile name as an argument to the v-sanitize-html
directive:
<template>
<div v-sanitize-html:profileName="dirtyHTML" />
</template>
<script setup>
const dirtyHtml = `
<div>
<h1>Welcome to My Website</h1>
<h3>This is H3 heading</h3>
<p>This is a <strong>simple</strong> paragraph.</p>
<img src="image.jpg" onerror="alert('Hacked!')" />
<a href="https://example.com" onclick="stealCookies()">Click me!</a>
<script>alert('This is an XSS attack!')</` + `script>
</div>`
</script>
We welcome contributions to Nuxt DOMPurify
. Please follow these steps to get started:
Enable Corepack: Ensure Corepack is enabled by running:
corepack enable
Install Dependencies: Install all necessary dependencies by running:
yarn install
Generate Type Stubs: Run the following command to generate type stubs:
yarn dev:prepare
Start Development Mode: Use the following command to start the playground in development mode:
yarn dev
This project is licensed under the MIT License. See the LICENSE file for more details.
FAQs
A Nuxt 3 module that integrates DOMPurify for sanitizing HTML content and protecting against XSS attacks, with support for multiple profiles.
The npm package @radya/nuxt-dompurify receives a total of 227 weekly downloads. As such, @radya/nuxt-dompurify popularity was classified as not popular.
We found that @radya/nuxt-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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.