Skip to content

eslint/rules/security ​

Security: Injection (XSS, SQL, commands), weak cryptography, secrets, insecure protocols and the sanitizer. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.

57 rules, 46 on. Source: lint/eslint/rules/security.mjs.

RuleSettingFilesWhat it checksWhy
no-restricted-propertieswarn, [{"property":"bypassSecurityTrustHtml","message":"Bypassi…JS + TSDisallow certain properties on certain objectsCustom: a sanitizer bypass is a security review, not a shortcut. Warn: a reviewed bypass (trusted, constant markup) may be justified with an eslint-disable comment.
no-evalerrorJS + TSDisallow the use of eval()—
no-implied-evalerrorJS + TSDisallow the use of eval()-like methodsReplaced by the TS version.
no-new-funcerrorJS + TSDisallow new operators with the Function object—
no-script-urlerrorJS + TSDisallow javascript: URLs—
sonarjs/code-evaloffJS + TSDynamic code execution should not use user-controlled dataOff: duplicate of no-eval, no-new-func and no-implied-eval.
sonarjs/confidential-information-loggingoffJS + TSConfidential information should not be loggedOff: not in the Sonar way profile of SonarQube.
sonarjs/content-lengtherrorJS + TSHTTP request content length should be limited—
sonarjs/content-security-policyerrorJS + TSContent security policy fetch directives should not be disabled—
sonarjs/cookie-no-httponlyerrorJS + TSCookies should have the "HttpOnly" flag—
sonarjs/corserrorJS + TSCross-Origin Resource Sharing (CORS) policy should be restricted to trusted origins—
sonarjs/csrferrorJS + TSCSRF protections should not be disabled—
sonarjs/disabled-auto-escapingerrorJS + TSAuto-escaping in HTML template engines should not be disabled—
sonarjs/disabled-resource-integrityerrorJS + TSRemote artifacts should not be used without integrity checks—
sonarjs/dompurify-unsafe-configerrorJS + TSDOMPurify configuration should not be bypassable—
sonarjs/encryption-secure-modeerrorJS + TSEncryption algorithms should be used with secure mode and padding scheme—
sonarjs/file-permissionserrorJS + TSFile permissions should not be set to world-accessible values—
sonarjs/file-uploadserrorJS + TSFile uploads should be restricted—
sonarjs/frame-ancestorsoffJS + TSContent Security Policy frame-ancestors directive should not be disabledOff: not in the Sonar way profile of SonarQube.
sonarjs/hardcoded-secret-signatureserrorJS + TSCredentials should not be hard-coded—
sonarjs/hashingerrorJS + TSWeak hashing algorithms should not be used—
sonarjs/hidden-filesoffJS + TSHidden files should not be served staticallyOff: not in the Sonar way profile of SonarQube.
sonarjs/insecure-cookieerrorJS + TSCookies should have the "secure" flag—
sonarjs/insecure-jwt-tokenerrorJS + TSJWT should be signed and verified with strong cipher algorithms—
sonarjs/link-with-target-blankerrorJS + TSOpened windows should not have access to the originating page—
sonarjs/no-angular-bypass-sanitizationerrorJS + TSAngular built-in sanitization should not be disabled—
sonarjs/no-clear-text-protocolswarnJS + TSClear-text protocols should not be usedWarn: a SonarQube security hotspot: to review, a local URL may be fine.
sonarjs/no-hardcoded-ipwarnJS + TSIP addresses should not be hardcodedWarn: a SonarQube security hotspot: to review, a documented example may be fine.
sonarjs/no-hardcoded-passwordserrorJS + TSCredentials should not be hard-coded—
sonarjs/no-hardcoded-secretserrorJS + TSSecrets should not be hard-coded—
sonarjs/no-intrusive-permissionsoffJS + TSSensitive permissions should not be requested unnecessarilyOff: not in the Sonar way profile of SonarQube.
sonarjs/no-ip-forwardoffJS + TSClient IP address should not be forwarded to proxiesOff: not in the Sonar way profile of SonarQube.
sonarjs/no-mime-snifferrorJS + TSBrowsers should not be allowed to perform MIME type sniffing—
sonarjs/no-mixed-contentoffJS + TSContent Security Policy should block mixed-contentOff: not in the Sonar way profile of SonarQube.
sonarjs/no-os-command-from-patherrorJS + TSOS commands should not rely on PATH resolution—
sonarjs/no-referrer-policyerrorJS + TSHTTP Referrer-Policy should not be set to an unsafe value—
sonarjs/no-session-cookies-on-static-assetserrorJS + TSStatic Assets should not serve session cookies—
sonarjs/no-unsafe-unzipoffJS + TSExpanding archive files should not be done without controlling resource consumptionOff: not in the Sonar way profile of SonarQube.
sonarjs/no-weak-ciphererrorJS + TSCipher algorithms should be robust—
sonarjs/no-weak-keyserrorJS + TSCryptographic keys should be robust—
sonarjs/os-commandoffJS + TSOS commands should not be executed using a shell interpreterOff: not in the Sonar way profile of SonarQube.
sonarjs/post-messageerrorJS + TSOrigins should be verified during cross-origin communications—
sonarjs/production-debugerrorJS + TSDebugging features should not be enabled in production—
sonarjs/pseudo-randomwarnJS + TSPseudorandom number generators (PRNGs) should not be used in security contextsWarn: a SonarQube security hotspot: to review, Math.random is fine outside security.
sonarjs/publicly-writable-directorieserrorJS + TSTemporary files should not be created in publicly writable directories—
sonarjs/session-regenerationerrorJS + TSA new session should be created during user authentication—
sonarjs/slow-regexerrorJS + TSRegular expressions should not cause catastrophic backtracking—
sonarjs/sql-querieserrorJS + TSSQL queries should not be dynamically formatted—
sonarjs/strict-transport-securityerrorJS + TSHTTP Strict-Transport-Security policy should not be disabled—
sonarjs/unverified-certificateerrorJS + TSServer certificates should be verified during SSL/TLS connections—
sonarjs/unverified-hostnameerrorJS + TSServer hostnames should be verified during SSL/TLS connections—
sonarjs/weak-sslerrorJS + TSWeak SSL/TLS protocols should not be used—
sonarjs/web-sql-databaseoffJS + TSWeb SQL databases should not be usedOff: not in the Sonar way profile of SonarQube.
sonarjs/x-powered-byerrorJS + TSWeb application technologies should not disclose version information—
sonarjs/xml-parser-xxeerrorJS + TSXML parsers should not be vulnerable to XXE attacks—
no-implied-evaloffTSDisallow the use of eval()-like methodsReplaced by the TS version.
@typescript-eslint/no-implied-evalerrorTSDisallow the use of eval()-like functions—

Generated from the JSDoc of the sources.