npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xss-attack-detection

v1.0.4

Published

This package helps to filter the input text that is malicious and intended to attack the server.

Downloads

1,258

Readme

Description

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.

Install

npm install --save xss-attack-detection

Usage

const attackDetection = require('xss-attack-detection');
const xss_detect = new attackDetection.xssAttackDetection();

1. When input is simple string


console.log(xss_detect.detect("<script onload="alert()"></script>"));

// Expected Output
{ gist: 'malicious', confidenceFactor: 99.99999997227279 },

2. When input is array of string.

// 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 },
]

3. When input is array of object

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
 }
]

Extra/Optional Arguments

Contributors Details

License

ISC