eslint-plugin-browser-security 1.2.14 → 1.3.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/README.md CHANGED
@@ -131,7 +131,7 @@ window.addEventListener('message', (event) => {
131
131
  ## 📦 Compatibility
132
132
  | Package | Version |
133
133
  | :--- | :--- |
134
- | ESLint | `^8.0.0 \|\| ^9.0.0 \|\| ^10.0.0` |
134
+ | ESLint | `^8.40.0 \|\| ^9.0.0 \|\| ^10.0.0` |
135
135
  | Node.js | `>=18.0.0` |
136
136
 
137
137
  See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-browser-security",
3
- "version": "1.2.14",
3
+ "version": "1.3.0",
4
4
  "description": "ESLint plugin for browser security — detects DOM XSS, postMessage abuse, tokens in localStorage, insecure cookies, clickjacking, mixed content, and CSP gaps.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -73,10 +73,10 @@
73
73
  "node": ">=18.0.0"
74
74
  },
75
75
  "dependencies": {
76
- "@interlace/eslint-devkit": "^1.10.0"
76
+ "@interlace/eslint-devkit": "^1.11.0"
77
77
  },
78
78
  "peerDependencies": {
79
- "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
79
+ "eslint": "^8.40.0 || ^9.0.0 || ^10.0.0"
80
80
  },
81
81
  "funding": {
82
82
  "type": "github",
package/src/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;exports.rules={get"no-innerhtml"(){return require("./rules/no-innerhtml").noInnerhtml},get"no-eval"(){return require("./rules/no-eval").noEval},get"require-postmessage-origin-check"(){return require("./rules/require-postmessage-origin-check").requirePostmessageOriginCheck},get"no-postmessage-wildcard-origin"(){return require("./rules/no-postmessage-wildcard-origin").noPostmessageWildcardOrigin},get"no-postmessage-innerhtml"(){return require("./rules/no-postmessage-innerhtml").noPostmessageInnerhtml},get"no-sensitive-localstorage"(){return require("./rules/no-sensitive-localstorage").noSensitiveLocalstorage},get"no-jwt-in-storage"(){return require("./rules/no-jwt-in-storage").noJwtInStorage},get"no-sensitive-sessionstorage"(){return require("./rules/no-sensitive-sessionstorage").noSensitiveSessionstorage},get"no-sensitive-indexeddb"(){return require("./rules/no-sensitive-indexeddb").noSensitiveIndexeddb},get"no-sensitive-cookie-js"(){return require("./rules/no-sensitive-cookie-js").noSensitiveCookieJs},get"no-cookie-auth-tokens"(){return require("./rules/no-cookie-auth-tokens").noCookieAuthTokens},get"require-cookie-secure-attrs"(){return require("./rules/require-cookie-secure-attrs").requireCookieSecureAttrs},get"require-websocket-wss"(){return require("./rules/require-websocket-wss").requireWebsocketWss},get"no-websocket-innerhtml"(){return require("./rules/no-websocket-innerhtml").noWebsocketInnerhtml},get"no-websocket-eval"(){return require("./rules/no-websocket-eval").noWebsocketEval},get"no-filereader-innerhtml"(){return require("./rules/no-filereader-innerhtml").noFilereaderInnerhtml},get"require-blob-url-revocation"(){return require("./rules/require-blob-url-revocation").requireBlobUrlRevocation},get"no-dynamic-service-worker-url"(){return require("./rules/no-dynamic-service-worker-url").noDynamicServiceWorkerUrl},get"no-worker-message-innerhtml"(){return require("./rules/no-worker-message-innerhtml").noWorkerMessageInnerhtml},get"no-unsafe-inline-csp"(){return require("./rules/no-unsafe-inline-csp").noUnsafeInlineCsp},get"no-unsafe-eval-csp"(){return require("./rules/no-unsafe-eval-csp").noUnsafeEvalCsp},get"detect-mixed-content"(){return require("./rules/detect-mixed-content").detectMixedContent},get"no-allow-arbitrary-loads"(){return require("./rules/no-allow-arbitrary-loads").noAllowArbitraryLoads},get"no-clickjacking"(){return require("./rules/no-clickjacking").noClickjacking},get"no-credentials-in-query-params"(){return require("./rules/no-credentials-in-query-params").noCredentialsInQueryParams},get"no-http-urls"(){return require("./rules/no-http-urls").noHttpUrls},get"no-insecure-redirects"(){return require("./rules/no-insecure-redirects").noInsecureRedirects},get"no-insecure-websocket"(){return require("./rules/no-insecure-websocket").noInsecureWebsocket},get"no-missing-cors-check"(){return require("./rules/no-missing-cors-check").noMissingCorsCheck},get"no-missing-csrf-protection"(){return require("./rules/no-missing-csrf-protection").noMissingCsrfProtection},get"no-missing-security-headers"(){return require("./rules/no-missing-security-headers").noMissingSecurityHeaders},get"no-password-in-url"(){return require("./rules/no-password-in-url").noPasswordInUrl},get"no-permissive-cors"(){return require("./rules/no-permissive-cors").noPermissiveCors},get"no-sensitive-data-in-analytics"(){return require("./rules/no-sensitive-data-in-analytics").noSensitiveDataInAnalytics},get"no-sensitive-data-in-cache"(){return require("./rules/no-sensitive-data-in-cache").noSensitiveDataInCache},get"no-tracking-without-consent"(){return require("./rules/no-tracking-without-consent").noTrackingWithoutConsent},get"no-unencrypted-transmission"(){return require("./rules/no-unencrypted-transmission").noUnencryptedTransmission},get"no-unescaped-url-parameter"(){return require("./rules/no-unescaped-url-parameter").noUnescapedUrlParameter},get"no-unvalidated-deeplinks"(){return require("./rules/no-unvalidated-deeplinks").noUnvalidatedDeeplinks},get"require-csp-headers"(){return require("./rules/require-csp-headers").requireCspHeaders},get"require-https-only"(){return require("./rules/require-https-only").requireHttpsOnly},get"require-url-validation"(){return require("./rules/require-url-validation").requireUrlValidation},get"require-mime-type-validation"(){return require("./rules/require-mime-type-validation").requireMimeTypeValidation},get"no-disabled-certificate-validation"(){return require("./rules/no-disabled-certificate-validation").noDisabledCertificateValidation},get"no-client-side-auth-logic"(){return require("./rules/no-client-side-auth-logic").noClientSideAuthLogic}};exports.plugin={meta:{name:"eslint-plugin-browser-security",version:"1.2.14"},rules:exports.rules};const recommendedRules={"browser-security/no-innerhtml":"error","browser-security/no-eval":"error","browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error","browser-security/no-postmessage-innerhtml":"error","browser-security/no-sensitive-localstorage":"error","browser-security/no-jwt-in-storage":"error","browser-security/no-sensitive-sessionstorage":"error","browser-security/no-sensitive-indexeddb":"error","browser-security/no-sensitive-cookie-js":"error","browser-security/no-cookie-auth-tokens":"error","browser-security/require-cookie-secure-attrs":"error","browser-security/require-websocket-wss":"error","browser-security/no-websocket-innerhtml":"error","browser-security/no-websocket-eval":"error","browser-security/no-filereader-innerhtml":"error","browser-security/require-blob-url-revocation":"warn","browser-security/no-dynamic-service-worker-url":"error","browser-security/no-worker-message-innerhtml":"error","browser-security/no-unsafe-inline-csp":"error","browser-security/no-unsafe-eval-csp":"error","browser-security/detect-mixed-content":"error","browser-security/no-allow-arbitrary-loads":"error","browser-security/no-clickjacking":"error","browser-security/no-credentials-in-query-params":"error","browser-security/no-http-urls":"error","browser-security/no-insecure-redirects":"error","browser-security/require-https-only":"error","browser-security/no-insecure-websocket":"error","browser-security/no-unvalidated-deeplinks":"error","browser-security/no-client-side-auth-logic":"error"};exports.configs={flagship:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-postmessage-wildcard-origin":"error"}},recommended:{plugins:{"browser-security":exports.plugin},rules:recommendedRules},strict:{plugins:{"browser-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`browser-security/${ruleName}`,"error"]))},xss:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-innerhtml":"error","browser-security/no-eval":"error"}},storage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-localstorage":"error"}},postmessage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error"}},websocket:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-websocket-wss":"error"}},cookies:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-cookie-js":"error"}}};exports.default=exports.plugin;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;exports.rules={get"no-innerhtml"(){return require("./rules/no-innerhtml").noInnerhtml},get"no-eval"(){return require("./rules/no-eval").noEval},get"require-postmessage-origin-check"(){return require("./rules/require-postmessage-origin-check").requirePostmessageOriginCheck},get"no-postmessage-wildcard-origin"(){return require("./rules/no-postmessage-wildcard-origin").noPostmessageWildcardOrigin},get"no-postmessage-innerhtml"(){return require("./rules/no-postmessage-innerhtml").noPostmessageInnerhtml},get"no-sensitive-localstorage"(){return require("./rules/no-sensitive-localstorage").noSensitiveLocalstorage},get"no-jwt-in-storage"(){return require("./rules/no-jwt-in-storage").noJwtInStorage},get"no-sensitive-sessionstorage"(){return require("./rules/no-sensitive-sessionstorage").noSensitiveSessionstorage},get"no-sensitive-indexeddb"(){return require("./rules/no-sensitive-indexeddb").noSensitiveIndexeddb},get"no-sensitive-cookie-js"(){return require("./rules/no-sensitive-cookie-js").noSensitiveCookieJs},get"no-cookie-auth-tokens"(){return require("./rules/no-cookie-auth-tokens").noCookieAuthTokens},get"require-cookie-secure-attrs"(){return require("./rules/require-cookie-secure-attrs").requireCookieSecureAttrs},get"require-websocket-wss"(){return require("./rules/require-websocket-wss").requireWebsocketWss},get"no-websocket-innerhtml"(){return require("./rules/no-websocket-innerhtml").noWebsocketInnerhtml},get"no-websocket-eval"(){return require("./rules/no-websocket-eval").noWebsocketEval},get"no-filereader-innerhtml"(){return require("./rules/no-filereader-innerhtml").noFilereaderInnerhtml},get"require-blob-url-revocation"(){return require("./rules/require-blob-url-revocation").requireBlobUrlRevocation},get"no-dynamic-service-worker-url"(){return require("./rules/no-dynamic-service-worker-url").noDynamicServiceWorkerUrl},get"no-worker-message-innerhtml"(){return require("./rules/no-worker-message-innerhtml").noWorkerMessageInnerhtml},get"no-unsafe-inline-csp"(){return require("./rules/no-unsafe-inline-csp").noUnsafeInlineCsp},get"no-unsafe-eval-csp"(){return require("./rules/no-unsafe-eval-csp").noUnsafeEvalCsp},get"detect-mixed-content"(){return require("./rules/detect-mixed-content").detectMixedContent},get"no-allow-arbitrary-loads"(){return require("./rules/no-allow-arbitrary-loads").noAllowArbitraryLoads},get"no-clickjacking"(){return require("./rules/no-clickjacking").noClickjacking},get"no-credentials-in-query-params"(){return require("./rules/no-credentials-in-query-params").noCredentialsInQueryParams},get"no-http-urls"(){return require("./rules/no-http-urls").noHttpUrls},get"no-insecure-redirects"(){return require("./rules/no-insecure-redirects").noInsecureRedirects},get"no-insecure-websocket"(){return require("./rules/no-insecure-websocket").noInsecureWebsocket},get"no-missing-cors-check"(){return require("./rules/no-missing-cors-check").noMissingCorsCheck},get"no-missing-csrf-protection"(){return require("./rules/no-missing-csrf-protection").noMissingCsrfProtection},get"no-missing-security-headers"(){return require("./rules/no-missing-security-headers").noMissingSecurityHeaders},get"no-password-in-url"(){return require("./rules/no-password-in-url").noPasswordInUrl},get"no-permissive-cors"(){return require("./rules/no-permissive-cors").noPermissiveCors},get"no-sensitive-data-in-analytics"(){return require("./rules/no-sensitive-data-in-analytics").noSensitiveDataInAnalytics},get"no-sensitive-data-in-cache"(){return require("./rules/no-sensitive-data-in-cache").noSensitiveDataInCache},get"no-tracking-without-consent"(){return require("./rules/no-tracking-without-consent").noTrackingWithoutConsent},get"no-unencrypted-transmission"(){return require("./rules/no-unencrypted-transmission").noUnencryptedTransmission},get"no-unescaped-url-parameter"(){return require("./rules/no-unescaped-url-parameter").noUnescapedUrlParameter},get"no-unvalidated-deeplinks"(){return require("./rules/no-unvalidated-deeplinks").noUnvalidatedDeeplinks},get"require-csp-headers"(){return require("./rules/require-csp-headers").requireCspHeaders},get"require-https-only"(){return require("./rules/require-https-only").requireHttpsOnly},get"require-url-validation"(){return require("./rules/require-url-validation").requireUrlValidation},get"require-mime-type-validation"(){return require("./rules/require-mime-type-validation").requireMimeTypeValidation},get"no-disabled-certificate-validation"(){return require("./rules/no-disabled-certificate-validation").noDisabledCertificateValidation},get"no-client-side-auth-logic"(){return require("./rules/no-client-side-auth-logic").noClientSideAuthLogic}};exports.plugin={meta:{name:"eslint-plugin-browser-security",version:"1.3.0"},rules:exports.rules};const recommendedRules={"browser-security/no-innerhtml":"error","browser-security/no-eval":"error","browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error","browser-security/no-postmessage-innerhtml":"error","browser-security/no-sensitive-localstorage":"error","browser-security/no-jwt-in-storage":"error","browser-security/no-sensitive-sessionstorage":"error","browser-security/no-sensitive-indexeddb":"error","browser-security/no-sensitive-cookie-js":"error","browser-security/no-cookie-auth-tokens":"error","browser-security/require-cookie-secure-attrs":"error","browser-security/require-websocket-wss":"error","browser-security/no-websocket-innerhtml":"error","browser-security/no-websocket-eval":"error","browser-security/no-filereader-innerhtml":"error","browser-security/require-blob-url-revocation":"warn","browser-security/no-dynamic-service-worker-url":"error","browser-security/no-worker-message-innerhtml":"error","browser-security/no-unsafe-inline-csp":"error","browser-security/no-unsafe-eval-csp":"error","browser-security/detect-mixed-content":"error","browser-security/no-allow-arbitrary-loads":"error","browser-security/no-clickjacking":"error","browser-security/no-credentials-in-query-params":"error","browser-security/no-http-urls":"error","browser-security/no-insecure-redirects":"error","browser-security/require-https-only":"error","browser-security/no-insecure-websocket":"error","browser-security/no-unvalidated-deeplinks":"error","browser-security/no-client-side-auth-logic":"error"};exports.configs={flagship:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-postmessage-wildcard-origin":"error"}},recommended:{plugins:{"browser-security":exports.plugin},rules:recommendedRules},strict:{plugins:{"browser-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`browser-security/${ruleName}`,"error"]))},xss:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-innerhtml":"error","browser-security/no-eval":"error"}},storage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-localstorage":"error"}},postmessage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error"}},websocket:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-websocket-wss":"error"}},cookies:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-cookie-js":"error"}}};exports.default=exports.plugin;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClickjacking=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const eslint_devkit_3=require("@interlace/eslint-devkit");exports.noClickjacking=(0,eslint_devkit_1.createRule)({name:"no-clickjacking",meta:{type:"problem",deprecated:true,replacedBy:["@see eslint-plugin-express-security/require-helmet"],docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-clickjacking.md",description:"Detects clickjacking vulnerabilities and missing frame protections",cwe:"CWE-1021"},hasSuggestions:true,messages:{clickjackingVulnerability:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Clickjacking Vulnerability",cwe:"CWE-1021",description:"Clickjacking protection missing",severity:"{{severity}}",fix:"{{safeAlternative}}",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing Frame Busting",cwe:"CWE-1021",description:"No frame-busting code to prevent clickjacking",severity:"HIGH",fix:"Add frame-busting JavaScript to prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),unsafeIframeUsage:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Unsafe iframe Usage",cwe:"CWE-1021",description:"iframe may enable clickjacking attacks",severity:"MEDIUM",fix:"Add X-Frame-Options or CSP frame-ancestors protection",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing X-Frame-Options",cwe:"CWE-1021",description:"X-Frame-Options header not set",severity:"HIGH",fix:"Set X-Frame-Options: DENY or SAMEORIGIN",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),missingCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing CSP frame-ancestors",cwe:"CWE-1021",description:"CSP frame-ancestors directive not configured",severity:"HIGH",fix:"Add frame-ancestors to Content-Security-Policy",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),transparentFrameOverlay:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Transparent Frame Overlay",cwe:"CWE-1021",description:"Transparent elements may hide clickjacking attacks",severity:"MEDIUM",fix:"Use frame-busting or CSP protections",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),frameManipulation:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Frame Manipulation",cwe:"CWE-1021",description:"Code attempts to manipulate parent frames",severity:"LOW",fix:"Implement proper frame communication or prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),implementFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Implement Frame Busting",description:"Add JavaScript to prevent framing",severity:"LOW",fix:"if (top != self) top.location = location;",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),useXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use X-Frame-Options",description:"Set X-Frame-Options HTTP header",severity:"LOW",fix:"X-Frame-Options: DENY",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),setCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Set CSP frame-ancestors",description:"Configure CSP frame-ancestors directive",severity:"LOW",fix:"frame-ancestors 'self' https://trusted.com",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),strategyFrameProtection:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Frame Protection Strategy",description:"Implement multiple layers of frame protection",severity:"LOW",fix:"Use X-Frame-Options, CSP, and frame-busting together",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),strategyContentSecurity:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Content Security Strategy",description:"Use CSP for comprehensive frame control",severity:"LOW",fix:"Implement strict CSP with frame-ancestors",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),strategyUserInteraction:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"User Interaction Strategy",description:"Protect user interactions from framing attacks",severity:"LOW",fix:"Validate user intent for sensitive actions",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"})},schema:[{type:"object",properties:{trustedSources:{type:"array",items:{type:"string"},default:["self","same-origin"],description:"Frame-ancestor sources treated as safe"},requireFrameBusting:{type:"boolean",default:true,description:"Require frame-busting code in addition to headers"},detectTransparentOverlays:{type:"boolean",default:true,description:"Report transparent overlays positioned over clickable elements"},trustedSanitizers:{type:"array",items:{type:"string"},default:[],description:"Additional function names to consider as frame protectors"},trustedAnnotations:{type:"array",items:{type:"string"},default:[],description:"Additional JSDoc annotations to consider as safe markers"},strictMode:{type:"boolean",default:false,description:"Disable all false positive detection (strict mode)"}},additionalProperties:false}]},defaultOptions:[{trustedSources:["self","same-origin"],requireFrameBusting:true,detectTransparentOverlays:true,trustedSanitizers:[],trustedAnnotations:[],strictMode:false}],create(context){const options=context.options[0]||{};const{trustedSources=["self","same-origin"],requireFrameBusting=true,detectTransparentOverlays=true,trustedSanitizers=[],trustedAnnotations=[],strictMode=false}=options;const sourceCode=context.sourceCode;const filename=context.filename;const safetyChecker=(0,eslint_devkit_3.createSafetyChecker)({trustedSanitizers,trustedAnnotations,trustedOrmPatterns:[],strictMode});let hasFrameBusting=false;const isTrustedSource=source=>{return trustedSources.some(trusted=>source.includes(trusted)||trusted==="self"&&(source==="self"||source.startsWith("/"))||trusted==="same-origin"&&source==="same-origin")};const isFrameBustingCode=node=>{const test=node.test;const testText=sourceCode.getText(test).toLowerCase();return testText.includes("top != self")||testText.includes("top !== self")||testText.includes("window.top !== window.self")||testText.includes("parent != self")||testText.includes("top.location")||testText.includes("self.location")};const hasTransparentStyles=styleText=>{const styles=styleText.toLowerCase();return styles.includes("opacity: 0")||styles.includes("opacity:0")||styles.includes("visibility: hidden")||styles.includes("display: none")||styles.includes("z-index: -1")||styles.includes("position: absolute")&&styles.includes("top: 0")&&styles.includes("left: 0")};return{IfStatement(node){if(isFrameBustingCode(node)){hasFrameBusting=true}},JSXElement(node){if(node.openingElement.name.type==="JSXIdentifier"&&node.openingElement.name.name==="iframe"){const attributes=node.openingElement.attributes;let hasSrc=false;let srcValue="";for(const attr of attributes){if(attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="src"&&attr.value){hasSrc=true;if(attr.value.type==="Literal"&&typeof attr.value.value==="string"){srcValue=attr.value.value}}}if(hasSrc&&srcValue&&!isTrustedSource(srcValue)){if(safetyChecker.isSafe(node,context)){return}context.report({node:node.openingElement,messageId:"unsafeIframeUsage",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},MemberExpression(node){if(node.object.type==="Identifier"&&(node.object.name==="top"||node.object.name==="window")){if(node.property.type==="Identifier"&&(node.property.name==="location"||node.property.name==="top")){let current=node;let isFrameManipulation=false;while(current){if(current.type==="AssignmentExpression"&&current.left===node){isFrameManipulation=true;break}if(current.type==="BinaryExpression"&&(current.left===node||current.right===node)){const operator=current.operator;if(operator==="!="||operator==="!=="||operator==="=="||operator==="==="){break}isFrameManipulation=true;break}current=current.parent}if(isFrameManipulation){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"frameManipulation",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}}},Literal(node){if(typeof node.value==="string"&&detectTransparentOverlays){const text=node.value.toLowerCase();if((text.includes("style=")||text.includes("css"))&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},TemplateLiteral(node){if(detectTransparentOverlays){const text=sourceCode.getText(node).toLowerCase();if(text.includes("style")&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},"Program:exit"(){if(requireFrameBusting&&!hasFrameBusting){const isEntryPoint=/\.(html|htm)$/.test(filename)||/(index|app|main|page)\.(tsx|jsx)$/i.test(filename)||/pages?\/.*\.(tsx|jsx)$/i.test(filename)||/layout\.(tsx|jsx)$/i.test(filename);if(!isEntryPoint){return}const fileContent=sourceCode.getText();const hasUIElements=fileContent.includes("<button")||fileContent.includes("<form")||fileContent.includes("<input")||fileContent.includes("onClick")&&fileContent.includes("<");if(hasUIElements){context.report({node:context.sourceCode.ast,messageId:"missingFrameBusting",data:{filePath:filename,line:"1"}})}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClickjacking=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const eslint_devkit_3=require("@interlace/eslint-devkit");const FRAME_REFS=new Set(["top","self","parent","window"]);function isFrameRef(node){if(node.type==="Identifier")return FRAME_REFS.has(node.name);if(node.type==="MemberExpression"&&node.object.type==="Identifier"&&node.object.name==="window"){return node.property.type==="Identifier"&&FRAME_REFS.has(node.property.name)}return false}function isFrameBustingTest(test){return test.type==="BinaryExpression"&&["!=","!==","==","==="].includes(test.operator)&&isFrameRef(test.left)&&isFrameRef(test.right)}const FUNCTION_TYPES=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]);function runsOnlyInsideGuard(fn,guard,sourceCode){const parent=fn.parent;if(parent?.type==="CallExpression"&&parent.arguments.includes(fn)){return true}if(parent?.type==="CallExpression"&&parent.callee===fn)return true;const declarator=fn.type==="FunctionDeclaration"?fn:parent?.type==="VariableDeclarator"?parent:void 0;if(declarator===void 0)return false;return sourceCode.getDeclaredVariables(declarator).every(variable=>variable.references.every(ref=>ref.identifier.range[0]>=guard.range[0]&&ref.identifier.range[1]<=guard.range[1]))}function insideFrameBustingGuard(node,sourceCode){const crossed=[];let current=node.parent;while(current){if(FUNCTION_TYPES.has(current.type))crossed.push(current);if(current.type==="IfStatement"&&isFrameBustingTest(current.test)){const guard=current;return crossed.every(fn=>runsOnlyInsideGuard(fn,guard,sourceCode))}current=current.parent}return false}exports.noClickjacking=(0,eslint_devkit_1.createRule)({name:"no-clickjacking",meta:{type:"problem",deprecated:true,replacedBy:["@see eslint-plugin-express-security/require-helmet"],docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-clickjacking.md",description:"Detects clickjacking vulnerabilities and missing frame protections",cwe:"CWE-1021"},messages:{clickjackingVulnerability:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Clickjacking Vulnerability",cwe:"CWE-1021",description:"Clickjacking protection missing",severity:"{{severity}}",fix:"{{safeAlternative}}",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing Frame Busting",cwe:"CWE-1021",description:"No frame-busting code to prevent clickjacking",severity:"HIGH",fix:"Add frame-busting JavaScript to prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),unsafeIframeUsage:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Unsafe iframe Usage",cwe:"CWE-1021",description:"iframe may enable clickjacking attacks",severity:"MEDIUM",fix:"Add X-Frame-Options or CSP frame-ancestors protection",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing X-Frame-Options",cwe:"CWE-1021",description:"X-Frame-Options header not set",severity:"HIGH",fix:"Set X-Frame-Options: DENY or SAMEORIGIN",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),missingCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing CSP frame-ancestors",cwe:"CWE-1021",description:"CSP frame-ancestors directive not configured",severity:"HIGH",fix:"Add frame-ancestors to Content-Security-Policy",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),transparentFrameOverlay:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Transparent Frame Overlay",cwe:"CWE-1021",description:"Transparent elements may hide clickjacking attacks",severity:"MEDIUM",fix:"Use frame-busting or CSP protections",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),frameManipulation:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Frame Manipulation",cwe:"CWE-1021",description:"Code attempts to manipulate parent frames",severity:"LOW",fix:"Implement proper frame communication or prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),implementFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Implement Frame Busting",description:"Add JavaScript to prevent framing",severity:"LOW",fix:"if (top != self) top.location = location;",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),useXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use X-Frame-Options",description:"Set X-Frame-Options HTTP header",severity:"LOW",fix:"X-Frame-Options: DENY",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),setCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Set CSP frame-ancestors",description:"Configure CSP frame-ancestors directive",severity:"LOW",fix:"frame-ancestors 'self' https://trusted.com",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),strategyFrameProtection:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Frame Protection Strategy",description:"Implement multiple layers of frame protection",severity:"LOW",fix:"Use X-Frame-Options, CSP, and frame-busting together",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),strategyContentSecurity:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Content Security Strategy",description:"Use CSP for comprehensive frame control",severity:"LOW",fix:"Implement strict CSP with frame-ancestors",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),strategyUserInteraction:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"User Interaction Strategy",description:"Protect user interactions from framing attacks",severity:"LOW",fix:"Validate user intent for sensitive actions",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"})},schema:[{type:"object",properties:{trustedSources:{type:"array",items:{type:"string"},default:["self","same-origin"],description:"Frame-ancestor sources treated as safe"},requireFrameBusting:{type:"boolean",default:true,description:"Require frame-busting code in addition to headers"},detectTransparentOverlays:{type:"boolean",default:true,description:"Report transparent overlays positioned over clickable elements"},trustedSanitizers:{type:"array",items:{type:"string"},default:[],description:"Additional function names to consider as frame protectors"},trustedAnnotations:{type:"array",items:{type:"string"},default:[],description:"Additional JSDoc annotations to consider as safe markers"},strictMode:{type:"boolean",default:false,description:"Disable all false positive detection (strict mode)"}},additionalProperties:false}]},defaultOptions:[{trustedSources:["self","same-origin"],requireFrameBusting:true,detectTransparentOverlays:true,trustedSanitizers:[],trustedAnnotations:[],strictMode:false}],create(context){const options=context.options[0]||{};const{trustedSources=["self","same-origin"],requireFrameBusting=true,detectTransparentOverlays=true,trustedSanitizers=[],trustedAnnotations=[],strictMode=false}=options;const sourceCode=context.sourceCode;const filename=context.filename;const safetyChecker=(0,eslint_devkit_3.createSafetyChecker)({trustedSanitizers,trustedAnnotations,trustedOrmPatterns:[],strictMode});let hasFrameBusting=false;const isTrustedSource=source=>{return trustedSources.some(trusted=>source.includes(trusted)||trusted==="self"&&(source==="self"||source.startsWith("/"))||trusted==="same-origin"&&source==="same-origin")};const isFrameBustingCode=node=>{const test=node.test;const testText=sourceCode.getText(test).toLowerCase();return testText.includes("top != self")||testText.includes("top !== self")||testText.includes("window.top !== window.self")||testText.includes("parent != self")||testText.includes("top.location")||testText.includes("self.location")};const hasTransparentStyles=styleText=>{const styles=styleText.toLowerCase();return styles.includes("opacity: 0")||styles.includes("opacity:0")||styles.includes("visibility: hidden")||styles.includes("display: none")||styles.includes("z-index: -1")||styles.includes("position: absolute")&&styles.includes("top: 0")&&styles.includes("left: 0")};return{IfStatement(node){if(isFrameBustingCode(node)){hasFrameBusting=true}},JSXElement(node){if(node.openingElement.name.type==="JSXIdentifier"&&node.openingElement.name.name==="iframe"){const attributes=node.openingElement.attributes;let hasSrc=false;let srcValue="";for(const attr of attributes){if(attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="src"&&attr.value){hasSrc=true;if(attr.value.type==="Literal"&&typeof attr.value.value==="string"){srcValue=attr.value.value}}}if(hasSrc&&srcValue&&!isTrustedSource(srcValue)){if(safetyChecker.isSafe(node,context)){return}context.report({node:node.openingElement,messageId:"unsafeIframeUsage",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},MemberExpression(node){if(node.object.type==="Identifier"&&(node.object.name==="top"||node.object.name==="window")){if(node.property.type==="Identifier"&&(node.property.name==="location"||node.property.name==="top")){let current=node;let isFrameManipulation=false;while(current){if(current.type==="AssignmentExpression"&&current.left===node){isFrameManipulation=true;break}if(current.type==="BinaryExpression"&&(current.left===node||current.right===node)){const operator=current.operator;if(operator==="!="||operator==="!=="||operator==="=="||operator==="==="){break}isFrameManipulation=true;break}current=current.parent}if(isFrameManipulation){if(safetyChecker.isSafe(node,context)){return}if(insideFrameBustingGuard(node,sourceCode)){return}context.report({node,messageId:"frameManipulation",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}}},Literal(node){if(typeof node.value==="string"&&detectTransparentOverlays){const text=node.value.toLowerCase();if((text.includes("style=")||text.includes("css"))&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},TemplateLiteral(node){if(detectTransparentOverlays){const text=sourceCode.getText(node).toLowerCase();if(text.includes("style")&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},"Program:exit"(){if(requireFrameBusting&&!hasFrameBusting){const isEntryPoint=/\.(html|htm)$/.test(filename)||/(index|app|main|page)\.(tsx|jsx)$/i.test(filename)||/pages?\/.*\.(tsx|jsx)$/i.test(filename)||/layout\.(tsx|jsx)$/i.test(filename);if(!isEntryPoint){return}const fileContent=sourceCode.getText();const hasUIElements=fileContent.includes("<button")||fileContent.includes("<form")||fileContent.includes("<input")||fileContent.includes("onClick")&&fileContent.includes("<");if(hasUIElements){context.report({node:context.sourceCode.ast,messageId:"missingFrameBusting",data:{filePath:filename,line:"1"}})}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_FUNCTIONS=new Set(["eval","execScript"]);const DANGEROUS_METHODS_WITH_STRING_ARG=new Set(["setTimeout","setInterval","setImmediate"]);exports.noEval=(0,eslint_devkit_1.createRule)({name:"no-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-eval.md",description:"Disallow eval(), Function(), and other code execution patterns",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{dangerousEval:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Code Injection via {{function}}",cwe:"CWE-95",description:"Using {{function}} with dynamic input can execute arbitrary code. This is a critical security vulnerability.",severity:"CRITICAL",fix:"Use safe alternatives like JSON.parse() for data, or refactor to avoid dynamic code execution.",documentationLink:"https://owasp.org/www-community/attacks/Code_Injection"}),useSafeAlternative:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Safe Alternative",description:"Replace with a safe alternative",severity:"LOW",fix:"Use JSON.parse() for JSON, or define functions statically.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},allowFunctionConstructor:{type:"boolean",default:false,description:"Allow `new Function(...)` while still reporting `eval()`"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,allowFunctionConstructor:false}],create(context,[options={}]){const{allowInTests=false,allowFunctionConstructor=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}return{CallExpression(node){const callee=node.callee;if(callee.type==="Identifier"){if(DANGEROUS_FUNCTIONS.has(callee.name)){context.report({node,messageId:"dangerousEval",data:{function:callee.name},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]});return}if(DANGEROUS_METHODS_WITH_STRING_ARG.has(callee.name)){const firstArg=node.arguments[0];if(firstArg&&firstArg.type==="Literal"&&typeof firstArg.value==="string"){context.report({node,messageId:"dangerousEval",data:{function:`${callee.name} with string`},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}if(callee.type==="MemberExpression"){let propertyName=null;if(!callee.computed&&callee.property.type==="Identifier"&&DANGEROUS_FUNCTIONS.has(callee.property.name)){propertyName=callee.property.name}else if(callee.computed&&callee.property.type==="Literal"&&typeof callee.property.value==="string"&&DANGEROUS_FUNCTIONS.has(callee.property.value)){propertyName=callee.property.value}if(propertyName){context.report({node,messageId:"dangerousEval",data:{function:propertyName},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}},NewExpression(node){if(allowFunctionConstructor){return}const callee=node.callee;if(callee.type==="Identifier"&&callee.name==="Function"){context.report({node,messageId:"dangerousEval",data:{function:"Function constructor"},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DANGEROUS_FUNCTIONS=new Set(["eval","execScript"]);const DANGEROUS_METHODS_WITH_STRING_ARG=new Set(["setTimeout","setInterval","setImmediate"]);exports.noEval=(0,eslint_devkit_2.createRule)({name:"no-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-eval.md",description:"Disallow eval(), Function(), and other code execution patterns",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{dangerousEval:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Code Injection via {{function}}",cwe:"CWE-95",description:"Using {{function}} with dynamic input can execute arbitrary code. This is a critical security vulnerability.",severity:"CRITICAL",fix:"Use safe alternatives like JSON.parse() for data, or refactor to avoid dynamic code execution.",documentationLink:"https://owasp.org/www-community/attacks/Code_Injection"}),useSafeAlternative:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use Safe Alternative",description:"Replace with a safe alternative",severity:"LOW",fix:"Use JSON.parse() for JSON, or define functions statically.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},allowFunctionConstructor:{type:"boolean",default:false,description:"Allow `new Function(...)` while still reporting `eval()`"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,allowFunctionConstructor:false}],create(context,[options={}]){const{allowInTests=false,allowFunctionConstructor=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{CallExpression(node){const callee=node.callee;if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(callee.type==="Identifier"){if(DANGEROUS_FUNCTIONS.has(callee.name)){context.report({node,messageId:"dangerousEval",data:{function:callee.name},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]});return}if(DANGEROUS_METHODS_WITH_STRING_ARG.has(callee.name)){const firstArg=node.arguments[0];if(firstArg&&firstArg.type==="Literal"&&typeof firstArg.value==="string"){context.report({node,messageId:"dangerousEval",data:{function:`${callee.name} with string`},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}if(callee.type==="MemberExpression"){let propertyName=null;if(!callee.computed&&callee.property.type==="Identifier"&&DANGEROUS_FUNCTIONS.has(callee.property.name)){propertyName=callee.property.name}else if(callee.computed&&callee.property.type==="Literal"&&typeof callee.property.value==="string"&&DANGEROUS_FUNCTIONS.has(callee.property.value)){propertyName=callee.property.value}if(propertyName){context.report({node,messageId:"dangerousEval",data:{function:propertyName},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}},NewExpression(node){if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(allowFunctionConstructor){return}const callee=node.callee;if(callee.type==="Identifier"&&callee.name==="Function"){context.report({node,messageId:"dangerousEval",data:{function:"Function constructor"},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noFilereaderInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noFilereaderInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-filereader-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-filereader-innerhtml.md",description:"Disallow using innerHTML or similar methods with FileReader data",cwe:"CWE-79",cvss:8.1},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via File Upload",cwe:"CWE-79",owasp:"A03:2021",cvss:8.1,description:"Using {{method}} with FileReader result enables XSS attacks. Malicious files can contain scripts that execute when rendered.",severity:"HIGH",fix:"Sanitize file content with DOMPurify before rendering, or use textContent for plain text.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/FileReader"}),sanitizeContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Sanitize File Content",description:"Use textContent or sanitize with DOMPurify",severity:"LOW",fix:"const sanitized = DOMPurify.sanitize(e.target.result);\nelement.innerHTML = sanitized;",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}let inFileReaderHandler=false;let eventParamName=null;function isFileReaderOnloadAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(node.left.property.name==="onload"||node.left.property.name==="onloadend")){const objName=node.left.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?node.left.object.name.toLowerCase():"";if(objName.includes("reader")||objName.includes("fr")||objName==="r"){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function isFileReaderAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&(eventType.value==="load"||eventType.value==="loadend")){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function referencesFileReaderResult(node,eventName){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="result"&&node.object.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.object.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.property.name==="target"&&node.object.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.object.name===eventName){return true}return referencesFileReaderResult(node.object,eventName)}return false}return{AssignmentExpression(node){const{isHandler,eventParam}=isFileReaderOnloadAssignment(node);if(isHandler){inFileReaderHandler=true;eventParamName=eventParam}if(!inFileReaderHandler||!eventParamName)return;if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(referencesFileReaderResult(node.right,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"sanitizeContent",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isFileReaderOnloadAssignment(node);if(isHandler){inFileReaderHandler=false;eventParamName=null}},CallExpression(node){const{isHandler,eventParam}=isFileReaderAddEventListener(node);if(isHandler){inFileReaderHandler=true;eventParamName=eventParam}if(!inFileReaderHandler||!eventParamName)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(referencesFileReaderResult(arg,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"sanitizeContent",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isFileReaderAddEventListener(node);if(isHandler){inFileReaderHandler=false;eventParamName=null}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noFilereaderInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);function readsFileReaderResult(node){let current=node;while(current.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(current.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&current.property.name==="result"){const owner=current.object;if(owner.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return true;return owner.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&owner.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&owner.property.name==="target"&&owner.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier}current=current.object}return false}exports.noFilereaderInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-filereader-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-filereader-innerhtml.md",description:"Disallow using innerHTML or similar methods with FileReader data",cwe:"CWE-79",cvss:8.1},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via File Upload",cwe:"CWE-79",owasp:"A03:2021",cvss:8.1,description:"Using {{method}} with FileReader result enables XSS attacks. Malicious files can contain scripts that execute when rendered.",severity:"HIGH",fix:"Sanitize file content with DOMPurify before rendering, or use textContent for plain text.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/FileReader"}),sanitizeContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Sanitize File Content",description:"Use textContent or sanitize with DOMPurify",severity:"LOW",fix:"const sanitized = DOMPurify.sanitize(e.target.result);\nelement.innerHTML = sanitized;",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}function isFileReaderOnloadAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(node.left.property.name==="onload"||node.left.property.name==="onloadend")){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}return{isHandler:false,eventParam:null}}function isFileReaderAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&(eventType.value==="load"||eventType.value==="loadend")){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(payloadSource(node.right)==="filereader"&&readsFileReaderResult(node.right)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"sanitizeContent",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isFileReaderOnloadAssignment(node);if(isHandler){}},CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(payloadSource(arg)==="filereader"&&readsFileReaderResult(arg)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"sanitizeContent",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isFileReaderAddEventListener(node);if(isHandler){}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DEFAULT_SANITIZERS=["DOMPurify.sanitize","sanitize","sanitizeHtml","xss","purify"];function isSanitized(node,sourceCode,sanitizers){const text=sourceCode.getText(node);return sanitizers.some(s=>text.includes(s))}function isLiteralString(node){if(node.type==="Literal"&&typeof node.value==="string"){return true}if(node.type==="TemplateLiteral"&&node.expressions.length===0){return true}return false}exports.noInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-innerhtml.md",description:"Disallow dangerous innerHTML/outerHTML assignments that can lead to XSS",cwe:"CWE-79",cvss:6.1,confidence:"medium"},hasSuggestions:true,messages:{dangerousInnerHTML:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Cross-Site Scripting (XSS) via innerHTML",cwe:"CWE-79",description:"Assigning to {{property}} with {{source}} can execute malicious scripts. This is a critical XSS vulnerability.",severity:"CRITICAL",fix:"Use textContent for text, or sanitize with DOMPurify.sanitize() before assignment.",documentationLink:"https://owasp.org/www-community/attacks/xss/"}),useSanitizer:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use HTML Sanitizer",description:"Sanitize HTML before assignment",severity:"LOW",fix:"element.innerHTML = DOMPurify.sanitize(userInput);",documentationLink:"https://www.npmjs.com/package/dompurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedSanitizers:{type:"array",items:{type:"string"},default:DEFAULT_SANITIZERS},allowLiteralStrings:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedSanitizers:DEFAULT_SANITIZERS,allowLiteralStrings:true}],create(context,[options={}]){const{allowInTests=false,trustedSanitizers=DEFAULT_SANITIZERS,allowLiteralStrings=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;const dangerousProperties=new Set(["innerHTML","outerHTML"]);const dangerousSinkMethods=new Set(["insertAdjacentHTML","write","writeln"]);function reportSink(reportNode,sinkName,taintedNode){if(allowLiteralStrings&&isLiteralString(taintedNode))return;if(isSanitized(taintedNode,sourceCode,trustedSanitizers))return;let source="dynamic content";if(taintedNode.type==="Identifier"){source=`variable "${taintedNode.name}"`}else if(taintedNode.type==="TemplateLiteral"){source="template literal with expressions"}else if(taintedNode.type==="CallExpression"){source="function call result"}context.report({node:reportNode,messageId:"dangerousInnerHTML",data:{property:sinkName,source},suggest:[{messageId:"useSanitizer",fix:()=>null}]})}return{AssignmentExpression(node){if(node.left.type!=="MemberExpression"){return}const property=node.left.property;if(property.type!=="Identifier"){return}if(!dangerousProperties.has(property.name)){return}reportSink(node,property.name,node.right)},CallExpression(node){if(node.callee.type!=="MemberExpression")return;const property=node.callee.property;if(property.type!=="Identifier")return;if(!dangerousSinkMethods.has(property.name))return;const tainted=node.arguments[node.arguments.length-1];if(!tainted)return;reportSink(node,property.name,tainted)}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DEFAULT_SANITIZERS=["DOMPurify.sanitize","sanitize","sanitizeHtml","xss","purify"];function isSanitized(node,sourceCode,sanitizers){const text=sourceCode.getText(node);return sanitizers.some(s=>text.includes(s))}function isLiteralString(node){if(node.type==="Literal"&&typeof node.value==="string"){return true}if(node.type==="TemplateLiteral"&&node.expressions.length===0){return true}return false}exports.noInnerhtml=(0,eslint_devkit_2.createRule)({name:"no-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-innerhtml.md",description:"Disallow dangerous innerHTML/outerHTML assignments that can lead to XSS",cwe:"CWE-79",cvss:6.1,confidence:"medium"},hasSuggestions:true,messages:{dangerousInnerHTML:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Cross-Site Scripting (XSS) via innerHTML",cwe:"CWE-79",description:"Assigning to {{property}} with {{source}} can execute malicious scripts. This is a critical XSS vulnerability.",severity:"CRITICAL",fix:"Use textContent for text, or sanitize with DOMPurify.sanitize() before assignment.",documentationLink:"https://owasp.org/www-community/attacks/xss/"}),useSanitizer:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use HTML Sanitizer",description:"Sanitize HTML before assignment",severity:"LOW",fix:"element.innerHTML = DOMPurify.sanitize(userInput);",documentationLink:"https://www.npmjs.com/package/dompurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedSanitizers:{type:"array",items:{type:"string"},default:DEFAULT_SANITIZERS},allowLiteralStrings:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedSanitizers:DEFAULT_SANITIZERS,allowLiteralStrings:true}],create(context,[options={}]){const{allowInTests=false,trustedSanitizers=DEFAULT_SANITIZERS,allowLiteralStrings=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;const dangerousProperties=new Set(["innerHTML","outerHTML"]);const dangerousSinkMethods=new Set(["insertAdjacentHTML","write","writeln"]);function reportSink(reportNode,sinkName,taintedNode){if(payloadSource(taintedNode)!==void 0)return;if(allowLiteralStrings&&isLiteralString(taintedNode))return;if(isSanitized(taintedNode,sourceCode,trustedSanitizers))return;let source="dynamic content";if(taintedNode.type==="Identifier"){source=`variable "${taintedNode.name}"`}else if(taintedNode.type==="TemplateLiteral"){source="template literal with expressions"}else if(taintedNode.type==="CallExpression"){source="function call result"}context.report({node:reportNode,messageId:"dangerousInnerHTML",data:{property:sinkName,source},suggest:[{messageId:"useSanitizer",fix:()=>null}]})}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type!=="MemberExpression"){return}const property=node.left.property;if(property.type!=="Identifier"){return}if(!dangerousProperties.has(property.name)){return}reportSink(node,property.name,node.right)},CallExpression(node){if(node.callee.type!=="MemberExpression")return;const property=node.callee.property;if(property.type!=="Identifier")return;if(!dangerousSinkMethods.has(property.name))return;const tainted=node.arguments[node.arguments.length-1];if(!tainted)return;reportSink(node,property.name,tainted)}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPostmessageInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noPostmessageInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-postmessage-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-postmessage-innerhtml.md",description:"Disallow using innerHTML or similar methods with postMessage data",cwe:"CWE-79",cvss:8.8},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via postMessage",cwe:"CWE-79",owasp:"A03:2021",cvss:8.8,description:"Using {{method}} with postMessage data allows XSS attacks. Any window can send malicious HTML that will be executed.",severity:"HIGH",fix:"Use textContent for plain text, or sanitize with DOMPurify before using innerHTML.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#security_concerns"}),useTextContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Safe DOM Methods",description:"Use textContent or sanitize input with DOMPurify",severity:"LOW",fix:"element.textContent = event.data; // For plain text\nelement.innerHTML = DOMPurify.sanitize(event.data); // For HTML",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}let inMessageHandler=false;let eventParamName=null;function checkMessageHandler(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventTypeArg=node.arguments[0];if(eventTypeArg.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventTypeArg.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isMessageHandler:true,eventParam:firstParam.name}}}}}return{isMessageHandler:false,eventParam:null}}function referencesEventData(node,eventName){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.name===eventName&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="data"){return true}return referencesEventData(node.object,eventName)}if(node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.name===eventName){return true}return false}return{CallExpression(node){const{isMessageHandler,eventParam}=checkMessageHandler(node);if(isMessageHandler){inMessageHandler=true;eventParamName=eventParam}if(!inMessageHandler||!eventParamName)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(referencesEventData(arg,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isMessageHandler}=checkMessageHandler(node);if(isMessageHandler){inMessageHandler=false;eventParamName=null}},AssignmentExpression(node){if(!inMessageHandler||!eventParamName)return;if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(referencesEventData(node.right,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]})}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noPostmessageInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noPostmessageInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-postmessage-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-postmessage-innerhtml.md",description:"Disallow using innerHTML or similar methods with postMessage data",cwe:"CWE-79",cvss:8.8},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via postMessage",cwe:"CWE-79",owasp:"A03:2021",cvss:8.8,description:"Using {{method}} with postMessage data allows XSS attacks. Any window can send malicious HTML that will be executed.",severity:"HIGH",fix:"Use textContent for plain text, or sanitize with DOMPurify before using innerHTML.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#security_concerns"}),useTextContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Safe DOM Methods",description:"Use textContent or sanitize input with DOMPurify",severity:"LOW",fix:"element.textContent = event.data; // For plain text\nelement.innerHTML = DOMPurify.sanitize(event.data); // For HTML",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(payloadSource(arg)==="postmessage"){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]});break}}}},AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(payloadSource(node.right)==="postmessage"){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]})}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnencryptedTransmission=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DEFAULT_INSECURE_PROTOCOLS=["http://","ws://","ftp://","tcp://","mongodb://","redis://","mysql://"];const SECURE_ALTERNATIVES={"http://":"https://","ws://":"wss://","ftp://":"ftps://","tcp://":"tls://","mongodb://":"mongodb+srv://","redis://":"rediss://","mysql://":"mysqls://"};function containsInsecureProtocol(value,insecureProtocols,secureAlternatives){const lowerValue=value.toLowerCase();for(const protocol of insecureProtocols){const lowerProtocol=protocol.toLowerCase();if(lowerValue.includes(lowerProtocol)){const secureAlternative=secureAlternatives[lowerProtocol];if(secureAlternative){if(!lowerValue.includes(secureAlternative.toLowerCase())){return{isInsecure:true,protocol}}}else{return{isInsecure:true,protocol}}}}return{isInsecure:false,protocol:""}}function matchesIgnorePattern(text,patterns){return patterns.some(pattern=>{try{const regex=new RegExp(pattern,"i");return regex.test(text)}catch{return false}})}exports.noUnencryptedTransmission=(0,eslint_devkit_2.createRule)({name:"no-unencrypted-transmission",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unencrypted-transmission.md",description:"Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols)",cwe:"CWE-319",cvss:7.5},hasSuggestions:true,messages:{unencryptedTransmission:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Unencrypted Transmission",cwe:"CWE-319",description:"Unencrypted transmission detected: {{issue}}",severity:"HIGH",fix:"{{safeAlternative}}",documentationLink:"https://cwe.mitre.org/data/definitions/319.html"}),useHttps:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use HTTPS",description:"Use secure protocol",severity:"LOW",fix:"Replace http:// with https://",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/Security/Transport_Layer_Security"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false,description:"Allow unencrypted transmission in test files"},insecureProtocols:{type:"array",items:{type:"string"},default:[],description:"Insecure protocol patterns to detect"},secureAlternatives:{type:"object",additionalProperties:{type:"string"},default:{},description:"Mapping of insecure protocols to their secure alternatives"},ignorePatterns:{type:"array",items:{type:"string"},default:[],description:"Additional safe patterns to ignore"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,insecureProtocols:[],secureAlternatives:{},ignorePatterns:[]}],create(context,[options={}]){const{allowInTests=false,insecureProtocols,secureAlternatives,ignorePatterns=[]}=options;const protocolsToCheck=insecureProtocols&&insecureProtocols.length>0?insecureProtocols:DEFAULT_INSECURE_PROTOCOLS;const secureAlternativesToUse=secureAlternatives&&Object.keys(secureAlternatives).length>0?{...SECURE_ALTERNATIVES,...secureAlternatives}:SECURE_ALTERNATIVES;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);const sourceCode=context.sourceCode;function checkLiteral(node){if(typeof node.value!=="string"){return}const value=node.value;const text=sourceCode.getText(node);if(matchesIgnorePattern(text,ignorePatterns)){return}if(isTestFile){if(text.includes("localhost")){return}}const{isInsecure,protocol}=containsInsecureProtocol(value,protocolsToCheck,secureAlternativesToUse);if(isInsecure){const secureProtocol=secureAlternativesToUse[protocol.toLowerCase()]||"secure protocol";const safeAlternative=`Use ${secureProtocol} instead of ${protocol}`;context.report({node,messageId:"unencryptedTransmission",data:{issue:`using insecure protocol ${protocol}`,safeAlternative},suggest:[{messageId:"useHttps",data:{protocol,secureProtocol},fix(fixer){if(secureProtocol&&secureProtocol!=="secure protocol"){const newValue=value.replace(new RegExp(protocol.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),secureProtocol);return fixer.replaceText(node,JSON.stringify(newValue))}return null}}]})}}function checkTemplateLiteral(node){if(isTestFile){return}const text=sourceCode.getText(node);if(matchesIgnorePattern(text,ignorePatterns)){return}for(const quasi of node.quasis){const value=quasi.value.raw;const{isInsecure,protocol}=containsInsecureProtocol(value,protocolsToCheck,secureAlternativesToUse);if(isInsecure){const secureProtocol=secureAlternativesToUse[protocol.toLowerCase()]||"secure protocol";const safeAlternative=`Use ${secureProtocol} instead of ${protocol}`;context.report({node:quasi,messageId:"unencryptedTransmission",data:{issue:`using insecure protocol ${protocol} in template literal`,safeAlternative}})}}}return{Literal:checkLiteral,TemplateLiteral:checkTemplateLiteral}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnencryptedTransmission=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DEFAULT_INSECURE_PROTOCOLS=["http://","ws://","ftp://","tcp://","mongodb://","redis://","mysql://"];const SECURE_ALTERNATIVES={"http://":"https://","ws://":"wss://","ftp://":"ftps://","tcp://":"tls://","mongodb://":"mongodb+srv://","redis://":"rediss://","mysql://":"mysqls://"};function containsInsecureProtocol(value,insecureProtocols,secureAlternatives){const lowerValue=value.toLowerCase();for(const protocol of insecureProtocols){const lowerProtocol=protocol.toLowerCase();if(lowerValue.includes(lowerProtocol)){const secureAlternative=secureAlternatives[lowerProtocol];if(secureAlternative){if(!lowerValue.includes(secureAlternative.toLowerCase())){return{isInsecure:true,protocol}}}else{return{isInsecure:true,protocol}}}}return{isInsecure:false,protocol:""}}function matchesIgnorePattern(text,patterns){return patterns.some(pattern=>{try{const regex=new RegExp(pattern,"i");return regex.test(text)}catch{return false}})}const NAMESPACE_URI_PREFIXES=["http://www.w3.org/","http://schemas.xmlsoap.org/","http://purl.org/","http://xmlns.com/","http://ns.adobe.com/","http://sodipodi.sourceforge.net/","http://www.inkscape.org/"];function isNamespaceUri(value){return NAMESPACE_URI_PREFIXES.some(prefix=>value.startsWith(prefix))}const WRITES_SECOND_ARGUMENT=new Set(["replace","replaceAll"]);const INSPECTION_METHODS=new Set(["startsWith","endsWith","includes","indexOf","lastIndexOf","search","match","matchAll","test","split","replace","replaceAll"]);function isProtocolInspection(node,parent){if(parent.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&parent.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&parent.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&INSPECTION_METHODS.has(parent.callee.property.name)){if(WRITES_SECOND_ARGUMENT.has(parent.callee.property.name)){return parent.arguments[0]===node}return true}return parent.type===eslint_devkit_1.AST_NODE_TYPES.BinaryExpression&&COMPARISON_OPERATORS.has(parent.operator)}const COMPARISON_OPERATORS=new Set(["===","!==","==","!="]);exports.noUnencryptedTransmission=(0,eslint_devkit_2.createRule)({name:"no-unencrypted-transmission",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unencrypted-transmission.md",description:"Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols)",cwe:"CWE-319",cvss:7.5},hasSuggestions:true,messages:{unencryptedTransmission:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Unencrypted Transmission",cwe:"CWE-319",description:"Unencrypted transmission detected: {{issue}}",severity:"HIGH",fix:"{{safeAlternative}}",documentationLink:"https://cwe.mitre.org/data/definitions/319.html"}),useHttps:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use HTTPS",description:"Use secure protocol",severity:"LOW",fix:"Replace http:// with https://",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/Security/Transport_Layer_Security"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false,description:"Allow unencrypted transmission in test files"},insecureProtocols:{type:"array",items:{type:"string"},default:[],description:"Insecure protocol patterns to detect"},secureAlternatives:{type:"object",additionalProperties:{type:"string"},default:{},description:"Mapping of insecure protocols to their secure alternatives"},ignorePatterns:{type:"array",items:{type:"string"},default:[],description:"Additional safe patterns to ignore"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,insecureProtocols:[],secureAlternatives:{},ignorePatterns:[]}],create(context,[options={}]){const{allowInTests=false,insecureProtocols,secureAlternatives,ignorePatterns=[]}=options;const protocolsToCheck=insecureProtocols&&insecureProtocols.length>0?insecureProtocols:DEFAULT_INSECURE_PROTOCOLS;const secureAlternativesToUse=secureAlternatives&&Object.keys(secureAlternatives).length>0?{...SECURE_ALTERNATIVES,...secureAlternatives}:SECURE_ALTERNATIVES;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);const sourceCode=context.sourceCode;function checkLiteral(node){if(typeof node.value!=="string"){return}const value=node.value;const text=sourceCode.getText(node);if(isProtocolInspection(node,node.parent)){return}if(isNamespaceUri(value)){return}if(matchesIgnorePattern(text,ignorePatterns)){return}if(isTestFile){if(text.includes("localhost")){return}}const{isInsecure,protocol}=containsInsecureProtocol(value,protocolsToCheck,secureAlternativesToUse);if(isInsecure){const secureProtocol=secureAlternativesToUse[protocol.toLowerCase()]||"secure protocol";const safeAlternative=`Use ${secureProtocol} instead of ${protocol}`;context.report({node,messageId:"unencryptedTransmission",data:{issue:`using insecure protocol ${protocol}`,safeAlternative},suggest:[{messageId:"useHttps",data:{protocol,secureProtocol},fix(fixer){if(secureProtocol&&secureProtocol!=="secure protocol"){const newValue=value.replace(new RegExp(protocol.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),secureProtocol);return fixer.replaceText(node,JSON.stringify(newValue))}return null}}]})}}function checkTemplateLiteral(node){if(isTestFile){return}const text=sourceCode.getText(node);if(matchesIgnorePattern(text,ignorePatterns)){return}for(const quasi of node.quasis){const value=quasi.value.raw;const{isInsecure,protocol}=containsInsecureProtocol(value,protocolsToCheck,secureAlternativesToUse);if(isInsecure){const secureProtocol=secureAlternativesToUse[protocol.toLowerCase()]||"secure protocol";const safeAlternative=`Use ${secureProtocol} instead of ${protocol}`;context.report({node:quasi,messageId:"unencryptedTransmission",data:{issue:`using insecure protocol ${protocol} in template literal`,safeAlternative}})}}}return{Literal:checkLiteral,TemplateLiteral:checkTemplateLiteral}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWebsocketEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const EVAL_FUNCTIONS=new Set(["eval","Function"]);exports.noWebsocketEval=(0,eslint_devkit_1.createRule)({name:"no-websocket-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-websocket-eval.md",description:"Disallow using eval() or Function() with WebSocket message data",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{evalWithWsData:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Remote Code Execution via WebSocket",cwe:"CWE-95",owasp:"A03:2021",cvss:9.8,description:"Using {{method}} with WebSocket data enables remote code execution. A compromised server or MITM attacker can execute arbitrary JavaScript.",severity:"CRITICAL",fix:"Parse WebSocket data as JSON and validate the structure instead of executing it.",documentationLink:"https://cwe.mitre.org/data/definitions/95.html"}),parseDataSafely:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Parse Data Safely",description:"Use JSON.parse() and validate the data structure",severity:"LOW",fix:'const data = JSON.parse(event.data); if (data.action === "update") { handleUpdate(data); }',documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}let inWsHandler=false;let eventParamName=null;function isWsOnmessageAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.property.name==="onmessage"){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}return{isHandler:false,eventParam:null}}function isWsAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function referencesEventData(node,eventName){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.name===eventName&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="data"){return true}return referencesEventData(node.object,eventName)}if(node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.name===eventName){return true}return false}function isEvalCall(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&EVAL_FUNCTIONS.has(node.callee.name)){return node.callee.name}return null}return{AssignmentExpression(node){const{isHandler,eventParam}=isWsOnmessageAssignment(node);if(isHandler){inWsHandler=true;eventParamName=eventParam}},"AssignmentExpression:exit"(node){const{isHandler}=isWsOnmessageAssignment(node);if(isHandler){inWsHandler=false;eventParamName=null}},CallExpression(node){const{isHandler,eventParam}=isWsAddEventListener(node);if(isHandler){inWsHandler=true;eventParamName=eventParam}if(!inWsHandler||!eventParamName)return;const evalFn=isEvalCall(node);if(evalFn){for(const arg of node.arguments){if(referencesEventData(arg,eventParamName)){context.report({node,messageId:"evalWithWsData",data:{method:evalFn},suggest:[{messageId:"parseDataSafely",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWsAddEventListener(node);if(isHandler){inWsHandler=false;eventParamName=null}},NewExpression(node){if(!inWsHandler||!eventParamName)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.name==="Function"){for(const arg of node.arguments){if(referencesEventData(arg,eventParamName)){context.report({node,messageId:"evalWithWsData",data:{method:"new Function"},suggest:[{messageId:"parseDataSafely",fix:()=>null}]});break}}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWebsocketEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const EVAL_FUNCTIONS=new Set(["eval","Function"]);exports.noWebsocketEval=(0,eslint_devkit_1.createRule)({name:"no-websocket-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-websocket-eval.md",description:"Disallow using eval() or Function() with WebSocket message data",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{evalWithWsData:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Remote Code Execution via WebSocket",cwe:"CWE-95",owasp:"A03:2021",cvss:9.8,description:"Using {{method}} with WebSocket data enables remote code execution. A compromised server or MITM attacker can execute arbitrary JavaScript.",severity:"CRITICAL",fix:"Parse WebSocket data as JSON and validate the structure instead of executing it.",documentationLink:"https://cwe.mitre.org/data/definitions/95.html"}),parseDataSafely:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Parse Data Safely",description:"Use JSON.parse() and validate the data structure",severity:"LOW",fix:'const data = JSON.parse(event.data); if (data.action === "update") { handleUpdate(data); }',documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}function isWsAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function isEvalCall(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&EVAL_FUNCTIONS.has(node.callee.name)){return node.callee.name}return null}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{CallExpression(node){const evalFn=isEvalCall(node);if(evalFn){for(const arg of node.arguments){if(payloadSource(arg)==="websocket"){context.report({node,messageId:"evalWithWsData",data:{method:evalFn},suggest:[{messageId:"parseDataSafely",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWsAddEventListener(node);if(isHandler){}},NewExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.name==="Function"){for(const arg of node.arguments){if(payloadSource(arg)==="websocket"){context.report({node,messageId:"evalWithWsData",data:{method:"new Function"},suggest:[{messageId:"parseDataSafely",fix:()=>null}]});break}}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWebsocketInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noWebsocketInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-websocket-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-websocket-innerhtml.md",description:"Disallow using innerHTML or similar methods with WebSocket message data",cwe:"CWE-79",cvss:8.1},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via WebSocket",cwe:"CWE-79",owasp:"A03:2021",cvss:8.1,description:"Using {{method}} with WebSocket data enables XSS attacks. Malicious server or MITM can send crafted HTML to execute scripts.",severity:"HIGH",fix:"Use textContent for plain text, or sanitize with DOMPurify before using innerHTML.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/WebSocket"}),useTextContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Safe DOM Methods",description:"Use textContent or sanitize input with DOMPurify",severity:"LOW",fix:"element.textContent = event.data; // For plain text\nelement.innerHTML = DOMPurify.sanitize(event.data); // For HTML",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}let inWsHandler=false;let eventParamName=null;function isWsOnmessageAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.property.name==="onmessage"){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}return{isHandler:false,eventParam:null}}function isWsAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function referencesEventData(node,eventName){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.name===eventName&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="data"){return true}return referencesEventData(node.object,eventName)}return false}return{AssignmentExpression(node){const{isHandler,eventParam}=isWsOnmessageAssignment(node);if(isHandler){inWsHandler=true;eventParamName=eventParam}if(!inWsHandler||!eventParamName)return;if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(referencesEventData(node.right,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isWsOnmessageAssignment(node);if(isHandler){inWsHandler=false;eventParamName=null}},CallExpression(node){const{isHandler,eventParam}=isWsAddEventListener(node);if(isHandler){inWsHandler=true;eventParamName=eventParam}if(!inWsHandler||!eventParamName)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(referencesEventData(arg,eventParamName)){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWsAddEventListener(node);if(isHandler){inWsHandler=false;eventParamName=null}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWebsocketInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noWebsocketInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-websocket-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-websocket-innerhtml.md",description:"Disallow using innerHTML or similar methods with WebSocket message data",cwe:"CWE-79",cvss:8.1},hasSuggestions:true,messages:{unsafeInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via WebSocket",cwe:"CWE-79",owasp:"A03:2021",cvss:8.1,description:"Using {{method}} with WebSocket data enables XSS attacks. Malicious server or MITM can send crafted HTML to execute scripts.",severity:"HIGH",fix:"Use textContent for plain text, or sanitize with DOMPurify before using innerHTML.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/WebSocket"}),useTextContent:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Safe DOM Methods",description:"Use textContent or sanitize input with DOMPurify",severity:"LOW",fix:"element.textContent = event.data; // For plain text\nelement.innerHTML = DOMPurify.sanitize(event.data); // For HTML",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}function isWsOnmessageAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.property.name==="onmessage"){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}return{isHandler:false,eventParam:null}}function isWsAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(payloadSource(node.right)==="websocket"){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isWsOnmessageAssignment(node);if(isHandler){}},CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(payloadSource(arg)==="websocket"){context.report({node,messageId:"unsafeInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"useTextContent",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWsAddEventListener(node);if(isHandler){}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWorkerMessageInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noWorkerMessageInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-worker-message-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-worker-message-innerhtml.md",description:"Disallow using innerHTML with Web Worker message data",cwe:"CWE-79",cvss:7.5},hasSuggestions:true,messages:{workerInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via Worker Message",cwe:"CWE-79",owasp:"A03:2021",cvss:7.5,description:"Using {{method}} with Worker message data can enable XSS if the worker processes untrusted input.",severity:"HIGH",fix:"Sanitize worker data with DOMPurify before rendering, or use textContent.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Worker/message_event"}),sanitizeWorkerData:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Sanitize Worker Data",description:"Use textContent or sanitize with DOMPurify",severity:"LOW",fix:"const sanitized = DOMPurify.sanitize(event.data);\nelement.innerHTML = sanitized;",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}let inWorkerHandler=false;let eventParamName=null;function isWorkerOnmessageAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.property.name==="onmessage"){const objName=node.left.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?node.left.object.name.toLowerCase():"";if(objName.includes("worker")||objName==="w"||objName==="wk"){const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function isWorkerAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const obj=node.callee.object;if(obj.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){const objName=obj.name.toLowerCase();if(objName.includes("worker")||objName==="w"||objName==="wk"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}}}return{isHandler:false,eventParam:null}}function referencesEventData(node,eventName){if(node.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){if(node.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.object.name===eventName&&node.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.property.name==="data"){return true}return referencesEventData(node.object,eventName)}return false}return{AssignmentExpression(node){const{isHandler,eventParam}=isWorkerOnmessageAssignment(node);if(isHandler){inWorkerHandler=true;eventParamName=eventParam}if(!inWorkerHandler||!eventParamName)return;if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(referencesEventData(node.right,eventParamName)){context.report({node,messageId:"workerInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"sanitizeWorkerData",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isWorkerOnmessageAssignment(node);if(isHandler){inWorkerHandler=false;eventParamName=null}},CallExpression(node){const{isHandler,eventParam}=isWorkerAddEventListener(node);if(isHandler){inWorkerHandler=true;eventParamName=eventParam}if(!inWorkerHandler||!eventParamName)return;if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(referencesEventData(arg,eventParamName)){context.report({node,messageId:"workerInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"sanitizeWorkerData",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWorkerAddEventListener(node);if(isHandler){inWorkerHandler=false;eventParamName=null}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noWorkerMessageInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DANGEROUS_PROPERTIES=new Set(["innerHTML","outerHTML"]);const DANGEROUS_METHODS=new Set(["insertAdjacentHTML","write","writeln"]);exports.noWorkerMessageInnerhtml=(0,eslint_devkit_1.createRule)({name:"no-worker-message-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-worker-message-innerhtml.md",description:"Disallow using innerHTML with Web Worker message data",cwe:"CWE-79",cvss:7.5},hasSuggestions:true,messages:{workerInnerhtml:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"XSS via Worker Message",cwe:"CWE-79",owasp:"A03:2021",cvss:7.5,description:"Using {{method}} with Worker message data can enable XSS if the worker processes untrusted input.",severity:"HIGH",fix:"Sanitize worker data with DOMPurify before rendering, or use textContent.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Worker/message_event"}),sanitizeWorkerData:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Sanitize Worker Data",description:"Use textContent or sanitize with DOMPurify",severity:"LOW",fix:"const sanitized = DOMPurify.sanitize(event.data);\nelement.innerHTML = sanitized;",documentationLink:"https://github.com/cure53/DOMPurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}function isWorkerOnmessageAssignment(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.left.property.name==="onmessage"){{const handler=node.right;if(handler.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||handler.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=handler.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}function isWorkerAddEventListener(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.property.name==="addEventListener"&&node.arguments.length>=2){const eventType=node.arguments[0];if(eventType.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&eventType.value==="message"){const callback=node.arguments[1];if(callback.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||callback.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){const firstParam=callback.params[0];if(firstParam&&firstParam.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return{isHandler:true,eventParam:firstParam.name}}}}}return{isHandler:false,eventParam:null}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_PROPERTIES.has(node.left.property.name)){if(payloadSource(node.right)==="worker"){context.report({node,messageId:"workerInnerhtml",data:{method:node.left.property.name},suggest:[{messageId:"sanitizeWorkerData",fix:()=>null}]})}}},"AssignmentExpression:exit"(node){const{isHandler}=isWorkerOnmessageAssignment(node);if(isHandler){}},CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&node.callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&DANGEROUS_METHODS.has(node.callee.property.name)){for(const arg of node.arguments){if(payloadSource(arg)==="worker"){context.report({node,messageId:"workerInnerhtml",data:{method:node.callee.property.name},suggest:[{messageId:"sanitizeWorkerData",fix:()=>null}]});break}}}},"CallExpression:exit"(node){const{isHandler}=isWorkerAddEventListener(node);if(isHandler){}}}}});