jamoy / node-policy

Apply a self-imposed sandbox on your CLI or dockerized Node.js apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-policies

Apply a self-imposed sandbox on your CLI or dockerized Node.js apps. You can use this library to augment the experimental Node 17 Policies feature.

This library will restrict

Policies

  • Inbound/Outbound Requests from Domains / DNS
  • Inbound/Outbound Websockets
  • File/Directory Access
  • Exec usage
  • Cluster (unreffed)
  • Workers
  • Process.ENV access
  • Integrity Checks
  • Import/Require

Policies File

Create a .policiesrc.json or a .policiesrc.js

{
    "extends": "...", 
    "onError": "log", // throw or exit
    "policies": {
        "inbound/http": [
            {
                access: 'deny',
                resources: '*',
            },
            {
                access: 'allow',
            }
        ]
    }
}

About

Apply a self-imposed sandbox on your CLI or dockerized Node.js apps

License:MIT License


Languages

Language:JavaScript 100.0%