当前位置: 首页 > 软件库 > Web应用开发 > >

protect

Proactively protect your Node.js web services
授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 虞裕
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Protect by RisingStack

Known Vulnerabilities

Works on Node.js v6 and newer.

The purpose of this module is to provide out-of-box, proactive protection for common security problems, likeSQL injection attacks, XSS attacks, brute force, etc...

This module is not a silver bullet, and is not a substitute for security-minded engineering work. But it can help you to achieve your goals.

protect by risingstack

Basic usage

npm i @risingstack/protect --save

With Express

const protect = require('@risingstack/protect')
const express = require('express')
const bodyParser = require('body-parser')
const redis = require('redis')

const client = redis.createClient()

const app = express()

app.use(bodyParser.json({
  extended: false
}))

app.use(protect.express.sqlInjection({
  body: true,
  loggerFunction: console.error
}))

app.use(protect.express.xss({
  body: true,
  loggerFunction: console.error
}))

app.use(protect.express.rateLimiter({
  db: client,
  id: (request) => request.connection.remoteAddress
}))

app.get('/', (request, response) => {
  response.send('hello protect!')
})

app.post('/login', protect.express.rateLimiter({
  db: client,
  id: (request) => request.body.email,
  // max 10 tries per 2 minutes
  max: 10,
  duration: 120000
}), (request, response) => {
  response.send('wuut logged in')
})

app.listen(3000)

API

protect.express.sqlInjection([options])

Returns an Express middleware, which checks for SQL injections.

  • options.body: if this options is set (true), the middleware will check for request bodies as well
    • default: false
    • prerequisite: you must have the body-parser module used before adding the protect middleware
  • options.loggerFunction: you can provide a logger function for the middleware to log attacks
    • default: noop

protect.express.xss([options])

Returns an Express middleware, which checks for XSS attacks.

  • options.body: if this options is set (true), the middleware will check for request bodies
    • default: false
    • prerequisite: you must have the body-parser module used before adding the protect middleware
  • options.loggerFunction: you can provide a logger function for the middleware to log attacks
    • default: noop

protect.express.rateLimiter([options])

Returns an Express middleware, which ratelimits

  • options.id: function that returns the id used for ratelimiting - gets the request as its' first parameter
    • required
    • example: (request) => request.connection.remoteAddress
  • options.db: redis connection instance
    • required
  • options.max: max requests within options.duration
    • default: 2500
  • options.max: of limit in milliseconds
    • default: 3600000
  • options.loggerFunction: you can provide a logger function for the middleware to log attacks
    • default: noop

protect.express.headers([options])

The headers object is a reference to the main helmet object exported.For docs on the options object, please refer to the helmet documentation.

Roadmap

Security Recommendations

As mentioned, this module isn't a silver bullet to solve your security issues completely. The following information is provided to hopefully point you in the right direction for solving other security concerns or alternatives that may be useful based on your budget or scale.

Other Aspects

There are plenty of other areas that you should be concerned about when it comes to security, that this module doesn't cover (yet or won't) for various reasons. Here are a few that are worth researching:

Resources

Dedicated WAF

If you have the resources available (budget or hosting environment), a dedicated WAF (Web Application Firewall) can offer a robust solution to various security issues, such as blocking potential attackers and flagging their activity.

  • protect修饰的方法只能在本类和子类中使用,其兄弟(父类的另一个孩子)不能使用,因此,大部分情况需要重写此方法。 重写: 重写方法的访问权限不能比父类被重写的方法访问权限更低

  • 不小心用了一下PC版旺旺,用完就卸载。没想到我等于沾到大便了。系统检查时,发现电脑被安装了AlibabaProtect服务,不能禁止不能删除不能停用,注册表相关配置被进程锁死不让修改,我他妈的动用了特殊手段才干掉这个服务,手工清理用了半小时,整体上坑了我一小时时间。真就没好东西。愿阿里早日被搞死。以下技巧不完全有效。仅供参考。 https://blog.csdn.net/banzhengyu/ar

  • 1.卸载阿里系软件 2.全局搜索pc sdk set,删除所在阿里目录 3.强制删除alibabaprotect所在目录

相关阅读

相关文章

相关问答

相关文档