
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
xss-attack-detection
Advanced tools
This package helps to filter the input text that is malicious and intended to attack the server.
This package helps to filter the input text that is malicious and intended to attack the server.It contains model that is trained on a dataset of around 6k XSS-attack scripts to classify the input into 2 pre-defined labels i.e malicious and benign and this package has the ability to deal with different types of input like JSON Objects, string array, singular string, Object Array that could be helpful to filter malicious data present in database.
npm install --save xss-attack-detection
const attackDetection = require('xss-attack-detection');
const xss_detect = new attackDetection.xssAttackDetection();
console.log(xss_detect.detect("<script onload="alert()"></script>"));
// Expected Output
{ gist: 'malicious', confidenceFactor: 99.99999997227279 },
// To Deal with array as input we have different method named as classifyBatch.
console.log(xss_detect.classifyBatch(["<script onload="alert()"></script>","Hello, how are you"));
// Expected Output
[
{ gist: 'malicious', confidenceFactor: 99.99999997227279 },
{ gist: 'benign', confidenceFactor: 99.98769997227279 },
]
var testingDocs = [
{
"input": "<script draggable=\"true\" ondragstart=\"alert(1)\">test</script>",
"anotherField":'lets go ',
"k":2
},
{
"input": "Go until script jurong point, crazy.. Available only in bugis n great world la e buffet... Cine there got amore wat...",
"anotherField":'Hello how are you',
"k": 6
},
];
console.log(d.classifyBatch(test,"k")); // k is primary key
//expected Outlet
[
{
input: { gist: 'malicious', confidenceFactor: 99.99999999285946 },
anotherField: { gist: 'benign', confidenceFactor: 98.41886759120219 },
primaryKey: 2
},
{
input: { gist: 'benign', confidenceFactor: 99.99999999834742 },
anotherField: { gist: 'benign', confidenceFactor: 91.66666666666666 },
primaryKey: 6
}
]
| S.no | Name | Type | How it Works |
|---|---|---|---|
| 1 | primary key | String | this will help in adding new key to result which can uniquely identify the document in array.It can be passed as second argument in classifyBatch function |
| 2 | Fields to Check | Array | this will help is saving time by avoiding brute force checking to only specific fields checking. it can be passed as third argument in classifyBatch function |
| S.no | Name | Contact Info |
|---|---|---|
| 1 | Harshit Kohli | harshit.kohli1997@gmail.com |
| 2 | Sagar Bilwal | bilwal.sagar@gmail.com |
| 3 | Abhinav Jain | jabhi678@gmail.com |
| 4 | Pranay Anand | pranayanand123@gmail.com |
ISC
FAQs
This package helps to filter the input text that is malicious and intended to attack the server.
The npm package xss-attack-detection receives a total of 236 weekly downloads. As such, xss-attack-detection popularity was classified as not popular.
We found that xss-attack-detection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.