Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qbit/node-pledge
Bindings for for OpenBSD's pledge(2)
https://github.com/qbit/node-pledge
Last synced: about 1 month ago
JSON representation
Bindings for for OpenBSD's pledge(2)
- Host: GitHub
- URL: https://github.com/qbit/node-pledge
- Owner: qbit
- License: isc
- Created: 2015-10-20T22:52:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T18:56:17.000Z (about 2 years ago)
- Last Synced: 2024-05-14T08:02:02.281Z (7 months ago)
- Language: C++
- Size: 22.5 KB
- Stars: 19
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pledge - node-pledge
README
node-pledge
===========Bindings for for OpenBSD's [pledge(2)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/pledge.2?query=pledge)
# What?
`pledge(2)` allows a process to ratchet down the privileges it requires to run, if it attempts to access
a privilege it has pledged to not use, it will be killed by the kernel.# Example Usage
Install via npm:
```
npm install --save node-pledge
``````JavaScript
var http = require('http');
var pledge = require('node-pledge');pledge.init("stdio rpath wpath prot_exec");
console.log("stuff");
// try to do something with http (will cause the kernel to kill node)
http.get("http://www.google.com/", function(res) {
console.log(res);
}).on('error', function(e) {
console.log(e);
});
```Output:
```
node stuff.js
stuff
Abort trap (core dumped)
```Line from `dmesg(8)`:
```
node(24353): sysctl 6: 4 17 0 0 3 0
node(24353): syscall 202 ""
```# This is an expirement!
Use at your own risk! It will *ONLY* work on OpenBSD!