Performance oriented safeguard for all possible XSS attacks
Click on 🌟 button.
- Want to show your love?
- Table of Contents
- Installation
- Features
- Usage
- FAQ
- Contributing
- Support
- License
$ yarn add @mohalla-tech/xss-safeguard
OR
$ npm i @mohalla-tech/xss-safeguard --save
- URL sanitization (With express middleware for SSR) 💯
- Query Param Sanitization (Client Side) 💯
- String Sanitization 💯
- Input Sanitization 💯
Express Middleware for SSR
import express from 'express';
import { secure } from '@mohalla-tech/xss-safeguard';
const app = express();
// Default configuration
app.use(secure());
// Callback on xss attack
app.use(secure({ callback: () => {} }));
// Custom response handler when xss attack happens
app.use(
secure({
handleResponseCustom: res => {
res.redirect('/error');
},
})
);
Query Param Sanitization
import { getSafeSearchParam } from '@mohalla-tech/xss-safeguard';
// URL : https://sharechat.com?language=en
const sanitizedString = getSafeSearchParam('language');
console.log(sanitizedString); // en
// URL : https://sharechat.com?language=<script>alert("Hello")</script>
const sanitizedString = getSafeSearchParam('language');
console.log(sanitizedString); // scriptalertHello/script
String Sanitization
import { sanitizeString } from '@mohalla-tech/xss-safeguard';
const sanitizedString = sanitizeString('<script>Hello</script>');
console.log(sanitizedString);
Yes
To get started...
-
Option 1
- 🍴 Fork this repo!
-
Option 2
- 👯 Clone this repo to your local machine using
https://github.com/ShareChat/xss-safeguard
- 👯 Clone this repo to your local machine using
- HACK AWAY! 🔨🔨🔨
- 🔃 Create a new pull request using
https://github.com/ShareChat/xss-safeguard
.
Reach out to one of the following: