@appthreat/atom

中文文档
3.2.1发布于 2026/10/28MITES Module零依赖构建来源已验证近 30 天下载 140.7万

Create atom (⚛) representation for your application, packages and libraries

原始使用文档
文档目录10 节
  1. Usage
  2. Languages supported
  3. CLI Usage
  4. Sample Invocations
  5. Generate an atom
  6. Create reachables slice for a java project.
  7. Environment variables
  8. Troubleshooting
  9. atom file is incomplete for large projects
  10. License

Atom npm wrapper

Atom is a novel intermediate representation for applications and a standalone tool powered by the chen library. The intermediate representation (a network with nodes and links) is optimised for operations typically used for application analytics and machine learning, including slicing and vectoring.

This package wraps the atom Java distributable and makes it available via the npm package registry. Ensure Java 21 is available in the PATH.

Usage

npm install @appthreat/atom

For a broader language support, also install @appthreat/atom-parsetools.

npm install -g @appthreat/atom-parsetools

Languages supported

  • C/C++
  • H (C/C++ Header and pre-processed .i files alone)
  • Java (Requires compilation)
  • Jar
  • Android APK (Requires Android SDK. Set the environment variable ANDROID_HOME or use the container image.)
  • JavaScript
  • Flow
  • TypeScript
  • Python (Supports 3.x to 3.14)
  • PHP (Requires PHP >= 7.4. Supports PHP 7.0 to 8.5 with limited support for PHP 5.x)
  • Ruby (Requires a Ruby runtime with the rbastgen generator; the grammar is chosen by capability, not by the runtime version, so Ruby 1.8 - 4.0.x syntax is supported on any supported runtime)
  • Scala (WIP)

CLI Usage

Usage: atom [parsedeps|data-flow|usages|reachables] [options] [input]

  input                    source file or directory
  -o, --output <value>     output filename. Default app.⚛ or app.atom in windows
  -s, --slice-outfile <value>
                           export intra-procedural slices as json
  -l, --language <value>   source language
  --with-data-deps         generate the atom with data-dependencies - defaults to `false`
  --remove-atom            do not persist the atom file - defaults to `false`
  --reuse-atom             reuse existing atom file - defaults to `false`
  -x, --export-atom        export the atom file with data-dependencies to graphml - defaults to `false`
  --export-dir <value>     export directory. Default: atom-exports
  --file-filter <value>    the name of the source file to generate slices from. Uses regex.
  --method-name-filter <value>
                           filters in slices that go through specific methods by names. Uses regex.
  --method-parameter-filter <value>
                           filters in slices that go through methods with specific types on the method parameters. Uses regex.
  --method-annotation-filter <value>
                           filters in slices that go through methods with specific annotations on the methods. Uses regex.
  --max-num-def <value>    maximum number of definitions in per-method data flow calculation - defaults to 2000
Command: parsedeps
Extract dependencies from the build file and imports
Command: data-flow [options]
Extract backward data-flow slices
  --slice-depth <value>    the max depth to traverse the DDG for the data-flow slice - defaults to 7.
  --sink-filter <value>    filters on the sink's `code` property. Uses regex.
Command: usages [options]
Extract local variable and parameter usages
  --min-num-calls <value>  the minimum number of calls required for a usage slice - defaults to 1.
  --include-source         includes method source code in the slices - defaults to false.
  --extract-endpoints      extract http endpoints and convert to openapi format using atom-tools - defaults to false.
Command: reachables [options]
Extract reachable data-flow slices based on automated framework tags
  --source-tag <value>     source tag - defaults to framework-input. Comma-separated values allowed.
  --sink-tag <value>       sink tag - defaults to framework-output. Comma-separated values allowed.
  --include-crypto         includes crypto library flows - defaults to false.
  --help                   display this help message

Sample Invocations

Generate an atom

# Compile java project
atom -o app.atom -l java .
atom -o app.atom -l jar <jar file>
export ANDROID_HOME=<path to android sdk>
atom -o app.atom -l apk <apk file>

Create reachables slice for a java project.

cd <path to repo>
cdxgen -t java --deep -o bom.json .
atom reachables -o app.atom -s reachables.json -l java .

Pass the argument --reuse-atom to slice based on an existing atom file.

atom reachables --reuse-atom -o app.atom -s reachables.json -l java .

Environment variables

