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 🙏

© 2025 – Pkg Stats / Ryan Hefner

landlock

v0.0.1

Published

A binding to Linux's landlock security module for node.js

Readme

Description

A binding to Linux's Landlock security module for node.js.

Supports Landlock ABI versions 1-7.

Information on feature availability per ABI version can be found here.

Requirements

  • Linux kernel v5.13+
    • CONFIG_SECURITY_LANDLOCK=y
    • One or both of:
      • CONFIG_LSM contains the value: landlock
      • The kernel command line parameter lsm contains the value: landlock
  • node.js -- v10.x or newer
  • An appropriate build environment -- see node-gyp's documentation

Installation

npm install landlock

Examples

  • Disallow reading or writing of any file (note: files can still be created if the filesystem allows, but they will not be able to be written to)
const fs = require('fs');

const landlock = require('landlock');

const fd = landlock.createRuleset(
  landlock.constants.LANDLOCK_ACCESS_FS_READ_FILE
    | landlock.constants.LANDLOCK_ACCESS_FS_WRITE_FILE
    | landlock.constants.LANDLOCK_ACCESS_FS_TRUNCATE_FILE
);
landlock.setNoNewPrivs();
landlock.restrictSelf(fd);
landlock.close(fd);

// Throws
fs.readFileSync(__filename);

// Throws, but creates a zero-length file
fs.writeFileSync('test.txt', 'foo');
  • Disallow execution of any file outside of /usr/bin
const { execFileSync } = require('child_process');

const landlock = require('landlock');

const fd = landlock.createRuleset(
  landlock.constants.LANDLOCK_ACCESS_FS_EXECUTE
);
landlock.addRule(
  fd,
  landlock.constants.LANDLOCK_RULE_PATH_BENEATH,
  landlock.constants.LANDLOCK_ACCESS_FS_EXECUTE,
  '/usr/bin'
);
landlock.setNoNewPrivs();
landlock.restrictSelf(fd);
landlock.close(fd);

// Throws
console.log(
  execFileSync('/usr/local/bin/node', [ '-v' ], { encoding: 'utf8' })
);

API

Exports

  • addRule(< integer >fd, < mixed >ruleType[, ...ruleTypeArgs]) - (void) - Adds a new rule to a ruleset. ruleType can be an integer or bigint. ...ruleTypeArgs depends on ruleType:

    • LANDLOCK_RULE_PATH_BENEATH: < mixed >allowedAccess, < mixed >parent - allowedAccess is an integer or bigint bitmask of allowed actions for this file hierarchy. parent is either a string path or a integer file descriptor which identifies the parent directory of a file hierarchy, or just a file.

    • LANDLOCK_RULE_NET_PORT: < integer >allowedAccess, < integer >port - allowedAccess is an integer or bigint bitmask of allowed actions for this file hierarchy. port is a network port.

  • close(< integer >fd) - (void) - Closes the given file descriptor.

  • constants - object - Contains useful Landlock constants, all named the same as the original C macros. All values are of type bigint.

  • createRuleset(< mixed >fsAccess[, < mixed >netAccess[, < mixed >scoped]]) - integer - Creates a new ruleset and returns the resulting file descriptor. All values can be either an integer or bigint.

  • getABI() - integer - Returns the highest supported Landlock ABI version (starting at 1).

  • getErrata() - bigint - Returns a bitmask of fixed issues for the current Landlock ABI version.

  • restrictSelf(< integer >fd[, < mixed >flags]) - (void) - Enforce a ruleset on the calling thread. flags can be an integer or bigint.

  • setNoNewPrivs() - (void) - Enables no_new_privs mode.