Hub rules-typescript

rules-typescript

v5 public Verified

TypeScript

TypeScript is a strongly typed programming language that builds on JavaScript. These rules govern type safety, vulnerability prevention, and idiomatic coding patterns for AI agents.

@sigmashakeinc 30 pulls 42 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-typescript →
Severity
20 error 20 warn 2 info
demo.cast
TypeScript is a strongly typed programming language that builds on JavaScript. These rules govern type safety, vulnerability prevention, and idiomatic coding patterns for AI agents.

Rules index

42 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

ts

ask-inner-html warning log

Direct HTML injection detected. Verify the value is sanitized — never pass user-supplied data to innerHTML or dangerouslySetInnerHTML.

Rule source requires an active Pro or Enterprise subscription.
ban-ts-ignore warning ask

Type suppression is banned. Fix the underlying type error instead of suppressing it with @ts-ignore or @ts-nocheck.

Rule source requires an active Pro or Enterprise subscription.
catch-unknown-not-any warning ask

Do not type catch variables as 'any'. Use 'unknown' and narrow the type: if (err instanceof Error) { ... }

Rule source requires an active Pro or Enterprise subscription.
json-parse-in-try warning log

JSON.parse throws on invalid input. Wrap in try/catch when parsing untrusted data (request bodies, env vars, file contents) or validate with a schema library (zod, valibot) after parsing.

Rule source requires an active Pro or Enterprise subscription.
no-any-type warning ask

Do not use 'any'. Define a concrete type, interface, or generic. 'any' defeats TypeScript's type system entirely.

Rule source requires an active Pro or Enterprise subscription.
no-axios-compromised-versions error block

axios 1.14.1 and 0.30.4 are malicious supply-chain releases published 2026-03-31 via a compromised maintainer account (Snyk/Microsoft advisory). Both versions install a cross-platform Remote Access Trojan. Upgrade to axios >=1.8.4, re-run 'npm ci', and rotate any credentials that may have been exposed in affected environments.

Rule source requires an active Pro or Enterprise subscription.
no-bun-file-user-path error block

Bun.file() or Bun.write() called with a request-derived path enables path traversal (CWE-22 / OWASP A01:2021). An attacker can supply '../../../etc/passwd' or an absolute path outside the intended root. Resolve the final path with path.resolve(), then assert it starts with the expected base directory before opening or writing any file.

Rule source requires an active Pro or Enterprise subscription.
no-bun-shell-template-injection error block

Bun.$`...` (Bun shell tagged template) with an interpolated expression passes user-controlled text through a POSIX shell, enabling command injection (CWE-78). An attacker can terminate the intended command and append arbitrary ones via ; or $(...). Use Bun.spawn(['cmd', arg]) with a validated argv array, or escape with Bun.$.escape(value) before interpolation. Never interpolate req.* or external data directly into Bun.$.

Rule source requires an active Pro or Enterprise subscription.
no-bun-spawn-template-injection error block

Bun.spawn() called with a template-literal array element containing an interpolated expression. Even without shell:true, interpolating untrusted data into an argv slot allows argument injection — an attacker can inject flags (e.g. '--exec', '--upload-pack') that change the command's behaviour (CWE-88). Build argv from validated, allowlisted values; never interpolate user input into a spawn array.

Rule source requires an active Pro or Enterprise subscription.
no-bun-sqlite-exec-concat error block

db.exec() called with a concatenated string enables SQL injection (CWE-89). Unlike db.query()/db.prepare(), exec() runs the full SQL string verbatim — there is no placeholder binding path. Build DDL/schema strings from a fixed constant, never by concatenating user-controlled values. For data writes, use db.prepare() with ? placeholders.

Rule source requires an active Pro or Enterprise subscription.
no-child-process-shell error block

child_process.exec/execSync invokes a shell — string concatenation or template interpolation opens command injection. Use execFile/spawn with an argv array and { shell: false } (the default).

Rule source requires an active Pro or Enterprise subscription.
no-console-log-in-src warning log

console.log() in source code detected. Use a structured logger instead so output can be controlled in production.

Rule source requires an active Pro or Enterprise subscription.
no-console-log-secret error block

Logging a secret-named variable (token/secret/password/apiKey/privateKey) via console.log leaks credentials into stdout, log files, and any downstream log aggregator (CWE-312 / CWE-532). Replace with a structured logger that redacts sensitive fields, or use a masked preview: maskToken(value) (trims to first 8 chars + '...'). Never log raw secrets — even in debug paths that ship to production.

