Files
klz-cables.com/.pnpm-store/v10/files/f4/8705b2b43dada485910f9641703f1a5bf28c92ce362c7ca777ef52b97fbb0db9d3ff0844244f25300330126af79642a70c33a324e9a81bc14acd0ffb66ef1e
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

46 lines
1.5 KiB
Plaintext

/**
* Validate SVG content for security vulnerabilities
* Detects and blocks malicious patterns commonly used in SVG-based attacks
*/ export function validateSvg(buffer) {
try {
const content = buffer.toString('utf8');
const dangerousPatterns = [
// Script tags
/<script[\s>]/i,
/<\/script>/i,
// Event handlers (onclick, onload, onerror, etc.)
/\son\w+\s*=/i,
// JavaScript URLs
/javascript:/i,
/data:text\/html/i,
// Foreign objects (can embed HTML)
/<foreignObject[\s>]/i,
// Embedded iframes
/<iframe[\s>]/i,
// Embedded objects and embeds
/<object[\s>]/i,
/<embed[\s>]/i,
// Base64 encoded scripts (common obfuscation technique)
/data:image\/svg\+xml;base64,[\w+/]*PHNjcmlwdA/i,
// XLink href with javascript (deprecated but still dangerous)
/xlink:href\s*=\s*["']javascript:/i,
// Import statements
/@import/i,
// External resource references that could be dangerous
/<!ENTITY/i,
/<!DOCTYPE[^>]*\[/i,
// Attempt to use CDATA to hide scripts
/<!\[CDATA\[[\s\S]*<script/i
];
for (const pattern of dangerousPatterns){
if (pattern.test(content)) {
return false;
}
}
return true;
} catch (_error) {
return false;
}
}
//# sourceMappingURL=validateSvg.js.map