Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xss-cross-detection

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xss-cross-detection

This package facilitates the filtration of input text susceptible to server-side exploitation. It encompasses a model trained on a dataset comprising approximately 6,000 XSS-attack scripts to categorize the input into two predefined classes: vulnerable an

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by17.39%
Maintainers
1
Weekly downloads
 
Created
Source

Xss-cross-detection

Description

This package helps to filter the input text that is vulnerable 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 vulnerable and immune 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 vulnerable data present in database.

Install

npm install --save xss-cross-detection

Usage

const attackDetection = require('xss-cross-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: 'vulnerable', 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'], null, null));

// Expected Output
[
{ gist: 'vulnerable', confidenceFactor: 99.99999997227279 },
{ gist: 'immune', 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":1
    },
    {
        "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": 2
      },
   
      ];
   
    console.log(xss_detect.classifyBatch(testingDocs, "k")); // k is primary key

//expected Outlet
[
 {
   input: { gist: 'vulnerable', confidenceFactor: 99.99999999285946 },
   anotherField: { gist: 'immune', confidenceFactor: 98.41886759120219 },
   primaryKey: 2
 },
 {
   input: { gist: 'immune', confidenceFactor: 99.99999999834742 },
   anotherField: { gist: 'immune', confidenceFactor: 91.66666666666666 },
   primaryKey: 6
 }
]

Extra/Optional Arguments

S.no NameTypeHow it Works
1primary keyStringthis 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
2Fields to CheckArraythis 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

Contributors Details

S.no NameContact Info
1Kundan Kumarkundansingh023230@gmail.com

License

ISC

Keywords

FAQs

Package last updated on 20 May 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc