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

xssfilter-js

v1.0.1

Published

Injection attack filter-to filter sensitive keywords in text or DOM elements to prevent XSS, command injection, and sql injection attacks

Downloads

4

Readme

injectFilter.js

注入攻击过滤器(兼容IE)-实现过滤文本或DOM元素中的敏感关键字防止XSS、命令注入、sql注入攻击

大小:4KB

NPM 地址:https://www.npmjs.com/package/xssfilter-js

Docs文档:

安装:

npm install xssfilter-js

options 配置项:

//创建一个InjectFilter对象,可传入options配置对象
var inf = new InjectFilter(options);


options.tokens = 可添加额外的自定义过滤字符,对象类型键值对
{'需要替换的目标字符':'字符1'} 
key为需要替换的字符,value为想要将目标字符替换成的字符。



options.xss = true; 
默认为true。 需为布尔值,是否启用过滤xss注入


options.command = true;
默认为true。 需为布尔值,是否启用过滤command(命令注入)



options.sql = true;
默认为true。 需为布尔值,是否启用过滤sql注入
注:命令和sql将过滤成对应的‘全角’文本(如select 、delete from、ping )

Demo:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="injectFilter.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
</head>
<body>
    <div id='aa' onclick="javascript:alert('hello world')">) or 1=1</div>
</body>
<script>
  var inf = new InjectFilter({tokens:{'or':'|||'}});
     $('#aa').html(inf.filter(document.getElementById('aa')))
</script>

</html>

ES6:

import injectFilter from './injectFilter';