Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 9, 2024 via pnpm

xss 1.0.14

Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist
Package summary
Share
0
issues
1
license
3
MIT
Package created
19 Sep 2012
Version published
16 Aug 2022
Maintainers
1
Total deps
3
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
commander@2.20.3
cssfilter@0.0.10
xss@1.0.14
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of xss 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
commander2.20.318.26 kBMIT
prod
cssfilter0.0.107.28 kBMIT
prod

Visualizations

Frequently Asked Questions

What does xss do?

The xss package is a popular JavaScript library utilized for the prevention of Cross-Site-Scripting(XSS) attacks. Its main function is to sanitize untrusted HTML input based on a whitelist of acceptable HTML tags and attributes. This helps in maintaining the security of your web applications by preventing malicious scripts from being injected and executed on the client-side.

How do you use xss?

To use the xss package in your JavaScript project, first, you need to install it from npm using the following code:

npm install xss

You can then require and utilize the xss function like the example given below:

var xss = require("xss");
var html = xss('<script>alert("xss");</script>');
console.log(html);

In the example, the xss function is sanitizing the input HTML string to ensure no harmful scripts are embedded within it.

If you're using the xss package in a browser environment, the setup is slightly different. Reference the xss.js file in a script tag, then use the filterXSS function similarly to the xss function from the Node.js example.

<script src="https://rawgit.com/leizongmin/js-xss/master/dist/xss.js"></script>
<script>
  var html = filterXSS('<script>alert("xss");</script>');
  alert(html);
</script>

Remember not to use this URL in a production environment.

Where are the xss docs?

The documentation for the xss package can be found in its GitHub repository readme. More detailed information about features, custom filter rules, default whitelist, and examples of usage can be found here. The API reference, including detailed explanations of the onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, and the custom escaping function, is described in detail in the readme.