deepseek-harness/native/landlock-run
2026-07-29 15:29:24 +08:00
..
docs docs(landlock-run): align source and release guidance 2026-07-20 12:25:43 +08:00
packages docs(i18n): proofread README translations 1-20 2026-07-29 15:29:24 +08:00
scripts chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
test fix(landlock-run): enforce probe CLI contract 2026-07-20 12:25:36 +08:00
.gitignore chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
AGENTS.md chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
LICENSE chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
package.json Merge branch 'master' into dependabot/npm_and_yarn/native/landlock-run/types/node-26.0.1 2026-07-28 12:23:28 +08:00
pnpm-lock.yaml Merge branch 'master' into dependabot/npm_and_yarn/native/landlock-run/types/node-26.0.1 2026-07-28 12:23:28 +08:00
pnpm-workspace.yaml chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
README.i18n.yaml docs: translate remaining READMEs 2026-07-26 05:06:39 +08:00
README.md docs: translate remaining READMEs 2026-07-26 05:06:39 +08:00
README.zh.md docs(i18n): proofread README translations 1-20 2026-07-29 15:29:24 +08:00
tsconfig.base.json chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00
tsconfig.json chore: adopt node-addon-landlock-run source as native/ subtree 2026-07-14 23:39:58 +08:00

node-addon-landlock-run

English | 中文

A Landlock self-restrict-then-exec launcher for confining subprocesses on Linux, distributed as prebuilt per-platform npm packages plus a thin JS entry package that resolves the binary and speaks its CLI contract. Built for agent harnesses and other hosts that need to run untrusted commands under a filesystem allow-list without confining themselves.

The first tool is landlock-run — a self-restrict-then-exec Landlock launcher (~300 lines of C11 over the raw kernel UAPI, statically linked against musl). It installs a Landlock ruleset on itself and execs the wrapped command; the ruleset is inherited across execve, so the command and every process it spawns run confined while the invoking process stays unrestricted. Fail-closed: if the kernel cannot enforce, it exits without running the command.

Install

npm install node-addon-landlock-run

Published packages use an entry package plus platform optional packages:

node-addon-landlock-run
node-addon-landlock-run-linux-x64
node-addon-landlock-run-linux-arm64

npm's os/cpu fields make installers fetch only the matching platform package. There is no install-time build fallback on purpose: on a host without a platform package the resolved path never exists, the probe reports unusable, and the consumer falls closed.

Usage

import { grantArgs, launcherPath, probe } from 'node-addon-landlock-run';

const launcher = launcherPath();
if (probe(launcher) !== 'unusable') {
  const argv = [launcher, ...grantArgs({ readOnly: ['/'], readWrite: ['/tmp/work'] }), '--', 'bash', '-c', command];
  // spawn argv with your process runner of choice
}

The public API is intentionally small:

  • launcherPath(): absolute path of this host's launcher (existence deliberately unchecked — the probe is the availability signal).
  • probe(launcher?, { timeoutMs? }): functional enforcement probe — 'full' | 'partial' | 'unusable'.
  • grantArgs({ readOnly?, readWrite? }): the launcher's grant argv; everything not granted is denied.
  • LAUNCHER_BIN, LAUNCHER_FAILURE_EXIT (125): contract constants.

The full binary contract (argv grammar, exit codes, report lines) is pinned in docs/cli-contract.md.

Support

linux-x64 and linux-arm64, kernel with Landlock enabled (5.13+; ABI level determines full vs partial enforcement — see docs/support-matrix.md). Other platforms deliberately have no package: consumers run different confinement backends there.

Development

corepack enable
pnpm install
pnpm build:ts        # entry packages → lib/
pnpm build:native    # this Linux architecture's binaries (apt-get install musl-tools)
pnpm test

Binaries are git-ignored and built natively per architecture — locally for your own machine, by CI's per-arch runners as the builders of record. Release flow: docs/release.md.