typescript language

JavaScript Overview

JavaScript is a high-level, interpreted programming language primarily used for creating interactive and dynamic web content widely used by developers. Endor Labs supports the scanning and monitoring of JavaScript projects. Using Endor Labs, application security engineers and developers can:

System Specifications for Deep Scan

Before you proceed to run a deep scan, ensure that your system meets the following specifications.

Project Size Processor Memory
Small projects 4-core processor 16 GB
Mid-size projects 8-core processor 32 GB
Large projects 16-core processor 64 GB

Software Prerequisites

To run deep scanning for JavaScript and TypeScript projects make sure you have the following prerequisites installed:

Nodejs Version TypeScript Version
Lower than 12.2 4.9
Between 12.2 and 14.17 5.0
Higher than or equal to 14.17 "Greater than 4.9 up to 6.X.X"
npm install -g typescript@6
npm install -g typescript@5.0
npm install -g typescript@4.9
  which tsserver

If you are running the endorctl scan with --install-build-tools, you don’t need to install tsserver.

Build JavaScript Projects

You can build your JavaScript projects before running a scan. Building first creates a package-lock.json, yarn.lock, or pnpm-lock.yaml file, which speeds up the scan. Ensure your repository has package.json and run the following command:

npm install
yarn install
pnpm install

If the project is not built, endorctl builds the project during the scan and generates package-lock.json, yarn.lock, or pnpm-lock.yaml file. Make sure that npm, Yarn, or pnpm is available on your system. If your repository includes a lock file, endorctl uses the existing file for dependency resolution and does not create it again. The npm install command may fail in a subdirectory if your project has a package-lock.json file at the root of the repository but not in sub-packages.

To avoid scan failures in monorepo setups, set the following environment variable before you run the scan.

export ENDOR_JS_USE_ROOT_DIR_LOCK_FILE=true

Specify a Custom Lock File Location

Use ENDOR_JS_LOCK_FILE_PATH to specify the exact lock file for endorctl to use during a scan. The variable applies to npm, Yarn, pnpm, and Rush projects.

export ENDOR_JS_LOCK_FILE_PATH=locks/yarn.lock

Scan Rush Monorepos

Rush is a monorepo management tool for JavaScript/TypeScript. Endor Labs detects Rush repositories and scans them with the standard JavaScript workflow. To scan Rush monorepos, you must first enable Rush detection.

export ENDOR_RUSH_ENABLED=true

Run endorctl scan to discover Rush dependencies:

endorctl scan

Configure Call Graph Generation Timeout

When generating call graphs for JavaScript/TypeScript projects, endorctl uses tsserver to analyze the code. You may need to increase the timeout.

export ENDOR_JS_TSSERVER_TIMEOUT=30

Override JavaScript Package Manager Detection

You can override the automatic JavaScript package manager detection by setting the ENDOR_JS_PACKAGE_MANAGER environment variable to npm, yarn, pnpm, or lerna.

export ENDOR_JS_PACKAGE_MANAGER=npm

Scan Bazel Projects

Endor Labs supports Bazel scans for JavaScript and TypeScript.

Scan TypeScript Projects with rules_ts

Ensure that the following prerequisites are in place:

Run the following command to discover and scan TypeScript targets:

bazel query 'kind(ts_project, //...)'

Run a Scan

Perform a scan to get visibility into your software composition and resolve dependencies:

endorctl scan

Understand the Scan Process

Dependency analysis tools analyze the lock file of an npm, yarn, pnpm, or Rush based package. Endor Labs surpasses mere manifest file analysis by expertly resolving JavaScript dependencies and identifies:

Configure Private NPM Package Repositories

Endor Labs supports fetching and scanning dependencies from private npm package registries.

Known Limitations

Troubleshoot Errors