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

httptables

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httptables

HTTP firewall

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

HTTPTables

Important Note

Do not use yet in production This module won't probably be heavily maintained. Fork at will or claim ownership ! Okay now you can keep reading :)

Module Status

NPM version Build status Dependency Status devDependency Status Coverage Status Code Climate

Description

Kind of a firewall for http requests based on headers. It parses a set of rules for each HTTP header and apply the matching policy

Usage

NB: This module makes the assumption your request object looks like this

req = {
  headers : {
    'method' : 'PUT',
    'url' : '/kung/foo/panda/',
    'any-other-header' : 'of_any_value'
  }
}

If it does not, use the setAccessFieldFunction (look around the end of this readme to see an example)

Example 1: a rule could be represented as such

rule = {
  policy : HTTPTables.policies.DROP,
  conditions : {
    'method' : ['POST', 'GET'],
    'user-agent' : /Android/,
    'url' : "/api/v2/users/1"
  }
}

In this case it will drop every POST or GET requests from android on /api/v2/users/1 url

var HTTPTables = require('httptables');
var httptables = HTTPTables({
  defaultPolicy : HTTPTables.policies.DROP // Drop all not matching requests
})

Example 2: In Express

var HTTPTables = require('httptables');
var httptables = HTTPTables({
  defaultPolicy : HTTPTables.policies.DROP // Drop all not matching requests
})
// Override the way to access a header field for an express request object
httptables.setAccessFieldFunction = function (req, field) {
  var _field = (field || "").toUpperCase();
  if(field === 'URL') {
    return req.url;
  } else if(field === 'METHOD') {
    return req.method;
  } else {
    return req.get(field);
  }
}
//...
//...
//...
app.use(function (req, res, next) {
  req.mySetOfRules = [
    {
      policy : HTTPTables.policies.ACCEPT,
      conditions : {
        'method' : ['POST', 'GET'],
        'user-agent' : /Android/,
        'url' : "/api/v2/users/1"
      }
    },
    {
      policy : HTTPTables.policies.ACCEPT,
      conditions : {
        'method' : ['POST', 'GET', 'PUT', 'DELETE'],
        'url' : "/api/v2/organizations/1/billing"
      }
    }
  ];
  next();
})

// Comming Soon, see commented code in source to implement yourself
// only if you want/need
app.use(httptables.toExpressMiddleware({rulesPropertyName : 'mySetOfRules'}))

FAQs

Package last updated on 28 Jan 2015

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