VariableDescription
CHEN_IGNORE_DIRSComma-separated list of directories to ignore for every language frontend.
CHEN_IGNORE_TEST_DIRSSet to true to ignore common test directories (test, tests, mocks) for every language frontend.
CHEN_C_IGNORE_DIRSComma-separated list of additional directories to ignore for the C/C++ and header frontends.
CHEN_CPP_IGNORE_DIRSComma-separated list of additional directories to ignore for the C++ frontend.
CHEN_JAVA_IGNORE_DIRSComma-separated list of additional directories to ignore for the Java source frontend.
CHEN_JIMPLE_IGNORE_DIRSComma-separated list of directories to ignore for the Jimple/JAR/Android/APK/DEX frontend.
CHEN_SCALA_IGNORE_DIRSComma-separated list of directories to ignore for the Scala frontend.
CHEN_JAVASCRIPT_IGNORE_DIRSComma-separated list of directories to ignore for the JavaScript, TypeScript, and Flow frontend.
CHEN_JS_IGNORE_DIRSAlias for JavaScript, TypeScript, and Flow ignored directories.
CHEN_TYPESCRIPT_IGNORE_DIRSAlias for TypeScript and Flow ignored directories.
CHEN_PYTHON_IGNORE_DIRSComma-separated list of directories to ignore for Python. If unset, Atom uses Python's default ignored directories.
CHEN_PHP_IGNORE_DIRSComma-separated list of additional directories to ignore for the PHP frontend.
CHEN_RUBY_IGNORE_DIRSComma-separated list of additional directories to ignore for the Ruby frontend.
CHEN_DELOMBOK_MODEDelombok mode for the Java frontend (no-delombok, default, types-only, run-delombok).
CHEN_INCLUDE_PATHInclude directories for the C frontend. Separate paths with : or ;.
CHEN_ASTGEN_OUTExisting astgen output directory. Improves performance for JavaScript, TypeScript, and Flow during repeated invocations by reusing existing AST json data.
ATOM_TOOLS_OPENAPI_FORMATOpenAPI format for atom-tools. Default: openapi3.1.0; alternative: openapi3.0.1.
ATOM_TOOLS_WORK_DIRWorking directory for atom-tools. Defaults to atom input path.
ATOM_SCALASEM_WORK_DIRWorking directory for scalasem. Defaults to atom input path.
ATOM_SCALASEM_SLICES_FILESlices file name. Defaults to semantics.slices.json.
ATOM_JVM_ARGSOverrides the JVM arguments, including heap memory values, constructed by the atom Node.js wrapper.
ATOM_JAVA_HOMEJava 21 or above to be used by atom.
PHP_CMDOverrides the PHP command used by the PHP frontend.
PHP_PARSER_BINOverrides the php-parse command used by the PHP frontend.
SCALA_CMDOverrides the scala command.
SCALAC_CMDOverrides the scalac command used by the scala frontend.
ASTGEN_IGNORE_DIRSComma-separated list of directories to ignore by the JavaScript astgen pre-processor command.
ASTGEN_IGNORE_FILE_PATTERNFile pattern to ignore by the JavaScript astgen pre-processor command.
ASTGEN_INCLUDE_NODE_MODULES_BUNDLESAlso include source code from node_modules directory. Makes the flows more complete at the cost of increased memory use.
JAVA_CMDOverrides the java command.
RUBY_CMDOverrides the Ruby command used by the rbastgen wrapper.
ATOM_RUBY_HOMERuby installation directory for the rbastgen wrapper, when Ruby is not on PATH.
RUBY_ASTGEN_BINPath to the ruby_ast_gen script that the rbastgen wrapper runs. The simplest way to test a generator build.
RBASTGEN_PATHPath to the rbastgen executable itself, overriding the one on PATH; the rbastgen.path system property takes precedence.

Troubleshooting

atom file is incomplete for large projects

astgen might require a generous heap of memory for large JavaScript projects, especially flow projects. Use the environment variable NODE_OPTIONS to increase the memory available.

export NODE_OPTIONS="--expose-gc --max-old-space-size=16288"

For large projects such as React 19, astgen requires over 80 GB of heap memory! Use the environment variable CHEN_ASTGEN_OUT to make atom and chen, reuse any existing directory containing astgen generated json and typemap files.

To improve the accuracy further, include source code from the node_modules directory by setting ASTGEN_INCLUDE_NODE_MODULES_BUNDLES.

export ASTGEN_INCLUDE_NODE_MODULES_BUNDLES=true
export ASTGEN_IGNORE_DIRS=""

License

MIT

版本与发布记录

@appthreat/atom 共发布 148 个版本,首次发布于 2023/06/08;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.2.1latest2026/10/289 天前
3.1.12026/08/082 个月前
3.1.02026/08/082 个月前
3.0.32026/06/284 个月前
3.0.22026/06/264 个月前
2.5.62026/06/184 个月前

关于 @appthreat/atom 的常见问题

@appthreat/atom 是什么?

Create atom (⚛) representation for your application, packages and libraries

如何安装 @appthreat/atom?

在项目目录运行 npm install @appthreat/atom,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 atom,可以用 npx atom 直接运行。

@appthreat/atom 支持 TypeScript 吗?

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

@appthreat/atom 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@appthreat/atom 需要什么版本的 Node.js?

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

@appthreat/atom 可以商用吗?

@appthreat/atom 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appthreat/atom 的下载量有多少?

根据 npm 官方下载统计,@appthreat/atom 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,407,492 次,日均约 46,916 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appthreat/atom 还在维护吗?

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