eslint-plugin-secure-coding 2.3.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/index.d.ts +32 -0
- package/src/index.js +416 -0
- package/src/rules/detect-child-process/index.d.ts +11 -0
- package/src/rules/detect-child-process/index.js +529 -0
- package/src/rules/detect-eval-with-expression/index.d.ts +9 -0
- package/src/rules/detect-eval-with-expression/index.js +392 -0
- package/src/rules/detect-mixed-content/index.d.ts +8 -0
- package/src/rules/detect-mixed-content/index.js +44 -0
- package/src/rules/detect-non-literal-fs-filename/index.d.ts +7 -0
- package/src/rules/detect-non-literal-fs-filename/index.js +454 -0
- package/src/rules/detect-non-literal-regexp/index.d.ts +9 -0
- package/src/rules/detect-non-literal-regexp/index.js +403 -0
- package/src/rules/detect-object-injection/index.d.ts +11 -0
- package/src/rules/detect-object-injection/index.js +560 -0
- package/src/rules/detect-suspicious-dependencies/index.d.ts +8 -0
- package/src/rules/detect-suspicious-dependencies/index.js +71 -0
- package/src/rules/detect-weak-password-validation/index.d.ts +6 -0
- package/src/rules/detect-weak-password-validation/index.js +58 -0
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +8 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +47 -0
- package/src/rules/no-arbitrary-file-access/index.d.ts +13 -0
- package/src/rules/no-arbitrary-file-access/index.js +195 -0
- package/src/rules/no-buffer-overread/index.d.ts +29 -0
- package/src/rules/no-buffer-overread/index.js +606 -0
- package/src/rules/no-clickjacking/index.d.ts +10 -0
- package/src/rules/no-clickjacking/index.js +396 -0
- package/src/rules/no-client-side-auth-logic/index.d.ts +6 -0
- package/src/rules/no-client-side-auth-logic/index.js +69 -0
- package/src/rules/no-credentials-in-query-params/index.d.ts +8 -0
- package/src/rules/no-credentials-in-query-params/index.js +57 -0
- package/src/rules/no-data-in-temp-storage/index.d.ts +6 -0
- package/src/rules/no-data-in-temp-storage/index.js +64 -0
- package/src/rules/no-debug-code-in-production/index.d.ts +8 -0
- package/src/rules/no-debug-code-in-production/index.js +51 -0
- package/src/rules/no-directive-injection/index.d.ts +12 -0
- package/src/rules/no-directive-injection/index.js +457 -0
- package/src/rules/no-disabled-certificate-validation/index.d.ts +6 -0
- package/src/rules/no-disabled-certificate-validation/index.js +61 -0
- package/src/rules/no-dynamic-dependency-loading/index.d.ts +8 -0
- package/src/rules/no-dynamic-dependency-loading/index.js +51 -0
- package/src/rules/no-electron-security-issues/index.d.ts +10 -0
- package/src/rules/no-electron-security-issues/index.js +423 -0
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +6 -0
- package/src/rules/no-exposed-debug-endpoints/index.js +62 -0
- package/src/rules/no-exposed-sensitive-data/index.d.ts +11 -0
- package/src/rules/no-exposed-sensitive-data/index.js +340 -0
- package/src/rules/no-format-string-injection/index.d.ts +17 -0
- package/src/rules/no-format-string-injection/index.js +660 -0
- package/src/rules/no-graphql-injection/index.d.ts +12 -0
- package/src/rules/no-graphql-injection/index.js +411 -0
- package/src/rules/no-hardcoded-credentials/index.d.ts +26 -0
- package/src/rules/no-hardcoded-credentials/index.js +376 -0
- package/src/rules/no-hardcoded-session-tokens/index.d.ts +6 -0
- package/src/rules/no-hardcoded-session-tokens/index.js +59 -0
- package/src/rules/no-http-urls/index.d.ts +12 -0
- package/src/rules/no-http-urls/index.js +114 -0
- package/src/rules/no-improper-sanitization/index.d.ts +12 -0
- package/src/rules/no-improper-sanitization/index.js +411 -0
- package/src/rules/no-improper-type-validation/index.d.ts +10 -0
- package/src/rules/no-improper-type-validation/index.js +475 -0
- package/src/rules/no-insecure-comparison/index.d.ts +7 -0
- package/src/rules/no-insecure-comparison/index.js +193 -0
- package/src/rules/no-insecure-redirects/index.d.ts +7 -0
- package/src/rules/no-insecure-redirects/index.js +216 -0
- package/src/rules/no-insecure-websocket/index.d.ts +6 -0
- package/src/rules/no-insecure-websocket/index.js +61 -0
- package/src/rules/no-ldap-injection/index.d.ts +10 -0
- package/src/rules/no-ldap-injection/index.js +455 -0
- package/src/rules/no-missing-authentication/index.d.ts +13 -0
- package/src/rules/no-missing-authentication/index.js +333 -0
- package/src/rules/no-missing-cors-check/index.d.ts +9 -0
- package/src/rules/no-missing-cors-check/index.js +399 -0
- package/src/rules/no-missing-csrf-protection/index.d.ts +11 -0
- package/src/rules/no-missing-csrf-protection/index.js +180 -0
- package/src/rules/no-missing-security-headers/index.d.ts +7 -0
- package/src/rules/no-missing-security-headers/index.js +218 -0
- package/src/rules/no-password-in-url/index.d.ts +8 -0
- package/src/rules/no-password-in-url/index.js +54 -0
- package/src/rules/no-permissive-cors/index.d.ts +8 -0
- package/src/rules/no-permissive-cors/index.js +65 -0
- package/src/rules/no-pii-in-logs/index.d.ts +8 -0
- package/src/rules/no-pii-in-logs/index.js +70 -0
- package/src/rules/no-privilege-escalation/index.d.ts +13 -0
- package/src/rules/no-privilege-escalation/index.js +321 -0
- package/src/rules/no-redos-vulnerable-regex/index.d.ts +7 -0
- package/src/rules/no-redos-vulnerable-regex/index.js +306 -0
- package/src/rules/no-sensitive-data-exposure/index.d.ts +11 -0
- package/src/rules/no-sensitive-data-exposure/index.js +250 -0
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +8 -0
- package/src/rules/no-sensitive-data-in-analytics/index.js +62 -0
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +8 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +52 -0
- package/src/rules/no-toctou-vulnerability/index.d.ts +7 -0
- package/src/rules/no-toctou-vulnerability/index.js +208 -0
- package/src/rules/no-tracking-without-consent/index.d.ts +6 -0
- package/src/rules/no-tracking-without-consent/index.js +67 -0
- package/src/rules/no-unchecked-loop-condition/index.d.ts +12 -0
- package/src/rules/no-unchecked-loop-condition/index.js +646 -0
- package/src/rules/no-unencrypted-transmission/index.d.ts +11 -0
- package/src/rules/no-unencrypted-transmission/index.js +236 -0
- package/src/rules/no-unescaped-url-parameter/index.d.ts +9 -0
- package/src/rules/no-unescaped-url-parameter/index.js +355 -0
- package/src/rules/no-unlimited-resource-allocation/index.d.ts +12 -0
- package/src/rules/no-unlimited-resource-allocation/index.js +643 -0
- package/src/rules/no-unsafe-deserialization/index.d.ts +10 -0
- package/src/rules/no-unsafe-deserialization/index.js +491 -0
- package/src/rules/no-unsafe-dynamic-require/index.d.ts +5 -0
- package/src/rules/no-unsafe-dynamic-require/index.js +106 -0
- package/src/rules/no-unsafe-regex-construction/index.d.ts +9 -0
- package/src/rules/no-unsafe-regex-construction/index.js +291 -0
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +6 -0
- package/src/rules/no-unvalidated-deeplinks/index.js +62 -0
- package/src/rules/no-unvalidated-user-input/index.d.ts +9 -0
- package/src/rules/no-unvalidated-user-input/index.js +420 -0
- package/src/rules/no-verbose-error-messages/index.d.ts +8 -0
- package/src/rules/no-verbose-error-messages/index.js +68 -0
- package/src/rules/no-weak-password-recovery/index.d.ts +12 -0
- package/src/rules/no-weak-password-recovery/index.js +424 -0
- package/src/rules/no-xpath-injection/index.d.ts +10 -0
- package/src/rules/no-xpath-injection/index.js +487 -0
- package/src/rules/no-xxe-injection/index.d.ts +7 -0
- package/src/rules/no-xxe-injection/index.js +266 -0
- package/src/rules/no-zip-slip/index.d.ts +9 -0
- package/src/rules/no-zip-slip/index.js +445 -0
- package/src/rules/require-backend-authorization/index.d.ts +6 -0
- package/src/rules/require-backend-authorization/index.js +60 -0
- package/src/rules/require-code-minification/index.d.ts +8 -0
- package/src/rules/require-code-minification/index.js +47 -0
- package/src/rules/require-csp-headers/index.d.ts +6 -0
- package/src/rules/require-csp-headers/index.js +64 -0
- package/src/rules/require-data-minimization/index.d.ts +8 -0
- package/src/rules/require-data-minimization/index.js +53 -0
- package/src/rules/require-dependency-integrity/index.d.ts +6 -0
- package/src/rules/require-dependency-integrity/index.js +64 -0
- package/src/rules/require-https-only/index.d.ts +8 -0
- package/src/rules/require-https-only/index.js +62 -0
- package/src/rules/require-mime-type-validation/index.d.ts +6 -0
- package/src/rules/require-mime-type-validation/index.js +66 -0
- package/src/rules/require-network-timeout/index.d.ts +8 -0
- package/src/rules/require-network-timeout/index.js +50 -0
- package/src/rules/require-package-lock/index.d.ts +8 -0
- package/src/rules/require-package-lock/index.js +63 -0
- package/src/rules/require-secure-credential-storage/index.d.ts +8 -0
- package/src/rules/require-secure-credential-storage/index.js +50 -0
- package/src/rules/require-secure-defaults/index.d.ts +8 -0
- package/src/rules/require-secure-defaults/index.js +47 -0
- package/src/rules/require-secure-deletion/index.d.ts +8 -0
- package/src/rules/require-secure-deletion/index.js +44 -0
- package/src/rules/require-storage-encryption/index.d.ts +8 -0
- package/src/rules/require-storage-encryption/index.js +50 -0
- package/src/rules/require-url-validation/index.d.ts +6 -0
- package/src/rules/require-url-validation/index.js +72 -0
- package/src/types/index.d.ts +106 -0
- package/src/types/index.js +16 -0
- package/src/index.ts +0 -605
- package/src/rules/__tests__/integration-demo.test.ts +0 -290
- package/src/rules/__tests__/integration-llm.test.ts +0 -89
- package/src/rules/database-injection/database-injection.test.ts +0 -456
- package/src/rules/database-injection/index.ts +0 -488
- package/src/rules/detect-child-process/detect-child-process.test.ts +0 -207
- package/src/rules/detect-child-process/index.ts +0 -634
- package/src/rules/detect-eval-with-expression/detect-eval-with-expression.test.ts +0 -416
- package/src/rules/detect-eval-with-expression/index.ts +0 -463
- package/src/rules/detect-mixed-content/detect-mixed-content.test.ts +0 -28
- package/src/rules/detect-mixed-content/index.ts +0 -52
- package/src/rules/detect-non-literal-fs-filename/detect-non-literal-fs-filename.test.ts +0 -269
- package/src/rules/detect-non-literal-fs-filename/index.ts +0 -551
- package/src/rules/detect-non-literal-regexp/detect-non-literal-regexp.test.ts +0 -189
- package/src/rules/detect-non-literal-regexp/index.ts +0 -490
- package/src/rules/detect-object-injection/detect-object-injection.test.ts +0 -440
- package/src/rules/detect-object-injection/index.ts +0 -674
- package/src/rules/detect-suspicious-dependencies/detect-suspicious-dependencies.test.ts +0 -32
- package/src/rules/detect-suspicious-dependencies/index.ts +0 -84
- package/src/rules/detect-weak-password-validation/detect-weak-password-validation.test.ts +0 -31
- package/src/rules/detect-weak-password-validation/index.ts +0 -68
- package/src/rules/no-allow-arbitrary-loads/index.ts +0 -54
- package/src/rules/no-allow-arbitrary-loads/no-allow-arbitrary-loads.test.ts +0 -28
- package/src/rules/no-arbitrary-file-access/index.ts +0 -238
- package/src/rules/no-arbitrary-file-access/no-arbitrary-file-access.test.ts +0 -119
- package/src/rules/no-buffer-overread/index.ts +0 -724
- package/src/rules/no-buffer-overread/no-buffer-overread.test.ts +0 -313
- package/src/rules/no-clickjacking/index.ts +0 -481
- package/src/rules/no-clickjacking/no-clickjacking.test.ts +0 -253
- package/src/rules/no-client-side-auth-logic/index.ts +0 -81
- package/src/rules/no-client-side-auth-logic/no-client-side-auth-logic.test.ts +0 -33
- package/src/rules/no-credentials-in-query-params/index.ts +0 -69
- package/src/rules/no-credentials-in-query-params/no-credentials-in-query-params.test.ts +0 -33
- package/src/rules/no-credentials-in-storage-api/index.ts +0 -64
- package/src/rules/no-credentials-in-storage-api/no-credentials-in-storage-api.test.ts +0 -31
- package/src/rules/no-data-in-temp-storage/index.ts +0 -75
- package/src/rules/no-data-in-temp-storage/no-data-in-temp-storage.test.ts +0 -33
- package/src/rules/no-debug-code-in-production/index.ts +0 -59
- package/src/rules/no-debug-code-in-production/no-debug-code-in-production.test.ts +0 -26
- package/src/rules/no-directive-injection/index.ts +0 -551
- package/src/rules/no-directive-injection/no-directive-injection.test.ts +0 -305
- package/src/rules/no-disabled-certificate-validation/index.ts +0 -72
- package/src/rules/no-disabled-certificate-validation/no-disabled-certificate-validation.test.ts +0 -33
- package/src/rules/no-document-cookie/index.ts +0 -113
- package/src/rules/no-document-cookie/no-document-cookie.test.ts +0 -382
- package/src/rules/no-dynamic-dependency-loading/index.ts +0 -60
- package/src/rules/no-dynamic-dependency-loading/no-dynamic-dependency-loading.test.ts +0 -27
- package/src/rules/no-electron-security-issues/index.ts +0 -504
- package/src/rules/no-electron-security-issues/no-electron-security-issues.test.ts +0 -324
- package/src/rules/no-exposed-debug-endpoints/index.ts +0 -73
- package/src/rules/no-exposed-debug-endpoints/no-exposed-debug-endpoints.test.ts +0 -40
- package/src/rules/no-exposed-sensitive-data/index.ts +0 -428
- package/src/rules/no-exposed-sensitive-data/no-exposed-sensitive-data.test.ts +0 -75
- package/src/rules/no-format-string-injection/index.ts +0 -801
- package/src/rules/no-format-string-injection/no-format-string-injection.test.ts +0 -437
- package/src/rules/no-graphql-injection/index.ts +0 -508
- package/src/rules/no-graphql-injection/no-graphql-injection.test.ts +0 -371
- package/src/rules/no-hardcoded-credentials/index.ts +0 -478
- package/src/rules/no-hardcoded-credentials/no-hardcoded-credentials.test.ts +0 -639
- package/src/rules/no-hardcoded-session-tokens/index.ts +0 -69
- package/src/rules/no-hardcoded-session-tokens/no-hardcoded-session-tokens.test.ts +0 -42
- package/src/rules/no-http-urls/index.ts +0 -131
- package/src/rules/no-http-urls/no-http-urls.test.ts +0 -60
- package/src/rules/no-improper-sanitization/index.ts +0 -502
- package/src/rules/no-improper-sanitization/no-improper-sanitization.test.ts +0 -156
- package/src/rules/no-improper-type-validation/index.ts +0 -572
- package/src/rules/no-improper-type-validation/no-improper-type-validation.test.ts +0 -372
- package/src/rules/no-insecure-comparison/index.ts +0 -232
- package/src/rules/no-insecure-comparison/no-insecure-comparison.test.ts +0 -218
- package/src/rules/no-insecure-cookie-settings/index.ts +0 -391
- package/src/rules/no-insecure-cookie-settings/no-insecure-cookie-settings.test.ts +0 -409
- package/src/rules/no-insecure-jwt/index.ts +0 -467
- package/src/rules/no-insecure-jwt/no-insecure-jwt.test.ts +0 -259
- package/src/rules/no-insecure-redirects/index.ts +0 -267
- package/src/rules/no-insecure-redirects/no-insecure-redirects.test.ts +0 -108
- package/src/rules/no-insecure-websocket/index.ts +0 -72
- package/src/rules/no-insecure-websocket/no-insecure-websocket.test.ts +0 -42
- package/src/rules/no-insufficient-postmessage-validation/index.ts +0 -497
- package/src/rules/no-insufficient-postmessage-validation/no-insufficient-postmessage-validation.test.ts +0 -360
- package/src/rules/no-insufficient-random/index.ts +0 -288
- package/src/rules/no-insufficient-random/no-insufficient-random.test.ts +0 -246
- package/src/rules/no-ldap-injection/index.ts +0 -547
- package/src/rules/no-ldap-injection/no-ldap-injection.test.ts +0 -317
- package/src/rules/no-missing-authentication/index.ts +0 -408
- package/src/rules/no-missing-authentication/no-missing-authentication.test.ts +0 -350
- package/src/rules/no-missing-cors-check/index.ts +0 -453
- package/src/rules/no-missing-cors-check/no-missing-cors-check.test.ts +0 -392
- package/src/rules/no-missing-csrf-protection/index.ts +0 -229
- package/src/rules/no-missing-csrf-protection/no-missing-csrf-protection.test.ts +0 -222
- package/src/rules/no-missing-security-headers/index.ts +0 -266
- package/src/rules/no-missing-security-headers/no-missing-security-headers.test.ts +0 -98
- package/src/rules/no-password-in-url/index.ts +0 -64
- package/src/rules/no-password-in-url/no-password-in-url.test.ts +0 -27
- package/src/rules/no-permissive-cors/index.ts +0 -78
- package/src/rules/no-permissive-cors/no-permissive-cors.test.ts +0 -28
- package/src/rules/no-pii-in-logs/index.ts +0 -83
- package/src/rules/no-pii-in-logs/no-pii-in-logs.test.ts +0 -26
- package/src/rules/no-postmessage-origin-wildcard/index.ts +0 -67
- package/src/rules/no-postmessage-origin-wildcard/no-postmessage-origin-wildcard.test.ts +0 -27
- package/src/rules/no-privilege-escalation/index.ts +0 -403
- package/src/rules/no-privilege-escalation/no-privilege-escalation.test.ts +0 -306
- package/src/rules/no-redos-vulnerable-regex/index.ts +0 -379
- package/src/rules/no-redos-vulnerable-regex/no-redos-vulnerable-regex.test.ts +0 -83
- package/src/rules/no-sensitive-data-exposure/index.ts +0 -294
- package/src/rules/no-sensitive-data-exposure/no-sensitive-data-exposure.test.ts +0 -262
- package/src/rules/no-sensitive-data-in-analytics/index.ts +0 -73
- package/src/rules/no-sensitive-data-in-analytics/no-sensitive-data-in-analytics.test.ts +0 -42
- package/src/rules/no-sensitive-data-in-cache/index.ts +0 -59
- package/src/rules/no-sensitive-data-in-cache/no-sensitive-data-in-cache.test.ts +0 -32
- package/src/rules/no-sql-injection/index.ts +0 -424
- package/src/rules/no-sql-injection/no-sql-injection.test.ts +0 -303
- package/src/rules/no-timing-attack/index.ts +0 -552
- package/src/rules/no-timing-attack/no-timing-attack.test.ts +0 -348
- package/src/rules/no-toctou-vulnerability/index.ts +0 -250
- package/src/rules/no-toctou-vulnerability/no-toctou-vulnerability.test.ts +0 -60
- package/src/rules/no-tracking-without-consent/index.ts +0 -78
- package/src/rules/no-tracking-without-consent/no-tracking-without-consent.test.ts +0 -34
- package/src/rules/no-unchecked-loop-condition/index.ts +0 -781
- package/src/rules/no-unchecked-loop-condition/no-unchecked-loop-condition.test.ts +0 -459
- package/src/rules/no-unencrypted-local-storage/index.ts +0 -73
- package/src/rules/no-unencrypted-local-storage/no-unencrypted-local-storage.test.ts +0 -41
- package/src/rules/no-unencrypted-transmission/index.ts +0 -296
- package/src/rules/no-unencrypted-transmission/no-unencrypted-transmission.test.ts +0 -287
- package/src/rules/no-unescaped-url-parameter/index.ts +0 -424
- package/src/rules/no-unescaped-url-parameter/no-unescaped-url-parameter.test.ts +0 -263
- package/src/rules/no-unlimited-resource-allocation/index.ts +0 -767
- package/src/rules/no-unlimited-resource-allocation/no-unlimited-resource-allocation.test.ts +0 -544
- package/src/rules/no-unsafe-deserialization/index.ts +0 -593
- package/src/rules/no-unsafe-deserialization/no-unsafe-deserialization.test.ts +0 -310
- package/src/rules/no-unsafe-dynamic-require/index.ts +0 -125
- package/src/rules/no-unsafe-dynamic-require/no-unsafe-dynamic-require.test.ts +0 -151
- package/src/rules/no-unsafe-regex-construction/index.ts +0 -370
- package/src/rules/no-unsafe-regex-construction/no-unsafe-regex-construction.test.ts +0 -181
- package/src/rules/no-unsanitized-html/index.ts +0 -400
- package/src/rules/no-unsanitized-html/no-unsanitized-html.test.ts +0 -488
- package/src/rules/no-unvalidated-deeplinks/index.ts +0 -73
- package/src/rules/no-unvalidated-deeplinks/no-unvalidated-deeplinks.test.ts +0 -29
- package/src/rules/no-unvalidated-user-input/index.ts +0 -498
- package/src/rules/no-unvalidated-user-input/no-unvalidated-user-input.test.ts +0 -463
- package/src/rules/no-verbose-error-messages/index.ts +0 -83
- package/src/rules/no-verbose-error-messages/no-verbose-error-messages.test.ts +0 -34
- package/src/rules/no-weak-crypto/index.ts +0 -447
- package/src/rules/no-weak-crypto/no-weak-crypto.test.ts +0 -297
- package/src/rules/no-weak-password-recovery/index.ts +0 -509
- package/src/rules/no-weak-password-recovery/no-weak-password-recovery.test.ts +0 -184
- package/src/rules/no-xpath-injection/index.ts +0 -596
- package/src/rules/no-xpath-injection/no-xpath-injection.test.ts +0 -405
- package/src/rules/no-xxe-injection/index.ts +0 -342
- package/src/rules/no-xxe-injection/no-xxe-injection.test.ts +0 -122
- package/src/rules/no-zip-slip/index.ts +0 -526
- package/src/rules/no-zip-slip/no-zip-slip.test.ts +0 -305
- package/src/rules/require-backend-authorization/index.ts +0 -71
- package/src/rules/require-backend-authorization/require-backend-authorization.test.ts +0 -31
- package/src/rules/require-code-minification/index.ts +0 -54
- package/src/rules/require-code-minification/require-code-minification.test.ts +0 -30
- package/src/rules/require-csp-headers/index.ts +0 -74
- package/src/rules/require-csp-headers/require-csp-headers.test.ts +0 -34
- package/src/rules/require-data-minimization/index.ts +0 -65
- package/src/rules/require-data-minimization/require-data-minimization.test.ts +0 -31
- package/src/rules/require-dependency-integrity/index.ts +0 -78
- package/src/rules/require-dependency-integrity/require-dependency-integrity.test.ts +0 -44
- package/src/rules/require-https-only/index.ts +0 -75
- package/src/rules/require-https-only/require-https-only.test.ts +0 -26
- package/src/rules/require-mime-type-validation/index.ts +0 -77
- package/src/rules/require-mime-type-validation/require-mime-type-validation.test.ts +0 -32
- package/src/rules/require-network-timeout/index.ts +0 -58
- package/src/rules/require-network-timeout/require-network-timeout.test.ts +0 -26
- package/src/rules/require-package-lock/index.ts +0 -75
- package/src/rules/require-package-lock/require-package-lock.test.ts +0 -27
- package/src/rules/require-secure-credential-storage/index.ts +0 -60
- package/src/rules/require-secure-credential-storage/require-secure-credential-storage.test.ts +0 -26
- package/src/rules/require-secure-defaults/index.ts +0 -54
- package/src/rules/require-secure-defaults/require-secure-defaults.test.ts +0 -26
- package/src/rules/require-secure-deletion/index.ts +0 -52
- package/src/rules/require-secure-deletion/require-secure-deletion.test.ts +0 -29
- package/src/rules/require-storage-encryption/index.ts +0 -60
- package/src/rules/require-storage-encryption/require-storage-encryption.test.ts +0 -26
- package/src/rules/require-url-validation/index.ts +0 -85
- package/src/rules/require-url-validation/require-url-validation.test.ts +0 -32
- package/src/types/index.ts +0 -235
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comprehensive tests for no-unchecked-loop-condition rule
|
|
3
|
-
* Security: CWE-400 (Uncontrolled Resource Consumption), CWE-606 (Unchecked Input for Loop Condition)
|
|
4
|
-
*/
|
|
5
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
6
|
-
import { describe, it, afterAll } from 'vitest';
|
|
7
|
-
import parser from '@typescript-eslint/parser';
|
|
8
|
-
import { noUncheckedLoopCondition } from './index';
|
|
9
|
-
|
|
10
|
-
// Configure RuleTester for Vitest
|
|
11
|
-
RuleTester.afterAll = afterAll;
|
|
12
|
-
RuleTester.it = it;
|
|
13
|
-
RuleTester.itOnly = it.only;
|
|
14
|
-
RuleTester.describe = describe;
|
|
15
|
-
|
|
16
|
-
// Use Flat Config format (ESLint 9+)
|
|
17
|
-
const ruleTester = new RuleTester({
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser,
|
|
20
|
-
ecmaVersion: 2022,
|
|
21
|
-
sourceType: 'module',
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('no-unchecked-loop-condition', () => {
|
|
26
|
-
describe('Valid Code', () => {
|
|
27
|
-
ruleTester.run('valid - safe loop conditions', noUncheckedLoopCondition, {
|
|
28
|
-
valid: [
|
|
29
|
-
// Safe for loops with clear bounds
|
|
30
|
-
{
|
|
31
|
-
code: 'for (let i = 0; i < 10; i++) { console.log(i); }',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
code: 'for (let i = 0; i < items.length; i++) { processItem(items[i]); }',
|
|
35
|
-
},
|
|
36
|
-
// Safe while loops with conditions
|
|
37
|
-
{
|
|
38
|
-
code: 'while (condition && attempts < 3) { attemptOperation(); attempts++; }',
|
|
39
|
-
},
|
|
40
|
-
// While true with break (allowed by default)
|
|
41
|
-
{
|
|
42
|
-
code: 'while (true) { processData(); if (shouldStop) break; }',
|
|
43
|
-
},
|
|
44
|
-
// Safe recursion with depth limit
|
|
45
|
-
{
|
|
46
|
-
code: 'function factorial(n, depth = 0) { if (depth > 10) return 1; return n * factorial(n-1, depth+1); }',
|
|
47
|
-
},
|
|
48
|
-
// Controlled iterations
|
|
49
|
-
{
|
|
50
|
-
code: 'const maxIterations = 100; for (let i = 0; i < maxIterations; i++) { /* work */ }',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
invalid: [],
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('Invalid Code - Infinite Loops', () => {
|
|
58
|
-
ruleTester.run('invalid - infinite loop patterns', noUncheckedLoopCondition, {
|
|
59
|
-
valid: [],
|
|
60
|
-
invalid: [
|
|
61
|
-
{
|
|
62
|
-
code: 'for (;;) { console.log("infinite"); }',
|
|
63
|
-
errors: [
|
|
64
|
-
{
|
|
65
|
-
messageId: 'infiniteLoop',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
code: 'while (true) { /* no break */ }',
|
|
71
|
-
options: [{ allowWhileTrueWithBreak: false }],
|
|
72
|
-
errors: [
|
|
73
|
-
{
|
|
74
|
-
messageId: 'infiniteLoop',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Invalid Code - User Controlled Loop Bounds', () => {
|
|
83
|
-
ruleTester.run('invalid - user controlled loop conditions', noUncheckedLoopCondition, {
|
|
84
|
-
valid: [],
|
|
85
|
-
invalid: [
|
|
86
|
-
{
|
|
87
|
-
code: 'for (let i = 0; i < req.query.limit; i++) { processItem(); }',
|
|
88
|
-
errors: [
|
|
89
|
-
{
|
|
90
|
-
messageId: 'userControlledLoopBound',
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
code: 'while (userInput-- > 0) { doWork(); }',
|
|
96
|
-
errors: [
|
|
97
|
-
{
|
|
98
|
-
messageId: 'userControlledLoopBound',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
code: 'const iterations = req.body.count; for (let i = 0; i < iterations; i++) { /* work */ }',
|
|
104
|
-
errors: [
|
|
105
|
-
{
|
|
106
|
-
messageId: 'userControlledLoopBound',
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe('Invalid Code - Complex User Input Expressions', () => {
|
|
115
|
-
ruleTester.run('invalid - complex expressions with user input', noUncheckedLoopCondition, {
|
|
116
|
-
valid: [],
|
|
117
|
-
invalid: [
|
|
118
|
-
{
|
|
119
|
-
code: 'while (-userInput > 0) { /* UnaryExpression */ process(); }',
|
|
120
|
-
errors: [{ messageId: 'userControlledLoopBound' }],
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
code: 'while (userInput++ < 100) { /* UpdateExpression */ process(); }',
|
|
124
|
-
errors: [{ messageId: 'userControlledLoopBound' }],
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
code: 'while (!userInput) { /* UnaryExpression ! */ process(); }',
|
|
128
|
-
errors: [{ messageId: 'userControlledLoopBound' }],
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
code: 'while (check(userInput)) { /* CallExpression with user input */ process(); }',
|
|
132
|
-
errors: [{ messageId: 'userControlledLoopBound' }],
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('Invalid Code - Large Loop Bounds', () => {
|
|
139
|
-
ruleTester.run('invalid - potentially large iteration counts', noUncheckedLoopCondition, {
|
|
140
|
-
valid: [],
|
|
141
|
-
invalid: [
|
|
142
|
-
{
|
|
143
|
-
code: 'for (let i = 0; i < 100000; i++) { processItem(); }',
|
|
144
|
-
errors: [
|
|
145
|
-
{
|
|
146
|
-
messageId: 'largeLoopBound',
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
code: 'for (let i = 0; i <= 50000; i++) { /* work */ }',
|
|
152
|
-
errors: [
|
|
153
|
-
{
|
|
154
|
-
messageId: 'largeLoopBound',
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe('Invalid Code - Missing Loop Termination', () => {
|
|
163
|
-
ruleTester.run('invalid - missing loop termination conditions', noUncheckedLoopCondition, {
|
|
164
|
-
valid: [],
|
|
165
|
-
invalid: [
|
|
166
|
-
{
|
|
167
|
-
code: 'for (let i = 0; ; i++) { if (i > 10) break; }', // Missing condition in for loop
|
|
168
|
-
errors: [
|
|
169
|
-
{
|
|
170
|
-
messageId: 'missingLoopTermination',
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('Invalid Code - Unsafe Recursion', () => {
|
|
179
|
-
ruleTester.run('invalid - unsafe recursive functions', noUncheckedLoopCondition, {
|
|
180
|
-
valid: [],
|
|
181
|
-
invalid: [
|
|
182
|
-
{
|
|
183
|
-
code: `
|
|
184
|
-
function recursiveFunc(n) {
|
|
185
|
-
if (n > 0) {
|
|
186
|
-
recursiveFunc(n - 1); // Recursion without depth limit
|
|
187
|
-
recursiveFunc(n - 1);
|
|
188
|
-
recursiveFunc(n - 1);
|
|
189
|
-
recursiveFunc(n - 1);
|
|
190
|
-
recursiveFunc(n - 1);
|
|
191
|
-
recursiveFunc(n - 1);
|
|
192
|
-
recursiveFunc(n - 1);
|
|
193
|
-
recursiveFunc(n - 1);
|
|
194
|
-
recursiveFunc(n - 1);
|
|
195
|
-
recursiveFunc(n - 1);
|
|
196
|
-
recursiveFunc(n - 1);
|
|
197
|
-
recursiveFunc(n - 1);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
`,
|
|
201
|
-
errors: [
|
|
202
|
-
{
|
|
203
|
-
messageId: 'unsafeRecursion',
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
],
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe('Invalid Code - Unchecked Collections', () => {
|
|
212
|
-
ruleTester.run('invalid - iteration over unchecked collections', noUncheckedLoopCondition, {
|
|
213
|
-
valid: [],
|
|
214
|
-
invalid: [
|
|
215
|
-
{
|
|
216
|
-
code: 'for (const item of req.body.items) { processItem(item); }',
|
|
217
|
-
errors: [
|
|
218
|
-
{
|
|
219
|
-
messageId: 'uncheckedLoopCondition',
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
code: 'for (const key in userInput) { console.log(key); }',
|
|
225
|
-
errors: [
|
|
226
|
-
{
|
|
227
|
-
messageId: 'uncheckedLoopCondition',
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('Valid Code - False Positives Reduced', () => {
|
|
236
|
-
ruleTester.run('valid - false positives reduced', noUncheckedLoopCondition, {
|
|
237
|
-
valid: [
|
|
238
|
-
// Safe annotations
|
|
239
|
-
{
|
|
240
|
-
code: `
|
|
241
|
-
/** @safe-loop */
|
|
242
|
-
while (true) {
|
|
243
|
-
processData();
|
|
244
|
-
if (shouldStop) break;
|
|
245
|
-
}
|
|
246
|
-
`,
|
|
247
|
-
},
|
|
248
|
-
// Controlled user input
|
|
249
|
-
{
|
|
250
|
-
code: `
|
|
251
|
-
const safeLimit = Math.min(req.query.limit, 100);
|
|
252
|
-
for (let i = 0; i < safeLimit; i++) { /* work */ }
|
|
253
|
-
`,
|
|
254
|
-
},
|
|
255
|
-
// Validated collections
|
|
256
|
-
{
|
|
257
|
-
code: `
|
|
258
|
-
if (Array.isArray(req.body.items) && req.body.items.length < 100) {
|
|
259
|
-
for (const item of req.body.items) { processItem(item); }
|
|
260
|
-
}
|
|
261
|
-
`,
|
|
262
|
-
},
|
|
263
|
-
// Small iteration counts
|
|
264
|
-
{
|
|
265
|
-
code: 'for (let i = 0; i < 100; i++) { /* safe small loop */ }',
|
|
266
|
-
},
|
|
267
|
-
// Controlled recursion
|
|
268
|
-
{
|
|
269
|
-
code: `
|
|
270
|
-
function safeRecursion(n, depth = 0) {
|
|
271
|
-
if (depth > 10) return; // Depth limit
|
|
272
|
-
if (n > 0) safeRecursion(n - 1, depth + 1);
|
|
273
|
-
}
|
|
274
|
-
`,
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
invalid: [],
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
describe('Configuration Options', () => {
|
|
282
|
-
ruleTester.run('config - custom max iterations', noUncheckedLoopCondition, {
|
|
283
|
-
valid: [
|
|
284
|
-
{
|
|
285
|
-
code: 'for (let i = 0; i < 500; i++) { /* within limit */ }',
|
|
286
|
-
options: [{ maxStaticIterations: 1000 }],
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
invalid: [
|
|
290
|
-
{
|
|
291
|
-
code: 'for (let i = 0; i < 1500; i++) { /* exceeds limit */ }',
|
|
292
|
-
options: [{ maxStaticIterations: 1000 }],
|
|
293
|
-
errors: [
|
|
294
|
-
{
|
|
295
|
-
messageId: 'largeLoopBound',
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
ruleTester.run('config - custom user input variables', noUncheckedLoopCondition, {
|
|
303
|
-
valid: [
|
|
304
|
-
{
|
|
305
|
-
code: 'for (let i = 0; i < customInput; i++) { /* not flagged */ }',
|
|
306
|
-
options: [{ userInputVariables: ['otherInput'] }],
|
|
307
|
-
},
|
|
308
|
-
],
|
|
309
|
-
invalid: [
|
|
310
|
-
{
|
|
311
|
-
code: 'while (customInput-- > 0) { /* flagged */ }',
|
|
312
|
-
options: [{ userInputVariables: ['customInput'] }],
|
|
313
|
-
errors: [
|
|
314
|
-
{
|
|
315
|
-
messageId: 'userControlledLoopBound',
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
ruleTester.run('config - disable while true with break', noUncheckedLoopCondition, {
|
|
323
|
-
valid: [],
|
|
324
|
-
invalid: [
|
|
325
|
-
{
|
|
326
|
-
code: 'while (true) { processData(); if (done) break; }',
|
|
327
|
-
options: [{ allowWhileTrueWithBreak: false }],
|
|
328
|
-
errors: [
|
|
329
|
-
{
|
|
330
|
-
messageId: 'infiniteLoop',
|
|
331
|
-
},
|
|
332
|
-
],
|
|
333
|
-
},
|
|
334
|
-
],
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
describe('Complex Loop Condition Scenarios', () => {
|
|
339
|
-
ruleTester.run('complex - real-world DoS loop patterns', noUncheckedLoopCondition, {
|
|
340
|
-
valid: [],
|
|
341
|
-
invalid: [
|
|
342
|
-
{
|
|
343
|
-
code: `
|
|
344
|
-
// ReDoS through user-controlled regex in loop
|
|
345
|
-
app.post('/search', (req, res) => {
|
|
346
|
-
const pattern = req.body.pattern;
|
|
347
|
-
const text = req.body.text;
|
|
348
|
-
|
|
349
|
-
// DANGEROUS: Loop controlled by regex that could cause catastrophic backtracking
|
|
350
|
-
while (text.match(pattern)) {
|
|
351
|
-
text = text.replace(pattern, '');
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
res.json({ result: text });
|
|
355
|
-
});
|
|
356
|
-
`,
|
|
357
|
-
errors: [
|
|
358
|
-
{
|
|
359
|
-
messageId: 'userControlledLoopBound',
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
code: `
|
|
365
|
-
// Resource exhaustion through large array operations
|
|
366
|
-
function processLargeArray(req, res) {
|
|
367
|
-
const data = req.body.data; // Could be millions of items
|
|
368
|
-
|
|
369
|
-
// DANGEROUS: No size limit on iteration
|
|
370
|
-
for (const item of data) {
|
|
371
|
-
expensiveOperation(item);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
res.json({ processed: data.length });
|
|
375
|
-
}
|
|
376
|
-
`,
|
|
377
|
-
errors: [
|
|
378
|
-
{
|
|
379
|
-
messageId: 'uncheckedLoopCondition',
|
|
380
|
-
},
|
|
381
|
-
],
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
code: `
|
|
385
|
-
// Infinite loop through state-dependent condition
|
|
386
|
-
let shouldContinue = true;
|
|
387
|
-
|
|
388
|
-
function processQueue() {
|
|
389
|
-
// DANGEROUS: Condition depends on external state that may never change
|
|
390
|
-
while (shouldContinue) {
|
|
391
|
-
const item = queue.shift();
|
|
392
|
-
if (!item) {
|
|
393
|
-
// Forgot to set shouldContinue = false!
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
processItem(item);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
`,
|
|
400
|
-
errors: [
|
|
401
|
-
{
|
|
402
|
-
messageId: 'infiniteLoop',
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
code: `
|
|
408
|
-
// Stack overflow through uncontrolled recursion
|
|
409
|
-
function traverseObject(obj, path = []) {
|
|
410
|
-
// DANGEROUS: No recursion depth limit
|
|
411
|
-
for (const key in obj) {
|
|
412
|
-
const value = obj[key];
|
|
413
|
-
const currentPath = [...path, key];
|
|
414
|
-
|
|
415
|
-
if (typeof value === 'object' && value !== null) {
|
|
416
|
-
// Deeply nested objects could cause stack overflow
|
|
417
|
-
traverseObject(value, currentPath);
|
|
418
|
-
} else {
|
|
419
|
-
processLeaf(currentPath, value);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
`,
|
|
424
|
-
errors: [
|
|
425
|
-
{
|
|
426
|
-
messageId: 'unsafeRecursion',
|
|
427
|
-
},
|
|
428
|
-
],
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
code: `
|
|
432
|
-
// DoS through user-controlled iteration bounds
|
|
433
|
-
app.get('/paginate', (req, res) => {
|
|
434
|
-
const pageSize = parseInt(req.query.pageSize) || 10;
|
|
435
|
-
const page = parseInt(req.query.page) || 0;
|
|
436
|
-
|
|
437
|
-
// DANGEROUS: pageSize could be 1e9, page could be negative
|
|
438
|
-
const startIndex = page * pageSize;
|
|
439
|
-
const endIndex = startIndex + pageSize;
|
|
440
|
-
|
|
441
|
-
const results = [];
|
|
442
|
-
for (let i = startIndex; i < endIndex; i++) {
|
|
443
|
-
if (i >= allData.length) break; // Too late!
|
|
444
|
-
results.push(allData[i]);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
res.json(results);
|
|
448
|
-
});
|
|
449
|
-
`,
|
|
450
|
-
errors: [
|
|
451
|
-
{
|
|
452
|
-
messageId: 'userControlledLoopBound',
|
|
453
|
-
},
|
|
454
|
-
],
|
|
455
|
-
},
|
|
456
|
-
],
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Prevent sensitive data in unencrypted local storage
|
|
3
|
-
* @see https://owasp.org/www-project-mobile-top-10/
|
|
4
|
-
* @see https://cwe.mitre.org/data/definitions/311.html
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createRule, formatLLMMessage, MessageIcons } from '@interlace/eslint-devkit';
|
|
8
|
-
import type { TSESTree } from '@interlace/eslint-devkit';
|
|
9
|
-
|
|
10
|
-
type MessageIds = 'violationDetected';
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface -- Rule has no configurable options
|
|
13
|
-
export interface Options {}
|
|
14
|
-
|
|
15
|
-
type RuleOptions = [Options?];
|
|
16
|
-
|
|
17
|
-
export const noUnencryptedLocalStorage = createRule<RuleOptions, MessageIds>({
|
|
18
|
-
name: 'no-unencrypted-local-storage',
|
|
19
|
-
meta: {
|
|
20
|
-
type: 'problem',
|
|
21
|
-
docs: {
|
|
22
|
-
description: 'Prevent sensitive data in unencrypted local storage',
|
|
23
|
-
category: 'Security',
|
|
24
|
-
recommended: true,
|
|
25
|
-
owaspMobile: ['M9'],
|
|
26
|
-
cweIds: ["CWE-311"],
|
|
27
|
-
},
|
|
28
|
-
messages: {
|
|
29
|
-
violationDetected: formatLLMMessage({
|
|
30
|
-
icon: MessageIcons.SECURITY,
|
|
31
|
-
issueName: 'violation Detected',
|
|
32
|
-
cwe: 'CWE-312',
|
|
33
|
-
description: 'Prevent sensitive data in unencrypted local storage detected - this is a security risk',
|
|
34
|
-
severity: 'HIGH',
|
|
35
|
-
fix: 'Review and apply secure practices',
|
|
36
|
-
documentationLink: 'https://cwe.mitre.org/data/definitions/312.html',
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
schema: [],
|
|
40
|
-
},
|
|
41
|
-
defaultOptions: [],
|
|
42
|
-
create(context) {
|
|
43
|
-
function report(node: TSESTree.Node) {
|
|
44
|
-
context.report({
|
|
45
|
-
node,
|
|
46
|
-
messageId: 'violationDetected',
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
CallExpression(node: TSESTree.CallExpression) {
|
|
52
|
-
|
|
53
|
-
// Similar to no-credentials-in-storage-api but broader
|
|
54
|
-
if (node.type === 'CallExpression' &&
|
|
55
|
-
node.callee.type === 'MemberExpression' &&
|
|
56
|
-
node.callee.property.name === 'setItem' &&
|
|
57
|
-
['localStorage', 'sessionStorage'].includes(node.callee.object.name)) {
|
|
58
|
-
|
|
59
|
-
const keyArg = node.arguments[0];
|
|
60
|
-
if (keyArg && keyArg.type === 'Literal') {
|
|
61
|
-
const key = keyArg.value.toString().toLowerCase();
|
|
62
|
-
const sensitiveKeys = ['creditcard', 'ssn', 'passport', 'license', 'medical', 'health'];
|
|
63
|
-
|
|
64
|
-
if (sensitiveKeys.some(k => key.includes(k))) {
|
|
65
|
-
report(node);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Tests for no-unencrypted-local-storage
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
6
|
-
import { noUnencryptedLocalStorage } from './index';
|
|
7
|
-
|
|
8
|
-
const ruleTester = new RuleTester({
|
|
9
|
-
languageOptions: {
|
|
10
|
-
ecmaVersion: 2022,
|
|
11
|
-
sourceType: 'module',
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
ruleTester.run('no-unencrypted-local-storage', noUnencryptedLocalStorage, {
|
|
16
|
-
valid: [
|
|
17
|
-
// Safe keys - not sensitive data
|
|
18
|
-
{ code: "localStorage.setItem('theme', 'dark')" },
|
|
19
|
-
{ code: "localStorage.setItem('language', 'en')" },
|
|
20
|
-
{ code: "sessionStorage.setItem('lastPage', '/home')" },
|
|
21
|
-
// Non-setItem methods
|
|
22
|
-
{ code: "localStorage.getItem('creditcard')" },
|
|
23
|
-
{ code: "const x = 1" },
|
|
24
|
-
],
|
|
25
|
-
|
|
26
|
-
invalid: [
|
|
27
|
-
// Credit card data
|
|
28
|
-
{ code: "localStorage.setItem('creditcard', cardNumber)", errors: [{ messageId: 'violationDetected' }] },
|
|
29
|
-
{ code: "localStorage.setItem('creditCard', '4111111111111111')", errors: [{ messageId: 'violationDetected' }] },
|
|
30
|
-
// SSN
|
|
31
|
-
{ code: "localStorage.setItem('ssn', userSSN)", errors: [{ messageId: 'violationDetected' }] },
|
|
32
|
-
{ code: "sessionStorage.setItem('userSSN', value)", errors: [{ messageId: 'violationDetected' }] },
|
|
33
|
-
// Passport
|
|
34
|
-
{ code: "localStorage.setItem('passport', passportNum)", errors: [{ messageId: 'violationDetected' }] },
|
|
35
|
-
// License
|
|
36
|
-
{ code: "localStorage.setItem('license', licNum)", errors: [{ messageId: 'violationDetected' }] },
|
|
37
|
-
// Medical/Health
|
|
38
|
-
{ code: "localStorage.setItem('medical', records)", errors: [{ messageId: 'violationDetected' }] },
|
|
39
|
-
{ code: "sessionStorage.setItem('health', data)", errors: [{ messageId: 'violationDetected' }] },
|
|
40
|
-
],
|
|
41
|
-
});
|