@cs-au-dk/jelly

中文文档
0.13.0发布于 2026/05/11BSD-3-Clause近 30 天下载 3530

Jelly - call graph and library usage analyzer for JavaScript

原始使用文档
文档目录9 节
  1. Installing
  2. Usage
  3. How to build
  4. Docker
  5. Server-mode
  6. Approximate interpretation
  7. Indirection bounding
  8. Dynamic call graph construction
  9. For developers

Jelly

License npm version

Jelly is a static analyzer for performing

  • call graphs construction,
  • library usage pattern matching, and
  • vulnerability exposure analysis

for JavaScript (and TypeScript) programs that use the Node.js platform.

The analyzer design is based on ideas from JAM [1], TAPIR [2] and ACG [3] with support for approximate interpretation [4] and indirection-bounding [5]. Its core is a flow-insensitive control-flow and points-to analysis, together with access paths for tracking library usage. It models the main parts of the ECMAScript language and standard library (intentionally not fully soundly!), and (for now) treats the Node.js standard library as unknown code.

[1] Benjamin Barslev Nielsen, Martin Toldam Torp, Anders Møller: Modular call graph construction for security scanning of Node.js applications. Proc. ISSTA 2021: 29-41

[2] Anders Møller, Benjamin Barslev Nielsen, Martin Toldam Torp: Detecting locations in JavaScript programs affected by breaking library changes. Proc. ACM Program. Lang. 4(OOPSLA): 187:1-187:25 (2020)

[3] Asger Feldthaus, Max Schäfer, Manu Sridharan, Julian Dolby, Frank Tip: Efficient construction of approximate call graphs for JavaScript IDE services. Proc. ICSE 2013: 752-761

[4] Mathias Rud Laursen, Wenyuan Xu, Anders Møller: Reducing Static Analysis Unsoundness with Approximate Interpretation. Proc. ACM Program. Lang. 8(PLDI): 194:1-194:24 (2024)

[5] Madhurima Chakraborty, Aakash Gnanakumar, Manu Sridharan, Anders Møller: Indirection-Bounded Call Graph Analysis Proc. ECOOP 2024: 27:1-27:27

Installing

npm install -g @cs-au-dk/jelly

Other options are described below at How to build.

Usage

See the full usage:

jelly --help

When running the Jelly static analyzer, one or more entry files are given as input. Directories are expanded (using heuristics to skip certain files and directories, see files.ts). All files reachable from entry files are analyzed, except if option --ignore-dependencies is used, in which case only entry files are analyzed, and only files within the base directory (auto-detected or specified using option --basedir or -b) are included.

As an example, generate a call graph for the winston package and all its dependencies, both in JSON format and for HTML visualization:

jelly -j cg.json -m cg.html node_modules/winston

Viewing cg.html in a browser:

call graph visualization

To set the heap limit, prefix commands by, for example:

NODE_OPTIONS=--max-old-space-size=8192

On Linux, the vm.max_map_count system setting also affects how much memory can be used. If changing --max-old-space-size in the Node.js options doesn't help, try running sysctl vm.max_map_count to see the current setting. On a machine with, for example, 64GB RAM, you can change the limit with sudo sysctl -w vm.max_map_count=524288.

Note that analyzing with all dependencies (i.e., not using --ignore-dependencies) can take a long time. The options --max-indirections or --timeout can be used to terminate the analysis early to provide partial (unsound) results.
Specific packages can also be included or excluded using --include-packages or --exclude-packages.

How to build

Install dependencies:

npm install

Compile TypeScript code:

npm run build

After compilation, Jelly can be run like this:

node lib/main.js

Build binary executables (optional), placed in dist/:

sudo npm install -g pkg
npm run pkg

Note that the binary executables do not support dynamic call graph construction.

Docker

Build Docker image (including support for dynamic call graph construction):

npm run build-docker

Run Jelly in Docker with the directory specified as first argument as current working directory:

./bin/jelly-docker . tests/helloworld/app.js --callgraph-html cg.html

Server-mode

Jelly can be run in server-mode as an alternative to the command-line interface:

jelly-server

or

node lib/server.js

See also the instructions above for how to build binary executables.

