Hub rules-bun

rules-bun

v4 public Verified

Bun

Bun is a fast, all-in-one JavaScript runtime. These rules govern package management, script execution, and performance optimization for AI-assisted Bun development.

@sigmashakeinc 3 pulls 20 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-bun →
Severity
10 error 9 warn 1 info
demo.cast
Bun is a fast, all-in-one JavaScript runtime. These rules govern package management, script execution, and performance optimization for AI-assisted Bun development.

Rules index

20 governance rules

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

bun

ask-bun-patch warning ask

'bun patch' modifies a dependency directly in node_modules. Patches are fragile — they are silently lost on the next 'bun install' unless committed with 'bun patch --commit'.

Rule source requires an active Pro or Enterprise subscription.
ask-bun-publish warning ask

Publishing to npm via bun is permanent (except within 72 hours). Verify the version, build output, and included files before publishing.

Rule source requires an active Pro or Enterprise subscription.
ask-bunx-unversioned warning ask

bunx without a pinned version always fetches the latest release. A compromised package version could execute malicious code in your project during the run.

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

Command injection risk: Bun.spawn() is used with 'shell: true' or 'sh -c'. This makes it highly vulnerable to command injection if user-controlled input is part of the command string. Always pass commands and arguments as an array to the 'cmd' property and avoid 'shell: true' to ensure arguments are properly escaped.

Rule source requires an active Pro or Enterprise subscription.
bun-fetch-reject-unauthorized-false error block

RISK: Disabling TLS certificate validation (rejectUnauthorized: false) exposes fetch/HTTPS traffic to man-in-the-middle attacks. FIX: Remove the option; if a self-signed cert is required, add its CA via the 'ca' option instead.

Rule source requires an active Pro or Enterprise subscription.
bun-google-js-style-no-var warning log

Style Guide Violation: Usage of 'var' keyword detected. Modern JavaScript and Google's JavaScript Style Guide recommend using 'const' or 'let' for variable declarations to improve scope management, prevent common hoisting-related bugs, and enhance code readability. Please refactor to use 'const' or 'let'.

Rule source requires an active Pro or Enterprise subscription.
bun-insecure-dynamic-code-eval error block

Insecure dynamic code execution: Usage of 'eval()' or 'new Function()' is detected. These functions are dangerous when used with untrusted input as they can execute arbitrary code, leading to severe security vulnerabilities like RCE. Refactor to avoid dynamic code execution from external sources.

Rule source requires an active Pro or Enterprise subscription.
bun-math-random-for-secrets error block

RISK: Math.random() is not cryptographically secure — the sequence is predictable, so generated tokens/secrets/salts can be guessed. FIX: Use crypto.randomUUID(), crypto.randomBytes(n), or crypto.getRandomValues().

Rule source requires an active Pro or Enterprise subscription.
bun-no-deprecated-buffer-constructor error block

Deprecated Buffer constructor: 'new Buffer()' is deprecated in Node.js and should be avoided in Bun for compatibility and security reasons (e.g., uninitialized memory in older Node.js versions). Use 'Buffer.from()', 'Buffer.alloc()', or 'Buffer.allocUnsafe()' for explicit and safer memory allocation.

Rule source requires an active Pro or Enterprise subscription.
bun-package-trusted-dependencies warning ask

RISK: Entries in trustedDependencies re-enable arbitrary postinstall script execution that Bun disables by default, widening the supply-chain attack surface. FIX: Remove entries you do not need; for each remaining one, audit its install scripts and pin an exact version.

Rule source requires an active Pro or Enterprise subscription.
bun-password-bcrypt-weak-cost warning ask

RISK: Bun.password bcrypt cost < 12 is below the 2024 OWASP password-storage recommendation and bcrypt silently truncates inputs > 72 bytes. FIX: Raise cost to 12+ or switch to the default argon2id algorithm.

Rule source requires an active Pro or Enterprise subscription.
bun-path-traversal-write-concat error block

Potential path traversal vulnerability: Bun.write() path argument uses string concatenation. This is risky if user input is involved. Always use 'path.join()' or 'path.resolve()' with a base directory for safe path construction to prevent directory traversal attacks.

Rule source requires an active Pro or Enterprise subscription.
bun-serve-oversized-body info log

RISK: Bun.serve defaults maxRequestBodySize to 128 MB, letting a single request exhaust memory (DoS). FIX: Set an explicit maxRequestBodySize appropriate to the endpoint (e.g. 1_000_000 for JSON APIs).

Rule source requires an active Pro or Enterprise subscription.
bun-shell-raw-bypass error block

RISK: Bun.$.raw() bypasses the tagged-template auto-escaping, re-introducing shell injection when any untrusted value reaches it. FIX: Remove .raw() and interpolate values directly with Bun.$`cmd ${value}` so Bun escapes them.

Rule source requires an active Pro or Enterprise subscription.
bun-sql-unsafe error block

RISK: Bun.sql.unsafe() / postgres.unsafe() executes a raw SQL string with no parameterization, enabling SQL injection (see CVE-2024-52531 class). FIX: Use the tagged template sql`SELECT ... WHERE id=${id}` so values are bound as parameters.

Rule source requires an active Pro or Enterprise subscription.
bun-sqlite-template-query error block

RISK: bun:sqlite db.query/run/exec/prepare with a template literal does NOT parameterize ${...} — the value is concatenated into SQL and is injectable. FIX: Use placeholders — db.query('SELECT ... WHERE id=?').all(id) or named params {$id: id}.

Rule source requires an active Pro or Enterprise subscription.
bun-subtle-extractable-key warning log

RISK: SubtleCrypto.importKey with extractable: true lets the key material be exported from the runtime, defeating the point of using WebCrypto. FIX: Pass extractable: false unless you genuinely need exportKey later.

Rule source requires an active Pro or Enterprise subscription.
bun-unsafe-file-read-sync warning log

Synchronous file read detected: Using '.textSync()' or '.arrayBufferSync()' can block the event loop, leading to performance issues and potential Denial-of-Service (DoS) if reading large or untrusted files. Prefer asynchronous methods like '.text()' or '.arrayBuffer()' with 'await' for non-blocking I/O.

Rule source requires an active Pro or Enterprise subscription.
bun-weak-hash-algorithm error block

RISK: MD5 and SHA-1 are cryptographically broken (collision attacks) and must not be used for signatures, integrity, or identifiers of security value. FIX: Use 'sha256' or 'sha512' via Bun.CryptoHasher or node:crypto.createHash.

Rule source requires an active Pro or Enterprise subscription.
bun-websocket-upgrade-no-origin-check warning ask

RISK: Bun.serve WebSocket upgrade() without an Origin check is vulnerable to Cross-Site WebSocket Hijacking — a malicious page can open an authenticated socket to your server. FIX: Validate req.headers.get('origin') against an allowlist before calling server.upgrade(req).

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
v4
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
f4c57f4aa381f7670f30df467edea86baa1d931c99c72792272e774ad6f2bb39
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

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

No commit history available.