Rule source requires an active Pro or Enterprise subscription.
no-deep-relative-imports info log

Deep relative import (3+ levels) detected. Consider using path aliases (e.g., @/src/...) configured in tsconfig.json for cleaner imports.

Rule source requires an active Pro or Enterprise subscription.
no-dynamic-require-user-input error block

Dynamic require() or import() with request-controlled input enables module injection (CWE-706). An attacker can load arbitrary Node built-ins or local files, bypassing access controls. Use a static allowlist of module names: const ALLOWED = { csv: () => import('./csv') }; never pass user input directly to require/import.

Rule source requires an active Pro or Enterprise subscription.
no-empty-catch warning log

Empty catch block silently swallows errors. At minimum, log the error or rethrow it.

Rule source requires an active Pro or Enterprise subscription.
no-eval error block

eval() and new Function() are banned. They enable code injection attacks and defeat static analysis.

Rule source requires an active Pro or Enterprise subscription.
no-express-redirect-unsanitized warning log

res.redirect() or res.location() with user-controlled input enables open redirect (CVE-2024-29041). Attackers can bypass allow lists using malformed URLs. Validate the URL with 'new URL()' and check the origin against a whitelist of permitted hosts.

Rule source requires an active Pro or Enterprise subscription.
no-ffi-bytelength-as-any error block

Passing an 'as any' cast to a bun:ffi length/byteLength argument bypasses TypeScript's numeric-type check. A wrong value can cause the native library to read or write beyond the allocated buffer, resulting in memory corruption (CWE-843 type confusion, CWE-119 buffer overflow). Use a concrete number expression — never cast to any at a memory-size boundary.

Rule source requires an active Pro or Enterprise subscription.
no-ffi-ptr-as-any error block

Passing an 'as any' value to bun:ffi ptr() suppresses TypeScript's check that the argument is a TypedArray (Uint8Array/Int32Array/etc.). A wrong type causes a silent dangling-pointer read or write, leading to memory corruption or a segfault in the Zig/C native library. Declare the buffer with the concrete TypedArray type and pass it directly: const buf = new Uint8Array(size); ptr(buf).

Rule source requires an active Pro or Enterprise subscription.
no-insecure-crypto-md5 error block

MD5 and SHA1 are cryptographically broken. Use SHA-256 or better (e.g., SHA-3).

Rule source requires an active Pro or Enterprise subscription.
no-insecure-tls error block

Disabling TLS certificate verification defeats HTTPS. Never set rejectUnauthorized: false or NODE_TLS_REJECT_UNAUTHORIZED=0 in production code — configure a trust store instead.

Rule source requires an active Pro or Enterprise subscription.
no-jwt-none-algorithm error block

Accepting the JWT 'none' algorithm lets any attacker forge tokens by stripping the signature (CVE-2015-9235 class; still reappears in wrappers). Pin algorithms to a concrete list like ['RS256'] or ['HS256'] when calling jsonwebtoken.verify / jose.jwtVerify.

Rule source requires an active Pro or Enterprise subscription.
no-new-buffer-ctor warning ask

The Buffer() constructor is deprecated since Node 10 and can disclose uninitialized memory or trigger DoS when called with a number. Use Buffer.alloc(n) for zero-filled buffers, Buffer.from(data) for copies, and Buffer.allocUnsafe(n) only when you immediately overwrite.

Rule source requires an active Pro or Enterprise subscription.
no-node-vm-module warning ask

The Node vm module does not provide a security sandbox — vm.runInNewContext can escape via Object.constructor. Use a real isolate (isolated-vm, worker_threads with MessageChannel, or a subprocess) to run untrusted code.

Rule source requires an active Pro or Enterprise subscription.
no-non-null-assertion warning log

Non-null assertion (!) detected. Handle the null/undefined case explicitly rather than asserting it away — crashes at runtime if the value is actually null.

Rule source requires an active Pro or Enterprise subscription.
no-path-traversal-user-input error block

Joining request-supplied values into file paths enables path traversal (OWASP A01:2021). An attacker can supply '../../../etc/passwd' to escape the intended root. Always resolve the final path and assert it starts with the expected base directory before opening any file.

Rule source requires an active Pro or Enterprise subscription.
no-prototype-mutation error block

Mutating Object.prototype or assigning to __proto__ enables prototype pollution, a common gadget for RCE in Node.js. Use Object.create(null) for dictionaries and never merge untrusted input with a recursive assign.