Requests to the server are sent on stdin using the JSON format described in src/typings/ipc.ts. Responses are returned (asynchronously) on stdout with the two-line header (including the empty line)

Content-Length: <bytes>

with \r\n linebreaks.

Approximate interpretation

To enable static analysis with approximate interpretation (see reference [4] above), use option --approx:

jelly --approx tests/helloworld/app.js

(This example assumes you have first installed test dependencies by running npm run tests-install.) Alternatively, you can run approximate interpretation and static analysis separately using options --approx-only and --approx-load:

jelly --approx-only hints.json tests/helloworld/app.js
jelly --approx-load hints.json tests/helloworld/app.js

Indirection bounding

To enable indirection bounding (see reference [5] above), use option --max-indirections:

jelly --max-indirections 2 tests/helloworld/app.js

Dynamic call graph construction

Jelly supports dynamic call graph construction via NodeProf, which can be used for measuring recall (or unsoundness) of the static analysis.

Install NodeProf (see also the information about Docker above):

sudo dnf install g++ libstdc++-static
mkdir -p ~/tools; cd ~/tools
git clone --depth 1 --branch 6.0.4 https://github.com/graalvm/mx.git
export PATH=$PATH:$HOME/tools/mx
mx -y fetch-jdk --java-distribution labsjdk-ce-17
export JAVA_HOME=$HOME/.mx/jdks/labsjdk-ce-17-jvmci-22.2-b01
git clone --depth 1 https://github.com/Haiyang-Sun/nodeprof.js.git
cd nodeprof.js
mx sforceimports
mx --dy /compiler build

As an example, run tests/micro/classes.js or tests/helloworld/app.js with instrumentation for call graph construction:

export GRAAL_HOME=$HOME/tools/graal/sdk/latest_graalvm_home

jelly tests/micro/classes.js -d cg.json
jelly tests/helloworld/app.js -d cg.json

Extra arguments to the JavaScript program can be added after --.

It is also possible to run npm test with instrumentation:

jelly --npm-test tests/mochatest -d cg.json

Another approach is to add $JELLY_HOME/lib/bin/node to PATH and set JELLY_OUT, for example to run Mocha directly:

cd tests/mochatest
PATH=$JELLY_HOME/bin:$PATH JELLY_OUT=cg.json node_modules/.bin/mocha

where JELLY_HOME is the home directory of Jelly. This results in a file cg.json-<PID> for each instrumented file that is executed.

Call graphs (generated either statically or dynamically) can be compared for precision and recall:

jelly --compare-callgraphs cg1.json cg2.json

For developers

Compile TypeScript code in watch mode:

npm run build-watch

Install as scripts (jelly and jelly-server) for development:

sudo npm link

Install dependencies for tests:

npm run tests-install

Run all tests:

npm test

Run individual tests (specified by regex), for example:

npm test -- -t tests/helloworld

To enable source map transformation of stack traces, prefix commands by:

NODE_OPTIONS=--enable-source-maps

版本与发布记录

@cs-au-dk/jelly 共发布 8 个版本,首次发布于 2023/02/20;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.13.0latest2026/05/116 个月前
0.12.02025/12/0411 个月前
0.11.02025/09/191.1 年前
0.10.02024/07/122 年前
0.9.02024/04/052 年前
0.8.02024/02/062 年前

关于 @cs-au-dk/jelly 的常见问题

@cs-au-dk/jelly 是什么?

Jelly - call graph and library usage analyzer for JavaScript

如何安装 @cs-au-dk/jelly?

在项目目录运行 npm install @cs-au-dk/jelly,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 jelly、jelly-server,可以用 npx jelly 直接运行。

@cs-au-dk/jelly 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cs-au-dk__jelly 是否存在。

@cs-au-dk/jelly 需要什么版本的 Node.js?

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

@cs-au-dk/jelly 可以商用吗?

@cs-au-dk/jelly 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@cs-au-dk/jelly 的下载量有多少?

根据 npm 官方下载统计,@cs-au-dk/jelly 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,530 次,日均约 118 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cs-au-dk/jelly 还在维护吗?

最新版本 0.13.0 发布于 2026/05/11(6 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/02/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。