/** * Copyright (c) 2025 Ofri Peretz * Licensed under the MIT License. Use of this source code is governed by the * MIT license that can be found in the LICENSE file. */ /** * ESLint Rule: no-math-random-crypto * Detects Math.random() used in cryptographic contexts * CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator * * Math.random() is not cryptographically secure and should never be used * for tokens, keys, IVs, salts, or any security-sensitive random values. * * Migrated from the deprecated eslint-plugin-crypto (2026-05) so that * node-security genuinely covers every cryptography rule the crypto plugin * shipped, per its deprecation notice. * * @see https://cwe.mitre.org/data/definitions/338.html */ import type { TSESLint } from '@interlace/eslint-devkit'; type MessageIds = 'mathRandomCrypto' | 'useRandomBytes' | 'useRandomUUID'; export interface Options { /** Allow Math.random() in test files. Default: false */ allowInTests?: boolean; } type RuleOptions = [Options?]; export declare const noMathRandomCrypto: TSESLint.RuleModule & { name: string; }; export type { Options as NoMathRandomCryptoOptions };