eslint-plugin-sdl-2 1.0.4
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 +5316 -0
- package/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/_internal/ast-utils.d.ts +17 -0
- package/dist/_internal/ast-utils.d.ts.map +1 -0
- package/dist/_internal/ast-utils.js +93 -0
- package/dist/_internal/ast-utils.js.map +1 -0
- package/dist/_internal/config-references.d.ts +5 -0
- package/dist/_internal/config-references.d.ts.map +1 -0
- package/dist/_internal/config-references.js +13 -0
- package/dist/_internal/config-references.js.map +1 -0
- package/dist/_internal/create-rule.d.ts +9 -0
- package/dist/_internal/create-rule.d.ts.map +1 -0
- package/dist/_internal/create-rule.js +6 -0
- package/dist/_internal/create-rule.js.map +1 -0
- package/dist/_internal/domparser.d.ts +19 -0
- package/dist/_internal/domparser.d.ts.map +1 -0
- package/dist/_internal/domparser.js +45 -0
- package/dist/_internal/domparser.js.map +1 -0
- package/dist/_internal/electron-web-preferences.d.ts +14 -0
- package/dist/_internal/electron-web-preferences.d.ts.map +1 -0
- package/dist/_internal/electron-web-preferences.js +63 -0
- package/dist/_internal/electron-web-preferences.js.map +1 -0
- package/dist/_internal/estree-utils.d.ts +51 -0
- package/dist/_internal/estree-utils.d.ts.map +1 -0
- package/dist/_internal/estree-utils.js +112 -0
- package/dist/_internal/estree-utils.js.map +1 -0
- package/dist/_internal/node-tls-config.d.ts +44 -0
- package/dist/_internal/node-tls-config.d.ts.map +1 -0
- package/dist/_internal/node-tls-config.js +101 -0
- package/dist/_internal/node-tls-config.js.map +1 -0
- package/dist/_internal/rules-registry.d.ts +10 -0
- package/dist/_internal/rules-registry.d.ts.map +1 -0
- package/dist/_internal/rules-registry.js +148 -0
- package/dist/_internal/rules-registry.js.map +1 -0
- package/dist/_internal/script-element.d.ts +7 -0
- package/dist/_internal/script-element.d.ts.map +1 -0
- package/dist/_internal/script-element.js +46 -0
- package/dist/_internal/script-element.js.map +1 -0
- package/dist/_internal/worker-code-loading.d.ts +69 -0
- package/dist/_internal/worker-code-loading.d.ts.map +1 -0
- package/dist/_internal/worker-code-loading.js +134 -0
- package/dist/_internal/worker-code-loading.js.map +1 -0
- package/dist/plugin.cjs +6036 -0
- package/dist/plugin.cjs.map +7 -0
- package/dist/plugin.d.cts +11 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +235 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/no-angular-bypass-sanitizer.d.ts +5 -0
- package/dist/rules/no-angular-bypass-sanitizer.d.ts.map +1 -0
- package/dist/rules/no-angular-bypass-sanitizer.js +32 -0
- package/dist/rules/no-angular-bypass-sanitizer.js.map +1 -0
- package/dist/rules/no-angular-bypass-security-trust-html.d.ts +5 -0
- package/dist/rules/no-angular-bypass-security-trust-html.d.ts.map +1 -0
- package/dist/rules/no-angular-bypass-security-trust-html.js +51 -0
- package/dist/rules/no-angular-bypass-security-trust-html.js.map +1 -0
- package/dist/rules/no-angular-innerhtml-binding.d.ts +5 -0
- package/dist/rules/no-angular-innerhtml-binding.d.ts.map +1 -0
- package/dist/rules/no-angular-innerhtml-binding.js +57 -0
- package/dist/rules/no-angular-innerhtml-binding.js.map +1 -0
- package/dist/rules/no-angular-sanitization-trusted-urls.d.ts +5 -0
- package/dist/rules/no-angular-sanitization-trusted-urls.d.ts.map +1 -0
- package/dist/rules/no-angular-sanitization-trusted-urls.js +32 -0
- package/dist/rules/no-angular-sanitization-trusted-urls.js.map +1 -0
- package/dist/rules/no-angularjs-bypass-sce.d.ts +5 -0
- package/dist/rules/no-angularjs-bypass-sce.d.ts.map +1 -0
- package/dist/rules/no-angularjs-bypass-sce.js +80 -0
- package/dist/rules/no-angularjs-bypass-sce.js.map +1 -0
- package/dist/rules/no-angularjs-enable-svg.d.ts +5 -0
- package/dist/rules/no-angularjs-enable-svg.d.ts.map +1 -0
- package/dist/rules/no-angularjs-enable-svg.js +48 -0
- package/dist/rules/no-angularjs-enable-svg.js.map +1 -0
- package/dist/rules/no-angularjs-ng-bind-html-without-sanitize.d.ts +5 -0
- package/dist/rules/no-angularjs-ng-bind-html-without-sanitize.d.ts.map +1 -0
- package/dist/rules/no-angularjs-ng-bind-html-without-sanitize.js +64 -0
- package/dist/rules/no-angularjs-ng-bind-html-without-sanitize.js.map +1 -0
- package/dist/rules/no-angularjs-sanitization-whitelist.d.ts +5 -0
- package/dist/rules/no-angularjs-sanitization-whitelist.d.ts.map +1 -0
- package/dist/rules/no-angularjs-sanitization-whitelist.js +32 -0
- package/dist/rules/no-angularjs-sanitization-whitelist.js.map +1 -0
- package/dist/rules/no-angularjs-sce-resource-url-wildcard.d.ts +5 -0
- package/dist/rules/no-angularjs-sce-resource-url-wildcard.d.ts.map +1 -0
- package/dist/rules/no-angularjs-sce-resource-url-wildcard.js +69 -0
- package/dist/rules/no-angularjs-sce-resource-url-wildcard.js.map +1 -0
- package/dist/rules/no-child-process-exec.d.ts +5 -0
- package/dist/rules/no-child-process-exec.d.ts.map +1 -0
- package/dist/rules/no-child-process-exec.js +141 -0
- package/dist/rules/no-child-process-exec.js.map +1 -0
- package/dist/rules/no-child-process-shell-true.d.ts +5 -0
- package/dist/rules/no-child-process-shell-true.d.ts.map +1 -0
- package/dist/rules/no-child-process-shell-true.js +89 -0
- package/dist/rules/no-child-process-shell-true.js.map +1 -0
- package/dist/rules/no-cookies.d.ts +5 -0
- package/dist/rules/no-cookies.d.ts.map +1 -0
- package/dist/rules/no-cookies.js +38 -0
- package/dist/rules/no-cookies.js.map +1 -0
- package/dist/rules/no-document-domain.d.ts +5 -0
- package/dist/rules/no-document-domain.d.ts.map +1 -0
- package/dist/rules/no-document-domain.js +41 -0
- package/dist/rules/no-document-domain.js.map +1 -0
- package/dist/rules/no-document-execcommand-insert-html.d.ts +5 -0
- package/dist/rules/no-document-execcommand-insert-html.d.ts.map +1 -0
- package/dist/rules/no-document-execcommand-insert-html.js +57 -0
- package/dist/rules/no-document-execcommand-insert-html.js.map +1 -0
- package/dist/rules/no-document-parse-html-unsafe.d.ts +5 -0
- package/dist/rules/no-document-parse-html-unsafe.d.ts.map +1 -0
- package/dist/rules/no-document-parse-html-unsafe.js +67 -0
- package/dist/rules/no-document-parse-html-unsafe.js.map +1 -0
- package/dist/rules/no-document-write.d.ts +5 -0
- package/dist/rules/no-document-write.d.ts.map +1 -0
- package/dist/rules/no-document-write.js +40 -0
- package/dist/rules/no-document-write.js.map +1 -0
- package/dist/rules/no-domparser-html-without-sanitization.d.ts +5 -0
- package/dist/rules/no-domparser-html-without-sanitization.d.ts.map +1 -0
- package/dist/rules/no-domparser-html-without-sanitization.js +56 -0
- package/dist/rules/no-domparser-html-without-sanitization.js.map +1 -0
- package/dist/rules/no-domparser-svg-without-sanitization.d.ts +5 -0
- package/dist/rules/no-domparser-svg-without-sanitization.d.ts.map +1 -0
- package/dist/rules/no-domparser-svg-without-sanitization.js +56 -0
- package/dist/rules/no-domparser-svg-without-sanitization.js.map +1 -0
- package/dist/rules/no-dynamic-import-unsafe-url.d.ts +5 -0
- package/dist/rules/no-dynamic-import-unsafe-url.d.ts.map +1 -0
- package/dist/rules/no-dynamic-import-unsafe-url.js +47 -0
- package/dist/rules/no-dynamic-import-unsafe-url.js.map +1 -0
- package/dist/rules/no-electron-allow-running-insecure-content.d.ts +5 -0
- package/dist/rules/no-electron-allow-running-insecure-content.d.ts.map +1 -0
- package/dist/rules/no-electron-allow-running-insecure-content.js +30 -0
- package/dist/rules/no-electron-allow-running-insecure-content.js.map +1 -0
- package/dist/rules/no-electron-dangerous-blink-features.d.ts +5 -0
- package/dist/rules/no-electron-dangerous-blink-features.d.ts.map +1 -0
- package/dist/rules/no-electron-dangerous-blink-features.js +89 -0
- package/dist/rules/no-electron-dangerous-blink-features.js.map +1 -0
- package/dist/rules/no-electron-disable-context-isolation.d.ts +5 -0
- package/dist/rules/no-electron-disable-context-isolation.d.ts.map +1 -0
- package/dist/rules/no-electron-disable-context-isolation.js +30 -0
- package/dist/rules/no-electron-disable-context-isolation.js.map +1 -0
- package/dist/rules/no-electron-disable-sandbox.d.ts +5 -0
- package/dist/rules/no-electron-disable-sandbox.d.ts.map +1 -0
- package/dist/rules/no-electron-disable-sandbox.js +30 -0
- package/dist/rules/no-electron-disable-sandbox.js.map +1 -0
- package/dist/rules/no-electron-disable-web-security.d.ts +5 -0
- package/dist/rules/no-electron-disable-web-security.d.ts.map +1 -0
- package/dist/rules/no-electron-disable-web-security.js +30 -0
- package/dist/rules/no-electron-disable-web-security.js.map +1 -0
- package/dist/rules/no-electron-enable-remote-module.d.ts +5 -0
- package/dist/rules/no-electron-enable-remote-module.d.ts.map +1 -0
- package/dist/rules/no-electron-enable-remote-module.js +30 -0
- package/dist/rules/no-electron-enable-remote-module.js.map +1 -0
- package/dist/rules/no-electron-enable-webview-tag.d.ts +5 -0
- package/dist/rules/no-electron-enable-webview-tag.d.ts.map +1 -0
- package/dist/rules/no-electron-enable-webview-tag.js +30 -0
- package/dist/rules/no-electron-enable-webview-tag.js.map +1 -0
- package/dist/rules/no-electron-experimental-features.d.ts +5 -0
- package/dist/rules/no-electron-experimental-features.d.ts.map +1 -0
- package/dist/rules/no-electron-experimental-features.js +30 -0
- package/dist/rules/no-electron-experimental-features.js.map +1 -0
- package/dist/rules/no-electron-expose-raw-ipc-renderer.d.ts +5 -0
- package/dist/rules/no-electron-expose-raw-ipc-renderer.d.ts.map +1 -0
- package/dist/rules/no-electron-expose-raw-ipc-renderer.js +108 -0
- package/dist/rules/no-electron-expose-raw-ipc-renderer.js.map +1 -0
- package/dist/rules/no-electron-insecure-certificate-error-handler.d.ts +5 -0
- package/dist/rules/no-electron-insecure-certificate-error-handler.d.ts.map +1 -0
- package/dist/rules/no-electron-insecure-certificate-error-handler.js +91 -0
- package/dist/rules/no-electron-insecure-certificate-error-handler.js.map +1 -0
- package/dist/rules/no-electron-insecure-certificate-verify-proc.d.ts +5 -0
- package/dist/rules/no-electron-insecure-certificate-verify-proc.d.ts.map +1 -0
- package/dist/rules/no-electron-insecure-certificate-verify-proc.js +75 -0
- package/dist/rules/no-electron-insecure-certificate-verify-proc.js.map +1 -0
- package/dist/rules/no-electron-insecure-permission-request-handler.d.ts +5 -0
- package/dist/rules/no-electron-insecure-permission-request-handler.d.ts.map +1 -0
- package/dist/rules/no-electron-insecure-permission-request-handler.js +75 -0
- package/dist/rules/no-electron-insecure-permission-request-handler.js.map +1 -0
- package/dist/rules/no-electron-node-integration.d.ts +5 -0
- package/dist/rules/no-electron-node-integration.d.ts.map +1 -0
- package/dist/rules/no-electron-node-integration.js +52 -0
- package/dist/rules/no-electron-node-integration.js.map +1 -0
- package/dist/rules/no-electron-permission-check-handler-allow-all.d.ts +5 -0
- package/dist/rules/no-electron-permission-check-handler-allow-all.d.ts.map +1 -0
- package/dist/rules/no-electron-permission-check-handler-allow-all.js +63 -0
- package/dist/rules/no-electron-permission-check-handler-allow-all.js.map +1 -0
- package/dist/rules/no-electron-unchecked-ipc-sender.d.ts +5 -0
- package/dist/rules/no-electron-unchecked-ipc-sender.d.ts.map +1 -0
- package/dist/rules/no-electron-unchecked-ipc-sender.js +90 -0
- package/dist/rules/no-electron-unchecked-ipc-sender.js.map +1 -0
- package/dist/rules/no-electron-unrestricted-navigation.d.ts +5 -0
- package/dist/rules/no-electron-unrestricted-navigation.d.ts.map +1 -0
- package/dist/rules/no-electron-unrestricted-navigation.js +100 -0
- package/dist/rules/no-electron-unrestricted-navigation.js.map +1 -0
- package/dist/rules/no-electron-untrusted-open-external.d.ts +5 -0
- package/dist/rules/no-electron-untrusted-open-external.d.ts.map +1 -0
- package/dist/rules/no-electron-untrusted-open-external.js +92 -0
- package/dist/rules/no-electron-untrusted-open-external.js.map +1 -0
- package/dist/rules/no-electron-webview-allowpopups.d.ts +5 -0
- package/dist/rules/no-electron-webview-allowpopups.d.ts.map +1 -0
- package/dist/rules/no-electron-webview-allowpopups.js +85 -0
- package/dist/rules/no-electron-webview-allowpopups.js.map +1 -0
- package/dist/rules/no-electron-webview-insecure-webpreferences.d.ts +5 -0
- package/dist/rules/no-electron-webview-insecure-webpreferences.d.ts.map +1 -0
- package/dist/rules/no-electron-webview-insecure-webpreferences.js +88 -0
- package/dist/rules/no-electron-webview-insecure-webpreferences.js.map +1 -0
- package/dist/rules/no-electron-webview-node-integration.d.ts +5 -0
- package/dist/rules/no-electron-webview-node-integration.d.ts.map +1 -0
- package/dist/rules/no-electron-webview-node-integration.js +107 -0
- package/dist/rules/no-electron-webview-node-integration.js.map +1 -0
- package/dist/rules/no-html-method.d.ts +5 -0
- package/dist/rules/no-html-method.d.ts.map +1 -0
- package/dist/rules/no-html-method.js +42 -0
- package/dist/rules/no-html-method.js.map +1 -0
- package/dist/rules/no-http-request-to-insecure-protocol.d.ts +5 -0
- package/dist/rules/no-http-request-to-insecure-protocol.d.ts.map +1 -0
- package/dist/rules/no-http-request-to-insecure-protocol.js +94 -0
- package/dist/rules/no-http-request-to-insecure-protocol.js.map +1 -0
- package/dist/rules/no-iframe-srcdoc.d.ts +5 -0
- package/dist/rules/no-iframe-srcdoc.d.ts.map +1 -0
- package/dist/rules/no-iframe-srcdoc.js +144 -0
- package/dist/rules/no-iframe-srcdoc.js.map +1 -0
- package/dist/rules/no-inner-html.d.ts +5 -0
- package/dist/rules/no-inner-html.d.ts.map +1 -0
- package/dist/rules/no-inner-html.js +67 -0
- package/dist/rules/no-inner-html.js.map +1 -0
- package/dist/rules/no-insecure-random.d.ts +5 -0
- package/dist/rules/no-insecure-random.d.ts.map +1 -0
- package/dist/rules/no-insecure-random.js +95 -0
- package/dist/rules/no-insecure-random.js.map +1 -0
- package/dist/rules/no-insecure-tls-agent-options.d.ts +5 -0
- package/dist/rules/no-insecure-tls-agent-options.d.ts.map +1 -0
- package/dist/rules/no-insecure-tls-agent-options.js +73 -0
- package/dist/rules/no-insecure-tls-agent-options.js.map +1 -0
- package/dist/rules/no-insecure-url.d.ts +12 -0
- package/dist/rules/no-insecure-url.d.ts.map +1 -0
- package/dist/rules/no-insecure-url.js +142 -0
- package/dist/rules/no-insecure-url.js.map +1 -0
- package/dist/rules/no-location-javascript-url.d.ts +5 -0
- package/dist/rules/no-location-javascript-url.d.ts.map +1 -0
- package/dist/rules/no-location-javascript-url.js +98 -0
- package/dist/rules/no-location-javascript-url.js.map +1 -0
- package/dist/rules/no-message-event-without-origin-check.d.ts +5 -0
- package/dist/rules/no-message-event-without-origin-check.d.ts.map +1 -0
- package/dist/rules/no-message-event-without-origin-check.js +183 -0
- package/dist/rules/no-message-event-without-origin-check.js.map +1 -0
- package/dist/rules/no-msapp-exec-unsafe.d.ts +5 -0
- package/dist/rules/no-msapp-exec-unsafe.d.ts.map +1 -0
- package/dist/rules/no-msapp-exec-unsafe.js +32 -0
- package/dist/rules/no-msapp-exec-unsafe.js.map +1 -0
- package/dist/rules/no-node-tls-check-server-identity-bypass.d.ts +5 -0
- package/dist/rules/no-node-tls-check-server-identity-bypass.d.ts.map +1 -0
- package/dist/rules/no-node-tls-check-server-identity-bypass.js +95 -0
- package/dist/rules/no-node-tls-check-server-identity-bypass.js.map +1 -0
- package/dist/rules/no-node-tls-legacy-protocol.d.ts +5 -0
- package/dist/rules/no-node-tls-legacy-protocol.d.ts.map +1 -0
- package/dist/rules/no-node-tls-legacy-protocol.js +106 -0
- package/dist/rules/no-node-tls-legacy-protocol.js.map +1 -0
- package/dist/rules/no-node-tls-reject-unauthorized-zero.d.ts +5 -0
- package/dist/rules/no-node-tls-reject-unauthorized-zero.d.ts.map +1 -0
- package/dist/rules/no-node-tls-reject-unauthorized-zero.js +93 -0
- package/dist/rules/no-node-tls-reject-unauthorized-zero.js.map +1 -0
- package/dist/rules/no-node-tls-security-level-zero.d.ts +5 -0
- package/dist/rules/no-node-tls-security-level-zero.d.ts.map +1 -0
- package/dist/rules/no-node-tls-security-level-zero.js +80 -0
- package/dist/rules/no-node-tls-security-level-zero.js.map +1 -0
- package/dist/rules/no-node-vm-run-in-context.d.ts +5 -0
- package/dist/rules/no-node-vm-run-in-context.d.ts.map +1 -0
- package/dist/rules/no-node-vm-run-in-context.js +186 -0
- package/dist/rules/no-node-vm-run-in-context.js.map +1 -0
- package/dist/rules/no-node-vm-source-text-module.d.ts +5 -0
- package/dist/rules/no-node-vm-source-text-module.d.ts.map +1 -0
- package/dist/rules/no-node-vm-source-text-module.js +126 -0
- package/dist/rules/no-node-vm-source-text-module.js.map +1 -0
- package/dist/rules/no-node-worker-threads-eval.d.ts +5 -0
- package/dist/rules/no-node-worker-threads-eval.d.ts.map +1 -0
- package/dist/rules/no-node-worker-threads-eval.js +151 -0
- package/dist/rules/no-node-worker-threads-eval.js.map +1 -0
- package/dist/rules/no-nonnull-assertion-on-security-input.d.ts +5 -0
- package/dist/rules/no-nonnull-assertion-on-security-input.d.ts.map +1 -0
- package/dist/rules/no-nonnull-assertion-on-security-input.js +48 -0
- package/dist/rules/no-nonnull-assertion-on-security-input.js.map +1 -0
- package/dist/rules/no-postmessage-star-origin.d.ts +5 -0
- package/dist/rules/no-postmessage-star-origin.d.ts.map +1 -0
- package/dist/rules/no-postmessage-star-origin.js +58 -0
- package/dist/rules/no-postmessage-star-origin.js.map +1 -0
- package/dist/rules/no-postmessage-without-origin-allowlist.d.ts +5 -0
- package/dist/rules/no-postmessage-without-origin-allowlist.d.ts.map +1 -0
- package/dist/rules/no-postmessage-without-origin-allowlist.js +80 -0
- package/dist/rules/no-postmessage-without-origin-allowlist.js.map +1 -0
- package/dist/rules/no-range-create-contextual-fragment.d.ts +5 -0
- package/dist/rules/no-range-create-contextual-fragment.d.ts.map +1 -0
- package/dist/rules/no-range-create-contextual-fragment.js +64 -0
- package/dist/rules/no-range-create-contextual-fragment.js.map +1 -0
- package/dist/rules/no-script-src-data-url.d.ts +5 -0
- package/dist/rules/no-script-src-data-url.d.ts.map +1 -0
- package/dist/rules/no-script-src-data-url.js +108 -0
- package/dist/rules/no-script-src-data-url.js.map +1 -0
- package/dist/rules/no-script-text.d.ts +5 -0
- package/dist/rules/no-script-text.d.ts.map +1 -0
- package/dist/rules/no-script-text.js +52 -0
- package/dist/rules/no-script-text.js.map +1 -0
- package/dist/rules/no-service-worker-unsafe-script-url.d.ts +5 -0
- package/dist/rules/no-service-worker-unsafe-script-url.d.ts.map +1 -0
- package/dist/rules/no-service-worker-unsafe-script-url.js +52 -0
- package/dist/rules/no-service-worker-unsafe-script-url.js.map +1 -0
- package/dist/rules/no-set-html-unsafe.d.ts +5 -0
- package/dist/rules/no-set-html-unsafe.d.ts.map +1 -0
- package/dist/rules/no-set-html-unsafe.js +48 -0
- package/dist/rules/no-set-html-unsafe.js.map +1 -0
- package/dist/rules/no-trusted-types-policy-pass-through.d.ts +5 -0
- package/dist/rules/no-trusted-types-policy-pass-through.d.ts.map +1 -0
- package/dist/rules/no-trusted-types-policy-pass-through.js +115 -0
- package/dist/rules/no-trusted-types-policy-pass-through.js.map +1 -0
- package/dist/rules/no-unsafe-alloc.d.ts +5 -0
- package/dist/rules/no-unsafe-alloc.d.ts.map +1 -0
- package/dist/rules/no-unsafe-alloc.js +51 -0
- package/dist/rules/no-unsafe-alloc.js.map +1 -0
- package/dist/rules/no-unsafe-cast-to-trusted-types.d.ts +5 -0
- package/dist/rules/no-unsafe-cast-to-trusted-types.d.ts.map +1 -0
- package/dist/rules/no-unsafe-cast-to-trusted-types.js +89 -0
- package/dist/rules/no-unsafe-cast-to-trusted-types.js.map +1 -0
- package/dist/rules/no-window-open-without-noopener.d.ts +5 -0
- package/dist/rules/no-window-open-without-noopener.d.ts.map +1 -0
- package/dist/rules/no-window-open-without-noopener.js +84 -0
- package/dist/rules/no-window-open-without-noopener.js.map +1 -0
- package/dist/rules/no-winjs-html-unsafe.d.ts +5 -0
- package/dist/rules/no-winjs-html-unsafe.d.ts.map +1 -0
- package/dist/rules/no-winjs-html-unsafe.js +32 -0
- package/dist/rules/no-winjs-html-unsafe.js.map +1 -0
- package/dist/rules/no-worker-blob-url.d.ts +5 -0
- package/dist/rules/no-worker-blob-url.d.ts.map +1 -0
- package/dist/rules/no-worker-blob-url.js +64 -0
- package/dist/rules/no-worker-blob-url.js.map +1 -0
- package/dist/rules/no-worker-data-url.d.ts +5 -0
- package/dist/rules/no-worker-data-url.d.ts.map +1 -0
- package/dist/rules/no-worker-data-url.js +67 -0
- package/dist/rules/no-worker-data-url.js.map +1 -0
- package/docs/rules/getting-started.md +70 -0
- package/docs/rules/no-angular-bypass-sanitizer.md +69 -0
- package/docs/rules/no-angular-bypass-security-trust-html.md +59 -0
- package/docs/rules/no-angular-innerhtml-binding.md +59 -0
- package/docs/rules/no-angular-sanitization-trusted-urls.md +64 -0
- package/docs/rules/no-angularjs-bypass-sce.md +64 -0
- package/docs/rules/no-angularjs-enable-svg.md +59 -0
- package/docs/rules/no-angularjs-ng-bind-html-without-sanitize.md +59 -0
- package/docs/rules/no-angularjs-sanitization-whitelist.md +63 -0
- package/docs/rules/no-angularjs-sce-resource-url-wildcard.md +62 -0
- package/docs/rules/no-child-process-exec.md +101 -0
- package/docs/rules/no-child-process-shell-true.md +59 -0
- package/docs/rules/no-cookies.md +61 -0
- package/docs/rules/no-document-domain.md +59 -0
- package/docs/rules/no-document-execcommand-insert-html.md +69 -0
- package/docs/rules/no-document-parse-html-unsafe.md +72 -0
- package/docs/rules/no-document-write.md +64 -0
- package/docs/rules/no-domparser-html-without-sanitization.md +59 -0
- package/docs/rules/no-domparser-svg-without-sanitization.md +71 -0
- package/docs/rules/no-dynamic-import-unsafe-url.md +81 -0
- package/docs/rules/no-electron-allow-running-insecure-content.md +69 -0
- package/docs/rules/no-electron-dangerous-blink-features.md +77 -0
- package/docs/rules/no-electron-disable-context-isolation.md +69 -0
- package/docs/rules/no-electron-disable-sandbox.md +69 -0
- package/docs/rules/no-electron-disable-web-security.md +69 -0
- package/docs/rules/no-electron-enable-remote-module.md +69 -0
- package/docs/rules/no-electron-enable-webview-tag.md +77 -0
- package/docs/rules/no-electron-experimental-features.md +77 -0
- package/docs/rules/no-electron-expose-raw-ipc-renderer.md +79 -0
- package/docs/rules/no-electron-insecure-certificate-error-handler.md +72 -0
- package/docs/rules/no-electron-insecure-certificate-verify-proc.md +63 -0
- package/docs/rules/no-electron-insecure-permission-request-handler.md +67 -0
- package/docs/rules/no-electron-node-integration.md +70 -0
- package/docs/rules/no-electron-permission-check-handler-allow-all.md +66 -0
- package/docs/rules/no-electron-unchecked-ipc-sender.md +62 -0
- package/docs/rules/no-electron-unrestricted-navigation.md +64 -0
- package/docs/rules/no-electron-untrusted-open-external.md +65 -0
- package/docs/rules/no-electron-webview-allowpopups.md +59 -0
- package/docs/rules/no-electron-webview-insecure-webpreferences.md +84 -0
- package/docs/rules/no-electron-webview-node-integration.md +59 -0
- package/docs/rules/no-html-method.md +58 -0
- package/docs/rules/no-http-request-to-insecure-protocol.md +59 -0
- package/docs/rules/no-iframe-srcdoc.md +76 -0
- package/docs/rules/no-inner-html.md +65 -0
- package/docs/rules/no-insecure-random.md +66 -0
- package/docs/rules/no-insecure-tls-agent-options.md +59 -0
- package/docs/rules/no-insecure-url.md +72 -0
- package/docs/rules/no-location-javascript-url.md +59 -0
- package/docs/rules/no-message-event-without-origin-check.md +82 -0
- package/docs/rules/no-msapp-exec-unsafe.md +59 -0
- package/docs/rules/no-node-tls-check-server-identity-bypass.md +88 -0
- package/docs/rules/no-node-tls-legacy-protocol.md +80 -0
- package/docs/rules/no-node-tls-reject-unauthorized-zero.md +61 -0
- package/docs/rules/no-node-tls-security-level-zero.md +77 -0
- package/docs/rules/no-node-vm-run-in-context.md +89 -0
- package/docs/rules/no-node-vm-source-text-module.md +79 -0
- package/docs/rules/no-node-worker-threads-eval.md +82 -0
- package/docs/rules/no-nonnull-assertion-on-security-input.md +59 -0
- package/docs/rules/no-postmessage-star-origin.md +59 -0
- package/docs/rules/no-postmessage-without-origin-allowlist.md +59 -0
- package/docs/rules/no-range-create-contextual-fragment.md +64 -0
- package/docs/rules/no-script-src-data-url.md +83 -0
- package/docs/rules/no-script-text.md +80 -0
- package/docs/rules/no-service-worker-unsafe-script-url.md +85 -0
- package/docs/rules/no-set-html-unsafe.md +64 -0
- package/docs/rules/no-trusted-types-policy-pass-through.md +68 -0
- package/docs/rules/no-unsafe-alloc.md +62 -0
- package/docs/rules/no-unsafe-cast-to-trusted-types.md +59 -0
- package/docs/rules/no-window-open-without-noopener.md +63 -0
- package/docs/rules/no-winjs-html-unsafe.md +60 -0
- package/docs/rules/no-worker-blob-url.md +86 -0
- package/docs/rules/no-worker-data-url.md +85 -0
- package/docs/rules/overview.md +111 -0
- package/docs/rules/presets/angular.md +35 -0
- package/docs/rules/presets/angularjs.md +36 -0
- package/docs/rules/presets/common.md +59 -0
- package/docs/rules/presets/electron.md +51 -0
- package/docs/rules/presets/index.md +26 -0
- package/docs/rules/presets/node.md +43 -0
- package/docs/rules/presets/react.md +33 -0
- package/docs/rules/presets/recommended.md +104 -0
- package/docs/rules/presets/required.md +99 -0
- package/docs/rules/presets/typescript.md +34 -0
- package/package.json +583 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { arrayAt } from "ts-extras";
|
|
2
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
3
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
4
|
+
if (!memberExpression.computed &&
|
|
5
|
+
memberExpression.property.type === "Identifier") {
|
|
6
|
+
return memberExpression.property.name;
|
|
7
|
+
}
|
|
8
|
+
if (memberExpression.property.type === "Literal" &&
|
|
9
|
+
typeof memberExpression.property.value === "string") {
|
|
10
|
+
return memberExpression.property.value;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const isFunctionExpression = (expression) => expression.type === "ArrowFunctionExpression" ||
|
|
15
|
+
expression.type === "FunctionExpression";
|
|
16
|
+
const hasUnsafePermissionAllowPattern = (callbackNode, context, callbackParameterName) => {
|
|
17
|
+
const callbackSourceText = context.sourceCode.getText(callbackNode);
|
|
18
|
+
const escapedName = callbackParameterName.replaceAll("$", String.raw `\$`);
|
|
19
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- Callback identifier is escaped before interpolation for strict permission-allow detection.
|
|
20
|
+
const callbackPattern = new RegExp(String.raw `\b${escapedName}\s*\(\s*true\b`, "u");
|
|
21
|
+
return (callbackPattern.test(callbackSourceText) ||
|
|
22
|
+
/\breturn\s+true\b/u.test(callbackSourceText));
|
|
23
|
+
};
|
|
24
|
+
/** Rule implementation. */
|
|
25
|
+
const rule = createRule({
|
|
26
|
+
create(context) {
|
|
27
|
+
return {
|
|
28
|
+
CallExpression(node) {
|
|
29
|
+
if (node.callee.type !== "MemberExpression") {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (getMemberPropertyName(node.callee) !==
|
|
33
|
+
"setPermissionRequestHandler") {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const [firstArgument] = node.arguments;
|
|
37
|
+
if (firstArgument === undefined ||
|
|
38
|
+
firstArgument.type === "SpreadElement" ||
|
|
39
|
+
!isFunctionExpression(firstArgument)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const callbackParameter = arrayAt(firstArgument.params, -1);
|
|
43
|
+
if (callbackParameter?.type !== "Identifier") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!hasUnsafePermissionAllowPattern(firstArgument, context, callbackParameter.name)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
context.report({
|
|
50
|
+
messageId: "default",
|
|
51
|
+
node: firstArgument,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
defaultOptions: [],
|
|
57
|
+
meta: {
|
|
58
|
+
deprecated: false,
|
|
59
|
+
docs: {
|
|
60
|
+
description: "disallow Electron permission request handlers that blanket-allow permission requests.",
|
|
61
|
+
frozen: false,
|
|
62
|
+
recommended: false,
|
|
63
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-insecure-permission-request-handler",
|
|
64
|
+
},
|
|
65
|
+
messages: {
|
|
66
|
+
default: "Do not blanket-allow permissions in setPermissionRequestHandler callbacks.",
|
|
67
|
+
},
|
|
68
|
+
schema: [],
|
|
69
|
+
type: "problem",
|
|
70
|
+
},
|
|
71
|
+
name: "no-electron-insecure-permission-request-handler",
|
|
72
|
+
});
|
|
73
|
+
export default rule;
|
|
74
|
+
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types -- Restore linting after rule implementation declarations. */
|
|
75
|
+
//# sourceMappingURL=no-electron-insecure-permission-request-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-insecure-permission-request-handler.js","sourceRoot":"","sources":["../../src/rules/no-electron-insecure-permission-request-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAIzD,MAAM,qBAAqB,GAAG,CAC1B,gBAA2C,EACzB,EAAE;IACpB,IACI,CAAC,gBAAgB,CAAC,QAAQ;QAC1B,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,IACI,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC5C,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,EACrD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC3C,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CACzB,UAA2C,EAGb,EAAE,CAChC,UAAU,CAAC,IAAI,KAAK,yBAAyB;IAC7C,UAAU,CAAC,IAAI,KAAK,oBAAoB,CAAC;AAE7C,MAAM,+BAA+B,GAAG,CACpC,YAEiC,EACjC,OAAoD,EACpD,qBAA6B,EACtB,E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BACC,OAAO;gBACX,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACX,SAAS,EAAE,SAAS;oBACpB,IAAI,EAAE,aAAa;iBACtB,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE;YACF,WAAW,EACP,uFAAuF;YAC3F,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,6GAA6G;SACrH;QACD,QAAQ,EAAE;YACN,OAAO,EACH,4EAA4E;SACnF;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,iDAAiD;CAC1D,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,iIAAiI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-node-integration.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-node-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CA2DtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
2
|
+
/** Rule implementation. */
|
|
3
|
+
const rule = createRule({
|
|
4
|
+
create(context) {
|
|
5
|
+
return {
|
|
6
|
+
"NewExpression[callee.name=/^(?:BrowserWindow|BrowserView)$/] > ObjectExpression.arguments > Property.properties[key.name='webPreferences'] > ObjectExpression.value > Property.properties[key.name=/^(?:nodeIntegration|nodeIntegrationInWorker|nodeIntegrationInSubFrames)$/][value.value=true]"(node) {
|
|
7
|
+
context.report({
|
|
8
|
+
fix(fixer) {
|
|
9
|
+
const propertyText = context.sourceCode.getText(node);
|
|
10
|
+
const separatorIndex = propertyText.indexOf(":");
|
|
11
|
+
if (separatorIndex === -1) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const valuePortion = propertyText.slice(separatorIndex + 1);
|
|
15
|
+
const trimmedValuePortion = valuePortion.trimStart();
|
|
16
|
+
if (!trimmedValuePortion.startsWith("true")) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const leadingWhitespaceLength = valuePortion.length - trimmedValuePortion.length;
|
|
20
|
+
const nextValuePortion = `${valuePortion.slice(0, leadingWhitespaceLength)}false${trimmedValuePortion.slice("true".length)}`;
|
|
21
|
+
const nextPropertyText = `${propertyText.slice(0, separatorIndex + 1)}${nextValuePortion}`;
|
|
22
|
+
if (nextPropertyText === propertyText) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return fixer.replaceText(node, nextPropertyText);
|
|
26
|
+
},
|
|
27
|
+
messageId: "default",
|
|
28
|
+
node,
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
meta: {
|
|
35
|
+
deprecated: false,
|
|
36
|
+
docs: {
|
|
37
|
+
description: "disallow enabling Electron Node.js integration in BrowserWindow/BrowserView webPreferences.",
|
|
38
|
+
frozen: false,
|
|
39
|
+
recommended: false,
|
|
40
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-node-integration",
|
|
41
|
+
},
|
|
42
|
+
fixable: "code",
|
|
43
|
+
messages: {
|
|
44
|
+
default: "Do not enable Node.js integration for remote content.",
|
|
45
|
+
},
|
|
46
|
+
schema: [],
|
|
47
|
+
type: "problem",
|
|
48
|
+
},
|
|
49
|
+
name: "no-electron-node-integration",
|
|
50
|
+
});
|
|
51
|
+
export default rule;
|
|
52
|
+
//# sourceMappingURL=no-electron-node-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-node-integration.js","sourceRoot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E,gBAAgB,CAAC,CAAC;oBACrD,CAAC;oBACD,SAAS,EAAE,SAAS;oBACpB,IAAI;iBACP,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE;YACF,WAAW,EACP,6FAA6F;YACjG,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,0FAA0F;SAClG;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACN,OAAO,EAAE,uDAAuD;SACnE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,8BAA8B;CACvC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-permission-check-handler-allow-all.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-permission-check-handler-allow-all.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAoCzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAmDtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { arrayFirst } from "ts-extras";
|
|
2
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
3
|
+
import { getMemberPropertyName } from "../_internal/estree-utils.js";
|
|
4
|
+
const isFunctionExpression = (expression) => expression.type === "ArrowFunctionExpression" ||
|
|
5
|
+
expression.type === "FunctionExpression";
|
|
6
|
+
const isBooleanTrueLiteral = (expression) => expression?.type === "Literal" && expression.value === true;
|
|
7
|
+
const isAllowAllPermissionCheckHandler = (callbackNode) => {
|
|
8
|
+
if (callbackNode.body.type !== "BlockStatement") {
|
|
9
|
+
return isBooleanTrueLiteral(callbackNode.body);
|
|
10
|
+
}
|
|
11
|
+
if (callbackNode.body.body.length !== 1) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const onlyStatement = arrayFirst(callbackNode.body.body);
|
|
15
|
+
return (onlyStatement?.type === "ReturnStatement" &&
|
|
16
|
+
isBooleanTrueLiteral(onlyStatement.argument));
|
|
17
|
+
};
|
|
18
|
+
/** Rule implementation. */
|
|
19
|
+
const rule = createRule({
|
|
20
|
+
create(context) {
|
|
21
|
+
return {
|
|
22
|
+
CallExpression(node) {
|
|
23
|
+
if (node.callee.type !== "MemberExpression") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (getMemberPropertyName(node.callee) !==
|
|
27
|
+
"setPermissionCheckHandler") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const [firstArgument] = node.arguments;
|
|
31
|
+
if (firstArgument === undefined ||
|
|
32
|
+
firstArgument.type === "SpreadElement" ||
|
|
33
|
+
!isFunctionExpression(firstArgument) ||
|
|
34
|
+
!isAllowAllPermissionCheckHandler(firstArgument)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
context.report({
|
|
38
|
+
messageId: "default",
|
|
39
|
+
node: firstArgument,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
defaultOptions: [],
|
|
45
|
+
meta: {
|
|
46
|
+
deprecated: false,
|
|
47
|
+
docs: {
|
|
48
|
+
description: "disallow Electron permission check handlers that unconditionally allow every permission request.",
|
|
49
|
+
frozen: false,
|
|
50
|
+
recommended: false,
|
|
51
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-permission-check-handler-allow-all",
|
|
52
|
+
},
|
|
53
|
+
messages: {
|
|
54
|
+
default: "Do not unconditionally return true from setPermissionCheckHandler callbacks.",
|
|
55
|
+
},
|
|
56
|
+
schema: [],
|
|
57
|
+
type: "problem",
|
|
58
|
+
},
|
|
59
|
+
name: "no-electron-permission-check-handler-allow-all",
|
|
60
|
+
});
|
|
61
|
+
export default rule;
|
|
62
|
+
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types -- Restore linting after rule implementation declarations. */
|
|
63
|
+
//# sourceMappingURL=no-electron-permission-check-handler-allow-all.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-permission-check-handler-allow-all.js","sourceRoot":"","sources":["../../src/rules/no-electron-permission-check-handler-allow-all.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,MAAM,oBAAoB,GAAG,CACzB,UAA2C,EAGb,EAAE,CAChC,UAAU,CAAC,IAAI,KAAK,yBAAyB;IAC7C,UAAU,CAAC,IAAI,KAAK,oBAAoB,CAAC;AAE7C,MAAM,oBAAoB,GAAG,CACzB,UAAkD,EAC3C,EAAE,CAAC,UAAU,EAAE,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC;AAE1E,MAAM,gCAAgC,GAAG,CACrC,YAA4E,EACrE,EAAE;IACT,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QAC9C,OAAO,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEzD,OAAO,CACH,aAAa,EAAE,IAAI,KAAK,iBAAiB;QACzC,oBAAoB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAC/C,CAAC;AACN,CAAC,CAAC;AAEF,2BAA2B;AAC3B,MAAM,IAAI,GAAkC,UAAU,CAAwB;IAC1E,MAAM,CAAC,OAAO;QACV,OAAO;YACH,cAAc,CAAC,IAA6B;gBACxC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBAC1C,OAAO;gBACX,CAAC;gBAED,IACI,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC;oBAClC,2BAA2B,EAC7B,CAAC;oBACC,OAAO;gBACX,CAAC;gBAED,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAEvC,IACI,aAAa,KAAK,SAAS;oBAC3B,aAAa,CAAC,IAAI,KAAK,eAAe;oBACtC,CAAC,oBAAoB,CAAC,aAAa,CAAC;oBACpC,CAAC,gCAAgC,CAAC,aAAa,CAAC,EAClD,CAAC;oBACC,OAAO;gBACX,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACX,SAAS,EAAE,SAAS;oBACpB,IAAI,EAAE,aAAa;iBACtB,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE;YACF,WAAW,EACP,kGAAkG;YACtG,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,4GAA4G;SACpH;QACD,QAAQ,EAAE;YACN,OAAO,EACH,8EAA8E;SACrF;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,gDAAgD;CACzD,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,iIAAiI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-unchecked-ipc-sender.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-unchecked-ipc-sender.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAqFzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CA2DtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { arrayFirst } from "ts-extras";
|
|
2
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
3
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
4
|
+
if (!memberExpression.computed &&
|
|
5
|
+
memberExpression.property.type === "Identifier") {
|
|
6
|
+
return memberExpression.property.name;
|
|
7
|
+
}
|
|
8
|
+
if (memberExpression.property.type === "Literal" &&
|
|
9
|
+
typeof memberExpression.property.value === "string") {
|
|
10
|
+
return memberExpression.property.value;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const isIpcMainObjectExpression = (expression) => {
|
|
15
|
+
if (expression.type === "Identifier") {
|
|
16
|
+
return expression.name === "ipcMain";
|
|
17
|
+
}
|
|
18
|
+
if (expression.type !== "MemberExpression") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return getMemberPropertyName(expression) === "ipcMain";
|
|
22
|
+
};
|
|
23
|
+
const isIpcMainHandlerRegistration = (node) => {
|
|
24
|
+
if (node.callee.type !== "MemberExpression") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const methodName = getMemberPropertyName(node.callee);
|
|
28
|
+
if (methodName !== "on" && methodName !== "handle") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return isIpcMainObjectExpression(node.callee.object);
|
|
32
|
+
};
|
|
33
|
+
const isFunctionExpression = (expression) => expression.type === "ArrowFunctionExpression" ||
|
|
34
|
+
expression.type === "FunctionExpression";
|
|
35
|
+
const hasSenderValidationPattern = (callbackNode, context, eventParameterName) => {
|
|
36
|
+
const callbackSourceText = context.sourceCode.getText(callbackNode);
|
|
37
|
+
const escapedEventName = eventParameterName.replaceAll("$", String.raw `\$`);
|
|
38
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- Event parameter identifier is escaped before interpolation for sender-access detection.
|
|
39
|
+
const eventSenderPattern = new RegExp(String.raw `\b${escapedEventName}\s*\.\s*(?:sender|senderFrame)\b`, "u");
|
|
40
|
+
return (eventSenderPattern.test(callbackSourceText) ||
|
|
41
|
+
/\b(?:allowlist|getURL|isTrusted|origin|validate|whitelist)\b/u.test(callbackSourceText));
|
|
42
|
+
};
|
|
43
|
+
/** Rule implementation. */
|
|
44
|
+
const rule = createRule({
|
|
45
|
+
create(context) {
|
|
46
|
+
return {
|
|
47
|
+
CallExpression(node) {
|
|
48
|
+
if (!isIpcMainHandlerRegistration(node)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const [, handlerNode] = node.arguments;
|
|
52
|
+
if (handlerNode === undefined ||
|
|
53
|
+
handlerNode.type === "SpreadElement" ||
|
|
54
|
+
!isFunctionExpression(handlerNode)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const eventParameter = arrayFirst(handlerNode.params);
|
|
58
|
+
if (eventParameter?.type !== "Identifier") {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (hasSenderValidationPattern(handlerNode, context, eventParameter.name)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
context.report({
|
|
65
|
+
messageId: "default",
|
|
66
|
+
node: handlerNode,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
defaultOptions: [],
|
|
72
|
+
meta: {
|
|
73
|
+
deprecated: false,
|
|
74
|
+
docs: {
|
|
75
|
+
description: "disallow privileged ipcMain handlers that do not validate sender/frame trust.",
|
|
76
|
+
frozen: false,
|
|
77
|
+
recommended: false,
|
|
78
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-unchecked-ipc-sender",
|
|
79
|
+
},
|
|
80
|
+
messages: {
|
|
81
|
+
default: "Validate the IPC sender or sender frame before handling privileged ipcMain requests.",
|
|
82
|
+
},
|
|
83
|
+
schema: [],
|
|
84
|
+
type: "problem",
|
|
85
|
+
},
|
|
86
|
+
name: "no-electron-unchecked-ipc-sender",
|
|
87
|
+
});
|
|
88
|
+
export default rule;
|
|
89
|
+
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types -- Restore linting after rule implementation declarations. */
|
|
90
|
+
//# sourceMappingURL=no-electron-unchecked-ipc-sender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-unchecked-ipc-sender.js","sourceRoot":"","sources":["../../src/rules/no-electron-unchecked-ipc-sender.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAIzD,MAAM,qBAAqB,GAAG,CAC1B,gBAA2C,EACzB,EAAE;IACpB,IACI,CAAC,gBAAgB,CAAC,QAAQ;QAC1B,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,IACI,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC5C,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,EACrD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC3C,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAC9B,UAA+B,EACxB,EAAE;IACT,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC;IACzC,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACzC,OAAO,KAAK,CA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C1E,MAAM,CAAC,OAAO;QACV,OAAO;YACH,cAAc,CAAC,IAA6B;gBACxC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtC,OAAO;gBACX,CAAC;gBAED,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAEvC,IACI,WAAW,KAAK,SAAS;oBACzB,WAAW,CAAC,IAAI,KAAK,eAAe;oBACpC,CAAC,oBAAoB,CAAC,WAAW,CAAC,EACpC,CAAC;oBACC,OAAO;gBACX,CAAC;gBAED,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBAEtD,IAAI,cAAc,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;oBACxC,OAAO;gBACX,CAAC;gBAED,IACI,0BAA0B,CACtB,WAAW,EACX,OAAO,EACP,cAAc,CAAC,IAAI,CACtB,EACH,CAAC;oBACC,OAAO;gBACX,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACX,SAAS,EAAE,SAAS;oBACpB,IAAI,EAAE,WAAW;iBACpB,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE;YACF,WAAW,EACP,+EAA+E;YACnF,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,8FAA8F;SACtG;QACD,QAAQ,EAAE;YACN,OAAO,EACH,sFAAsF;SAC7F;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,kCAAkC;CAC3C,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,iIAAiI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-unrestricted-navigation.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-unrestricted-navigation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AA6DzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAiGtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { arrayFirst } from "ts-extras";
|
|
2
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
3
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
4
|
+
if (!memberExpression.computed &&
|
|
5
|
+
memberExpression.property.type === "Identifier") {
|
|
6
|
+
return memberExpression.property.name;
|
|
7
|
+
}
|
|
8
|
+
if (memberExpression.property.type === "Literal" &&
|
|
9
|
+
typeof memberExpression.property.value === "string") {
|
|
10
|
+
return memberExpression.property.value;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const isFunctionExpression = (expression) => expression.type === "ArrowFunctionExpression" ||
|
|
15
|
+
expression.type === "FunctionExpression";
|
|
16
|
+
const hasUnsafeAllowAction = (callbackNode, context) => {
|
|
17
|
+
const callbackSourceText = context.sourceCode.getText(callbackNode);
|
|
18
|
+
return /\baction\s*:\s*["'`]allow["'`]/u.test(callbackSourceText);
|
|
19
|
+
};
|
|
20
|
+
const hasPreventDefaultCall = (callbackNode, context, eventParameterName) => {
|
|
21
|
+
const callbackSourceText = context.sourceCode.getText(callbackNode);
|
|
22
|
+
const escapedName = eventParameterName.replaceAll("$", String.raw `\$`);
|
|
23
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- Event parameter identifier is escaped before interpolation for preventDefault-call detection.
|
|
24
|
+
const preventDefaultPattern = new RegExp(String.raw `\b${escapedName}\s*\.\s*preventDefault\s*\(`, "u");
|
|
25
|
+
return preventDefaultPattern.test(callbackSourceText);
|
|
26
|
+
};
|
|
27
|
+
/** Rule implementation. */
|
|
28
|
+
const rule = createRule({
|
|
29
|
+
create(context) {
|
|
30
|
+
return {
|
|
31
|
+
CallExpression(node) {
|
|
32
|
+
if (node.callee.type !== "MemberExpression") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const methodName = getMemberPropertyName(node.callee);
|
|
36
|
+
if (methodName === "setWindowOpenHandler") {
|
|
37
|
+
const [firstArgument] = node.arguments;
|
|
38
|
+
if (firstArgument === undefined ||
|
|
39
|
+
firstArgument.type === "SpreadElement" ||
|
|
40
|
+
!isFunctionExpression(firstArgument)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!hasUnsafeAllowAction(firstArgument, context)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
context.report({
|
|
47
|
+
messageId: "default",
|
|
48
|
+
node: firstArgument,
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (methodName !== "on") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const [firstArgument, secondArgument] = node.arguments;
|
|
56
|
+
if (firstArgument === undefined ||
|
|
57
|
+
firstArgument.type === "SpreadElement" ||
|
|
58
|
+
secondArgument === undefined ||
|
|
59
|
+
secondArgument.type === "SpreadElement" ||
|
|
60
|
+
!isFunctionExpression(secondArgument)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (firstArgument.type !== "Literal" ||
|
|
64
|
+
firstArgument.value !== "will-navigate") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const eventParameter = arrayFirst(secondArgument.params);
|
|
68
|
+
if (eventParameter?.type !== "Identifier") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (hasPreventDefaultCall(secondArgument, context, eventParameter.name)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
context.report({
|
|
75
|
+
messageId: "default",
|
|
76
|
+
node: secondArgument,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
defaultOptions: [],
|
|
82
|
+
meta: {
|
|
83
|
+
deprecated: false,
|
|
84
|
+
docs: {
|
|
85
|
+
description: "disallow Electron navigation handlers that allow unrestricted navigation or window opening.",
|
|
86
|
+
frozen: false,
|
|
87
|
+
recommended: false,
|
|
88
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-unrestricted-navigation",
|
|
89
|
+
},
|
|
90
|
+
messages: {
|
|
91
|
+
default: "Restrict Electron navigation/window-opening handlers with explicit blocking or allowlist logic.",
|
|
92
|
+
},
|
|
93
|
+
schema: [],
|
|
94
|
+
type: "problem",
|
|
95
|
+
},
|
|
96
|
+
name: "no-electron-unrestricted-navigation",
|
|
97
|
+
});
|
|
98
|
+
export default rule;
|
|
99
|
+
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types -- Restore linting after rule implementation declarations. */
|
|
100
|
+
//# sourceMappingURL=no-electron-unrestricted-navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-unrestricted-navigation.js","sourceRoot":"","sources":["../../src/rules/no-electron-unrestricted-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAIzD,MAAM,qBAAqB,GAAG,CAC1B,gBAA2C,EACzB,EAAE;IACpB,IACI,CAAC,gBAAgB,CAAC,QAAQ;QAC1B,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED,IACI,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC5C,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,EACrD,CAAC;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC3C,CAAC;IAED,OAAO,SAAS,CAAC;AAC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EAAE;IAClB,IAAI,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE;YACF,WAAW,EACP,6FAA6F;YACjG,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,iGAAiG;SACzG;QACD,QAAQ,EAAE;YACN,OAAO,EACH,iGAAiG;SACxG;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,qCAAqC;CAC9C,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,iIAAiI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-untrusted-open-external.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-untrusted-open-external.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AA2EzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAmDtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { arrayFirst } from "ts-extras";
|
|
2
|
+
import { createRule } from "../_internal/create-rule.js";
|
|
3
|
+
const getStaticTemplateLiteralValue = (templateLiteral) => {
|
|
4
|
+
if (templateLiteral.expressions.length > 0) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
return arrayFirst(templateLiteral.quasis)?.value.cooked ?? undefined;
|
|
8
|
+
};
|
|
9
|
+
const getStringValue = (node) => {
|
|
10
|
+
if (node.type === "Literal" && typeof node.value === "string") {
|
|
11
|
+
return node.value;
|
|
12
|
+
}
|
|
13
|
+
if (node.type === "TemplateLiteral") {
|
|
14
|
+
return getStaticTemplateLiteralValue(node);
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
const isAllowedExternalProtocol = (value) => /^(?:https|mailto):/iu.test(value.trim());
|
|
19
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
20
|
+
if (!memberExpression.computed &&
|
|
21
|
+
memberExpression.property.type === "Identifier") {
|
|
22
|
+
return memberExpression.property.name;
|
|
23
|
+
}
|
|
24
|
+
if (memberExpression.property.type === "Literal" &&
|
|
25
|
+
typeof memberExpression.property.value === "string") {
|
|
26
|
+
return memberExpression.property.value;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
const isShellObjectExpression = (node) => {
|
|
31
|
+
if (node.type === "Identifier") {
|
|
32
|
+
return node.name === "shell";
|
|
33
|
+
}
|
|
34
|
+
if (node.type !== "MemberExpression") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return getMemberPropertyName(node) === "shell";
|
|
38
|
+
};
|
|
39
|
+
const isShellOpenExternalCallee = (callee) => {
|
|
40
|
+
if (callee.type !== "MemberExpression") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (getMemberPropertyName(callee) !== "openExternal") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return isShellObjectExpression(callee.object);
|
|
47
|
+
};
|
|
48
|
+
/** Rule implementation. */
|
|
49
|
+
const rule = createRule({
|
|
50
|
+
create(context) {
|
|
51
|
+
return {
|
|
52
|
+
CallExpression(node) {
|
|
53
|
+
if (!isShellOpenExternalCallee(node.callee)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const [firstArgument] = node.arguments;
|
|
57
|
+
if (firstArgument === undefined ||
|
|
58
|
+
firstArgument.type === "SpreadElement") {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const firstArgumentValue = getStringValue(firstArgument);
|
|
62
|
+
if (typeof firstArgumentValue === "string" &&
|
|
63
|
+
isAllowedExternalProtocol(firstArgumentValue)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
context.report({
|
|
67
|
+
messageId: "default",
|
|
68
|
+
node: firstArgument,
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
defaultOptions: [],
|
|
74
|
+
meta: {
|
|
75
|
+
deprecated: false,
|
|
76
|
+
docs: {
|
|
77
|
+
description: "disallow untrusted or non-HTTPS/non-mailto URLs in Electron shell.openExternal calls.",
|
|
78
|
+
frozen: false,
|
|
79
|
+
recommended: false,
|
|
80
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-SDL-2/docs/rules/no-electron-untrusted-open-external",
|
|
81
|
+
},
|
|
82
|
+
messages: {
|
|
83
|
+
default: "Only open trusted https: or mailto: URLs with shell.openExternal.",
|
|
84
|
+
},
|
|
85
|
+
schema: [],
|
|
86
|
+
type: "problem",
|
|
87
|
+
},
|
|
88
|
+
name: "no-electron-untrusted-open-external",
|
|
89
|
+
});
|
|
90
|
+
export default rule;
|
|
91
|
+
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types -- Restore linting after rule implementation declarations. */
|
|
92
|
+
//# sourceMappingURL=no-electron-untrusted-open-external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-untrusted-open-external.js","sourceRoot":"","sources":["../../src/rules/no-electron-untrusted-open-external.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAIzD,MAAM,6BAA6B,GAAG,CAClC,eAAyC,EACvB,EAAE;IACpB,IAAI,eAAe,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAyB,EAAsB,EAAE;IACrE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,CAA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AC;AAEH,eAAe,IAAI,CAAC;AACpB,iIAAiI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-electron-webview-allowpopups.d.ts","sourceRoot":"","sources":["../../src/rules/no-electron-webview-allowpopups.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAuDzD,2BAA2B;AAC3B,QAAA,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAkDtC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|