Rule source requires an active Pro or Enterprise subscription.
no-sourcemap-in-tsconfig error block

sourceMap: true exposes your TypeScript source code via .map files served alongside production bundles. Source maps allowed the Claude Code source code leak (March 31, 2026) — private TypeScript was fully reconstructable by anyone inspecting network traffic. Set sourceMap: false or omit the field entirely. For local debugging only, restrict source maps to dev-only tsconfig overrides never deployed to production.

Rule source requires an active Pro or Enterprise subscription.
no-spawn-shell-true error block

spawn/spawnSync/Bun.spawn called with { shell: true } invokes a POSIX shell to execute the command string — any interpolated or user-supplied argument becomes a shell-injection vector (CWE-78). Remove shell:true and pass an explicit argv array: Bun.spawn(['git', '--version']) never involves a shell by default. If you need a pipeline, build the argv manually or use Bun.$ with escaped values.

Rule source requires an active Pro or Enterprise subscription.
no-sql-interpolation error block

Do not use template literals in SQL queries. Use parameterized statements with ? placeholders to prevent SQL injection.

Rule source requires an active Pro or Enterprise subscription.
no-sql-string-concat error block

SQL query built with string concatenation enables SQL injection (CWE-89 / OWASP A03:2021). An attacker who controls any concatenated value can exfiltrate or corrupt the database. Use parameterized placeholders: db.query('SELECT * FROM rules WHERE id = ?').get(id) — bun:sqlite passes bound values as separate arguments, never inside the SQL string.

Rule source requires an active Pro or Enterprise subscription.
no-var-declarations warning log

Prefer 'const' or 'let' over 'var'. Block-scoped declarations prevent hoisting bugs and clarify intent.

Rule source requires an active Pro or Enterprise subscription.
no-wildcard-imports warning log

Wildcard imports ('import * as X') import the entire module and prevent tree-shaking. Use named imports instead.

Rule source requires an active Pro or Enterprise subscription.
prefer-const-over-let info log

Consider 'const' if this variable is never reassigned. Immutable bindings make code easier to reason about.

Rule source requires an active Pro or Enterprise subscription.
timing-safe-compare-secrets warning log

Comparing secrets with === leaks timing information (byte-by-byte early exit). Use crypto.timingSafeEqual() for tokens, HMACs, signatures, and API keys.

Rule source requires an active Pro or Enterprise subscription.
warn-lodash-merge-prototype-pollution warning log

lodash _.merge() and _.defaultsDeep() are vulnerable to prototype pollution when passed untrusted input containing a '__proto__' key (CVE-2019-10744, CVE-2020-8203). Upgrade to lodash >=4.17.21 and sanitize untrusted objects before merging — prefer structuredClone() or Object.assign({}) with validated, allowlisted keys.

Rule source requires an active Pro or Enterprise subscription.
warn-math-random warning log

Math.random() is cryptographically insecure. If this is for security tokens, passwords, or IDs, use crypto.getRandomValues() or crypto.randomBytes().

Rule source requires an active Pro or Enterprise subscription.
warn-multer-without-limits warning log

multer() called with no size limits. This risks memory exhaustion and DoS attacks (CVE-2025-47935, CVE-2025-47944). Upgrade to multer 2.0.0+ and always configure limits: multer({ limits: { fileSize: 5*1024*1024, files: 10 } })

Rule source requires an active Pro or Enterprise subscription.
warn-postmessage-wildcard-origin warning log

window.postMessage(..., '*') broadcasts the payload to any cross-origin listener, leaking tokens, user data, or auth state. Pass the concrete target origin (e.g., 'https://app.example.com') and verify event.origin on the receiver.

Rule source requires an active Pro or Enterprise subscription.
warn-regex-dos warning log

Nested quantifiers (e.g. (.*)+ or (a+)*) can cause catastrophic backtracking (ReDoS) on adversarial input. Refactor to a linear pattern, add a length cap, or use a linear-time engine (re2).

Rule source requires an active Pro or Enterprise subscription.
warn-ssrf-user-url warning log

Passing request-derived URLs directly to fetch() or axios enables SSRF (OWASP A10:2021). Attackers can reach internal services or cloud metadata endpoints (e.g. 169.254.169.254). Validate the URL against a strict allowlist of permitted hosts before making any outbound request.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v5
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
f6571f676c4584ec082f4239f8287bc02947907eda60bc056be8ebc3832091f8
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-typescript/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-typescript. The published version only bumps when a maintainer resyncs.

No commit history available.