@datadog/native-appsec

中文文档
12.0.0发布于 2026/11/10Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 5072.8万

Node.js bindings for libddwaf

原始使用文档

dd-native-appsec-js

Node.js bindings for libddwaf.

Supported platforms

This package supports the following platforms:

  • Node.js version: 18 and higher
  • Operating Systems:
    • macOS 14.2.1 and higher (the minimum target of the bundled libddwaf)
      • x64
      • arm64
    • Windows
      • x86
      • x64
    • Linux
      • x64 with glibc
      • x64 with musl
      • arm64

Therefore, unsupported platforms include:

  • Linux x86
  • arm32
  • AIX
  • PPC

Please feel free to contact support if you would like to request support for a new platform.

Migrating to native-appsec 12

This version bundles libddwaf 2.2.0 and changes the evaluation API. context.run(data, timeout) now receives an address map directly. The previous { persistent, ephemeral } envelope is no longer supported. For scoped data, create a subcontext with context.createSubcontext(), call its run(data, timeout) method, and dispose it in finally. A subcontext inherits parent data and keeps its own data and evaluation effects local. It can outlive the parent.

createContext() returns null when there is no active ruleset, including after removing all configurations. A rejected same-path replacement can also remove the previous configuration; callers must check diagnostics and configuration paths when deciding whether to restore a fallback ruleset. Rejected map configurations are fully removed from the builder, including their paths and any partially loaded content. Top-level parsing failures are reported in diagnostics.error. If a rebuild produces no handle, new contexts also return null; the binding does not distinguish an empty ruleset from other build failures or retain a stale handle.

Durations are nanoseconds; timeout inputs are microseconds. Actions are a map keyed by action type.

Responsibilities

native-appsecdd-trace-js
Native handles, allocators, finalizers and safe marshallingRequest and operation lifetimes, including explicit disposal
Context and subcontext evaluation primitivesPersistent/scoped input routing, evaluation order and shared timeout budgets
Raw results, diagnostics and truncation measurementsResult aggregation, blocking, reporting and telemetry
Configuration binding and argument validationRemote Config orchestration, fallback policy and known-address filtering

The dd-trace-js dependency upgrade must ship with the companion API migration. Mixed persistent and scoped evaluations need explicit result aggregation and a shared time budget in the tracer. The native binding does not infer those policies.

Conversion and configuration limits

Evaluation data is limited to 4096 bytes per string, 256 entries per container, and 20 levels of nesting. String truncation preserves complete UTF-8 code points. Truncation metrics report original sizes. dd-trace-js owns exporting those measurements.

Configuration containers are not subject to the request size limit. libddwaf 2.1's large-container APIs support configuration arrays and maps beyond 65535 entries.

Obfuscator configuration is passed directly to libddwaf. The binding reports the builder result and diagnostics without additional regex validation.

版本与发布记录

@datadog/native-appsec 共发布 53 个版本,首次发布于 2021/09/23;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
12.0.0latest2026/11/10今天
11.0.32026/10/051 个月前
11.0.22026/08/132 个月前
11.0.12026/02/198 个月前
11.0.02025/11/031 年前
10.3.02025/10/151.1 年前

关于 @datadog/native-appsec 的常见问题

@datadog/native-appsec 是什么?

Node.js bindings for libddwaf

如何安装 @datadog/native-appsec?

在项目目录运行 npm install @datadog/native-appsec,或使用 pnpm add / yarn add / bun add。

@datadog/native-appsec 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@datadog/native-appsec 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@datadog/native-appsec 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@datadog/native-appsec 可以商用吗?

@datadog/native-appsec 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@datadog/native-appsec 的下载量有多少?

根据 npm 官方下载统计,@datadog/native-appsec 在 2026/10/12 – 2026/11/10 这 30 天内被下载 50,727,775 次,日均约 1,690,926 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@datadog/native-appsec 还在维护吗?

最新版本 12.0.0 发布于 2026/11/10(今天);至今共发布 53 个版本,其中过去 12 个月发布了 4 个;首次发布于 2021/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。