basesec

Fast, zero-config SAST CLI for JavaScript & TypeScript — Node.js backends and frontend frameworks. Detects SQLi, NoSQLi, XSS, DOM-based XSS, RCE, path traversal, secrets, and 60+ other vulnerabilities via AST + taint analysis. Supports Express, NestJS, Fa
1,014 11
Install
npm install basesec
Latest Version:0.1.7
License:CC BY-NC 4.0
Last Updated:Oct 5, 2026
Links: GitHub  ·  npm
Maintainer: tavotsu

logo

npm version License downloads stars

Static Application Security Testing (SAST) CLI for JavaScript & TypeScript — Node.js backends and frontend frameworks.

Features

  • 65 Security Rules across 10 categories (SQL Injection, XSS, NoSQL Injection, Command Injection, Path Traversal, Authentication, Secrets, Error Handling, Misconfiguration, Dependency Checking) — including frontend DOM-based XSS, client-side secrets, open redirect, postMessage/insecure-storage, and framework rules for React/Next, Vue/Nuxt, Angular, and Svelte
  • Taint Analysis — tracks data flow from user input (req.query, req.body, useSearchParams(), location.search, route params, etc.) to dangerous sinks
  • Framework Detection — auto-detects Express, NestJS, Mongoose, TypeORM, Fastify, Koa, Prisma, React, Next.js, Vue, Nuxt, Angular, and Svelte
  • Single-File Components — parses .vue and .svelte files (script + template) with no extra dependencies
  • Dependency Checking — detects outdated packages with known CVEs, vulnerable dependencies (via pnpm/npm audit), unused dependencies, and lockfile mismatches
  • Sensitive File Protection — .env and credential files are completely ignored by default unless explicitly allowed with --read-env
  • Multiple Output Formats — Terminal (colored tables), JSON, SARIF, HTML, Markdown. Non-terminal formats auto-save to ~/.basesec/
  • Analysis Cache — hash-based per-file caching for 10x speedup on incremental scans
  • Worker Threads — multi-core parallel analysis for large codebases
  • Custom Rules — load external rule files (MJS/CJS) via .basesecrc
  • AI-Powered Analysis — enriches findings with AI explanations and detects suspicious taint flows (Ollama or OpenAI)
  • Zero Configuration — works out of the box with sensible defaults

Quick Start

Install

npm install -g basesec
# or
pnpm add -g basesec
# or
yarn global add basesec

Scan

# Scan current directory
basesec scan

# Scan specific directory
basesec scan ./src

# JSON output (auto-saved to ~/.basesec/scan-<timestamp>.json)
basesec scan ./src --format json

# Custom output path
basesec scan ./src --format json --output report.json

# Only critical/high findings, strict exit code
basesec scan ./src --severity high --strict

Framework Support

Framework Auto-Detection Notes
Express Yes Route handlers, middleware, res.send(), res.set()
NestJS Yes Decorators (@Controller, @Get, etc.), guards
Fastify Yes Route handlers, rate limit, helmet, CORS
Koa Yes Context assignments (ctx.body), middleware
Mongoose Yes Query chains, $where, lean()
TypeORM Yes Query builder, raw queries
Prisma Yes Raw queries ($queryRaw, $executeRaw)
React / Next.js Yes dangerouslySetInnerHTML, JSX href/src, refs, NEXT_PUBLIC_ secrets, redirect()
Vue / Nuxt Yes v-html, :href/:src, render-function innerHTML (.vue SFCs)
Angular Yes bypassSecurityTrust*, nativeElement.innerHTML, [innerHTML], jsonp, router redirects, unguarded routes
Svelte Yes {@html} (.svelte SFCs)

Configuration

Create a .basesecrc file in your project root:

export default {
  severity: 'low',
  framework: 'auto',
  ignore: ['node_modules', 'dist', 'coverage'],
  taintAnalysis: true,
  sanitizers: [],
  rules: [],
  rulesConfig: {},
  maxFileSize: 512000,
  maxFiles: 10000,
  cache: {
    maxAge: 86400000,
    dir: '.basesec/cache',
  },
  workers: {
    threshold: 50,
    max: 8,
  },
  output: {
    format: 'terminal',
    filePath: '',
  },
  // AI disabled by default for maximum privacy
  ai: {
    enabled: false,
    provider: 'ollama',
    model: 'llama3.2',
    contextLevel: 'minimal',
    baseUrl: 'http://localhost:11434',
    maxFindings: 10,
    timeout: 30000,
  },
};

See CONFIGURATION.md for full options.

Performance

BaseSec uses two core optimizations:

  1. Analysis Cache (enabled by default) — SHA-256 file + config hashing, skips unchanged files
  2. Worker Threads (auto-enabled for >50 files) — parallel analysis across CPU cores

Combined, these deliver ~12x speedup on rescans. See PERFORMANCE.md for benchmark data.

Documentation

License

CC BY-NC 4.0 © tavotsu

Related Packages

owlwarden

Offline security scanner for Node web apps and AI coding agents. OWASP rules wit...

0 0
guardz

A simple and lightweight TypeScript type guard library for runtime type validati...

26,533 3
cr-numeral

cr-numeral is a lightweight and versatile npm package designed to effortlessly c...

8,248 3
@flowslens/cli

Trace any user action from the UI to the database. Maps every click through Reac...

983 0
reliant-type

A modern TypeScript validation library designed around familiar interface syntax...

6,115 0

Version History

Version Released License
0.1.7 CC BY-NC 4.0
0.1.6 CC BY-NC 4.0
0.1.4 MIT
0.1.3 MIT
0.1.2 MIT