XSS Safeguard
Performance oriented safeguard for all possible XSS attacks
Made with ❤️ by developers for developers
Want to show your love?
Click on 🌟 button.
Table of Contents
Installation
$ yarn add @mohalla-tech/xss-safeguard
OR
$ npm i @mohalla-tech/xss-safeguard --save
Features
- URL sanitization (With express middleware for SSR) :100:
- Query Param Sanitization (Client Side) :100:
- String Sanitization :100:
- Input Sanitization :100:
Usage
Express Middleware for SSR
import express from 'express';
import { secure } from '@mohalla-tech/xss-safeguard';
const app = express();
app.use(secure());
app.use(secure({ callback: () => {} }));
app.use(
secure({
handleResponseCustom: res => {
res.redirect('/error');
},
})
);
Query Param Sanitization
import { getSafeSearchParam } from '@mohalla-tech/xss-safeguard';
const sanitizedString = getSafeSearchParam('language');
console.log(sanitizedString);
const sanitizedString = getSafeSearchParam('language');
console.log(sanitizedString);
String Sanitization
import { sanitizeString } from '@mohalla-tech/xss-safeguard';
const sanitizedString = sanitizeString('<script>Hello</script>');
console.log(sanitizedString);
FAQ
Is it supported and tested both on web and mobile?
Yes
Contributing
To get started...
Step 1
-
Option 1
-
Option 2
- 👯 Clone this repo to your local machine using
https://github.com/ShareChat/xss-safeguard
Step 2
Step 3
Support
Reach out to one of the following:
License