Bun Analyzer Developer Gotchas

This document covers common pitfalls and considerations when working with the Bun analyzer.

Bun’s isolated linker (bun install --linker isolated) creates a flat store under node_modules/.bun/ with symlinks for package resolution. This differs from the default hoisted layout.

Implications:

Testing:

2. node_modules/.bun/ Scanning Requirement

Unlike Node.js, Bun may store packages entirely under node_modules/.bun/ with only symlinks in the top-level node_modules/. If your scanner configuration excludes .bun/ directories, you will miss dependencies.

Checklist:

3. bun.lockb Policy (2025-12-09)

The binary lockfile (bun.lockb) remains unsupported. We will not parse it and will keep remediation-only handling until Bun publishes a stable, documented format.

Posture:

Migration command (required):

bun install --save-text-lockfile

This generates bun.lock (JSONC text format) which the analyzer parses.

WebService response when only bun.lockb exists:

4. JSONC Lockfile Format

bun.lock uses JSONC (JSON with Comments) format supporting:

Parser considerations:

5. Multi-Stage Build Implications

In multi-stage Docker builds, the final image may contain only production artifacts without the lockfile or node_modules/.bun/ directory.

Scanning strategies:

  1. Image scanning (recommended for production): Scans the final image filesystem. Set include_dev: false to filter dev dependencies
  2. Repository scanning: Scans bun.lock from source. Includes all dependencies by default (include_dev: true)

Best practice: Scan both the repository (for complete visibility) and production images (for runtime accuracy).

6. npm Ecosystem Reuse

Bun packages are npm packages. The analyzer:

This means:

7. Source Detection in Lockfile

bun.lock entries include source information that determines package type:

Source PatternTypeExample
No source / default registryregistrylodash@4.17.21
git+https://... or git://...gitVCS dependency
file: or link:tarballLocal package
workspace:workspaceMonorepo member

The analyzer records source type in evidence for provenance tracking.

8. Workspace/Monorepo Handling

Bun workspaces use a single bun.lock at the root with multiple package.json files in subdirectories.

Analyzer behavior:

Testing: Use the WorkspacesAreParsedAsync test fixture.

9. Dev/Prod Dependency Filtering

The include_dev configuration option controls whether dev dependencies are included:

ContextDefault include_devRationale
Repository scan (lockfile-only)trueFull visibility for developers
Image scan (installed packages)truePackages are present regardless of intent

Override: Set include_dev: false in scan configuration to exclude dev dependencies from results.

10. Evidence Model

Each Bun package includes evidence with:

Evidence enables:

CLI Reference

Inspect local workspace

stellaops-cli bun inspect --root /path/to/project

Resolve packages from scan

stellaops-cli bun resolve --scan-id <id>
stellaops-cli bun resolve --digest sha256:<hash>
stellaops-cli bun resolve --ref myregistry.io/myapp:latest

Output formats

stellaops-cli bun inspect --format json > packages.json
stellaops-cli bun inspect --format table