eslint-plugin-browser-security 2.1.1 → 2.1.3

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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +1 -1
  3. package/src/rules/detect-mixed-content/index.js +1 -1
  4. package/src/rules/no-clickjacking/index.js +1 -1
  5. package/src/rules/no-client-side-auth-logic/index.js +1 -1
  6. package/src/rules/no-disabled-certificate-validation/index.js +1 -1
  7. package/src/rules/no-dynamic-service-worker-url/index.js +1 -1
  8. package/src/rules/no-filereader-innerhtml/index.js +1 -1
  9. package/src/rules/no-http-urls/index.js +1 -1
  10. package/src/rules/no-incomplete-url-sanitization/index.js +1 -1
  11. package/src/rules/no-insecure-redirects/index.js +1 -1
  12. package/src/rules/no-missing-cors-check/index.js +1 -1
  13. package/src/rules/no-missing-csrf-protection/index.js +1 -1
  14. package/src/rules/no-missing-security-headers/index.js +1 -1
  15. package/src/rules/no-password-in-url/index.js +1 -1
  16. package/src/rules/no-permissive-cors/index.js +1 -1
  17. package/src/rules/no-postmessage-innerhtml/index.js +1 -1
  18. package/src/rules/no-postmessage-wildcard-origin/index.js +1 -1
  19. package/src/rules/no-unencrypted-transmission/index.js +1 -1
  20. package/src/rules/no-unescaped-url-parameter/index.js +1 -1
  21. package/src/rules/no-unescaped-url-parameter/untrusted-text.js +1 -1
  22. package/src/rules/no-unvalidated-deeplinks/index.js +1 -1
  23. package/src/rules/no-websocket-innerhtml/index.js +1 -1
  24. package/src/rules/no-worker-message-innerhtml/index.js +1 -1
  25. package/src/rules/require-blob-url-revocation/index.js +1 -1
  26. package/src/rules/require-csp-headers/index.js +1 -1
  27. package/src/rules/require-mime-type-validation/index.js +1 -1
  28. package/src/rules/require-postmessage-origin-check/index.js +1 -1
  29. package/src/rules/require-url-validation/index.js +1 -1
  30. package/src/utils/analytics-sinks.js +1 -1
  31. package/src/utils/dynamic-code-sinks.js +1 -1
  32. package/src/utils/express-app.js +1 -1
  33. package/src/utils/global-object.js +1 -1
  34. package/src/utils/navigation-targets.js +1 -1
  35. package/src/utils/protocol-inspection.js +1 -1
  36. package/src/utils/sensitive-value-evidence.js +1 -1
  37. package/src/utils/transport-ownership.js +1 -1
  38. package/src/utils/url-taint.js +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.STEERABILITY_PRESERVING_FUNCTIONS=exports.STEERABILITY_PRESERVING_METHODS=void 0;exports.isLocationObject=isLocationObject;exports.resolveBoundInitializer=resolveBoundInitializer;exports.isAttackerSteerableUrl=isAttackerSteerableUrl;const resolve_binding_1=require("./resolve-binding");const STEERABLE_LOCATION_PROPS=new Set(["href","search","hash","pathname"]);const LOCATION_HOLDERS=new Set(["window","document","self","top","parent","globalThis"]);const REQUEST_INPUT_PROPS=new Set(["query","body","params"]);function isLocationObject(node){if(node.type==="Identifier"){return node.name==="location"}return node.type==="MemberExpression"&&!node.computed&&node.property.type==="Identifier"&&node.property.name==="location"&&node.object.type==="Identifier"&&LOCATION_HOLDERS.has(node.object.name)}function isRequestInput(node){let current=node;let sawInputProp=false;while(current.type==="MemberExpression"){const property=staticProperty(current);if(property!==null&&REQUEST_INPUT_PROPS.has(property)){sawInputProp=true}current=current.object}return sawInputProp&&current.type==="Identifier"&&(current.name==="req"||current.name==="request")}exports.STEERABILITY_PRESERVING_METHODS=new Set(["slice","substring","substr","trim","trimStart","trimEnd","toString","toLowerCase","toUpperCase","normalize","valueOf"]);exports.STEERABILITY_PRESERVING_FUNCTIONS=new Set(["decodeURI","decodeURIComponent","unescape","String"]);function staticProperty(node){if(!node.computed){return node.property.type==="Identifier"?node.property.name:null}return node.property.type==="Literal"&&typeof node.property.value==="string"?node.property.value:null}function resolveBoundInitializer(identifier,sourceCode){const init=(0,resolve_binding_1.resolveInitializer)(identifier,sourceCode);if(init===void 0)return void 0;const declarator=init.parent;if(declarator?.type==="VariableDeclarator"&&declarator.id.type!=="Identifier"){return void 0}return init}function isSteerableMember(node){const property=staticProperty(node);if(property===null){return isRequestInput(node)}if(STEERABLE_LOCATION_PROPS.has(property)&&isLocationObject(node.object)){return true}if((property==="URL"||property==="referrer")&&node.object.type==="Identifier"&&node.object.name==="document"){return true}return isRequestInput(node)}const URL_CONSTRUCTORS=new Set(["URL"]);const PARAMS_CONSTRUCTORS=new Set(["URLSearchParams"]);const PARAMS_READERS=new Set(["get","getAll"]);const URL_STRINGIFIERS=new Set(["toString","toJSON","valueOf"]);function isUnshadowedGlobal(node,names,sourceCode){if(node.type!=="Identifier"||!names.has(node.name))return false;for(let scope=sourceCode.getScope(node);scope!==null;scope=scope.upper){const variable=scope.variables.find(v=>v.name===node.name);if(variable!==void 0)return variable.defs.length===0}return true}function urlContainerKind(node,sourceCode,seen){switch(node.type){case"NewExpression":{const[argument]=node.arguments;if(argument===void 0||argument.type==="SpreadElement"){return null}if(!isAttackerSteerableUrl(argument,sourceCode,seen))return null;if(isUnshadowedGlobal(node.callee,PARAMS_CONSTRUCTORS,sourceCode)){return"params"}if(isUnshadowedGlobal(node.callee,URL_CONSTRUCTORS,sourceCode)){return"url"}return null}case"MemberExpression":{if(staticProperty(node)!=="searchParams"){return null}return urlContainerKind(node.object,sourceCode,seen)==="url"?"params":null}case"Identifier":{if(seen.has(node.name))return null;seen.add(node.name);const init=resolveBoundInitializer(node,sourceCode);return init===void 0?null:urlContainerKind(init,sourceCode,seen)}default:return null}}function isUrlContainerRead(node,sourceCode,seen){const probe=new Set(seen);if(node.type==="CallExpression"){const callee=node.callee;if(callee.type!=="MemberExpression")return false;const reader=staticProperty(callee);if(reader===null)return false;const kind=urlContainerKind(callee.object,sourceCode,probe);if(kind==="params")return PARAMS_READERS.has(reader);return kind==="url"&&URL_STRINGIFIERS.has(reader)}const property=staticProperty(node);return property!==null&&STEERABLE_LOCATION_PROPS.has(property)&&urlContainerKind(node.object,sourceCode,probe)==="url"}function isAttackerSteerableUrl(node,sourceCode,seen=new Set){switch(node.type){case"MemberExpression":return isSteerableMember(node)||isUrlContainerRead(node,sourceCode,seen);case"Identifier":{if(seen.has(node.name))return false;seen.add(node.name);const init=resolveBoundInitializer(node,sourceCode);return init!==void 0&&isAttackerSteerableUrl(init,sourceCode,seen)}case"BinaryExpression":return node.operator==="+"&&isAttackerSteerableUrl(node.left,sourceCode,seen);case"TemplateLiteral":return node.quasis[0].value.cooked===""&&node.expressions.length>0&&isAttackerSteerableUrl(node.expressions[0],sourceCode,seen);case"CallExpression":{if(isUrlContainerRead(node,sourceCode,seen))return true;const callee=node.callee;if(callee.type==="MemberExpression"&&!callee.computed&&callee.property.type==="Identifier"&&exports.STEERABILITY_PRESERVING_METHODS.has(callee.property.name)){return isAttackerSteerableUrl(callee.object,sourceCode,seen)}if(callee.type==="Identifier"&&exports.STEERABILITY_PRESERVING_FUNCTIONS.has(callee.name)&&node.arguments.length>0){return isAttackerSteerableUrl(node.arguments[0],sourceCode,seen)}return false}case"ConditionalExpression":return isAttackerSteerableUrl(node.consequent,sourceCode,seen)||isAttackerSteerableUrl(node.alternate,sourceCode,seen);case"LogicalExpression":return isAttackerSteerableUrl(node.left,sourceCode,seen)||isAttackerSteerableUrl(node.right,sourceCode,seen);default:return false}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.STEERABILITY_PRESERVING_FUNCTIONS=exports.STEERABILITY_PRESERVING_METHODS=void 0;exports.isLocationObject=isLocationObject;exports.resolveBoundInitializer=resolveBoundInitializer;exports.isAttackerSteerableUrl=isAttackerSteerableUrl;const resolve_binding_1=require("./resolve-binding");const STEERABLE_LOCATION_PROPS=new Set(["href","search","hash","pathname"]);const LOCATION_HOLDERS=new Set(["window","document","self","top","parent","globalThis"]);const REQUEST_INPUT_PROPS=new Set(["query","body","params"]);function isLocationObject(node){if(node.type==="Identifier"){return node.name==="location"}return node.type==="MemberExpression"&&!node.computed&&node.property.type==="Identifier"&&node.property.name==="location"&&node.object.type==="Identifier"&&LOCATION_HOLDERS.has(node.object.name)}function isRequestInput(node){let current=node;let sawInputProp=false;while(current.type==="MemberExpression"){const property=staticProperty(current);if(property!==null&&REQUEST_INPUT_PROPS.has(property)){sawInputProp=true}current=current.object}return sawInputProp&&current.type==="Identifier"&&(current.name==="req"||current.name==="request")}exports.STEERABILITY_PRESERVING_METHODS=new Set(["slice","substring","substr","trim","trimStart","trimEnd","toString","toLowerCase","toUpperCase","normalize","valueOf"]);exports.STEERABILITY_PRESERVING_FUNCTIONS=new Set(["decodeURI","decodeURIComponent","unescape","String"]);function staticProperty(node){if(!node.computed){return node.property.type==="Identifier"?node.property.name:null}return node.property.type==="Literal"&&typeof node.property.value==="string"?node.property.value:null}function resolveBoundInitializer(identifier,sourceCode){const init=(0,resolve_binding_1.resolveInitializer)(identifier,sourceCode);if(init===void 0)return void 0;const declarator=init.parent;if(declarator?.type==="VariableDeclarator"&&declarator.id.type!=="Identifier"){return void 0}return init}function isSteerableMember(node){const property=staticProperty(node);if(property===null){return isRequestInput(node)}if(STEERABLE_LOCATION_PROPS.has(property)&&isLocationObject(node.object)){return true}if((property==="URL"||property==="referrer")&&node.object.type==="Identifier"&&node.object.name==="document"){return true}return isRequestInput(node)}const URL_CONSTRUCTORS=new Set(["URL"]);const PARAMS_CONSTRUCTORS=new Set(["URLSearchParams"]);const PARAMS_READERS=new Set(["get","getAll"]);const URL_STRINGIFIERS=new Set(["toString","toJSON","valueOf"]);function isUnshadowedGlobal(node,names,sourceCode){if(node.type!=="Identifier"||!names.has(node.name))return false;for(let scope=sourceCode.getScope(node);scope!==null;scope=scope.upper){const variable=scope.variables.find(v=>v.name===node.name);if(variable!==void 0)return variable.defs.length===0}return true}function urlContainerKind(node,sourceCode,seen){switch(node.type){case"NewExpression":{const[argument]=node.arguments;if(argument===void 0||argument.type==="SpreadElement"){return null}if(!isAttackerSteerableUrl(argument,sourceCode,seen))return null;if(isUnshadowedGlobal(node.callee,PARAMS_CONSTRUCTORS,sourceCode)){return"params"}if(isUnshadowedGlobal(node.callee,URL_CONSTRUCTORS,sourceCode)){return"url"}return null}case"MemberExpression":{if(staticProperty(node)!=="searchParams"){return null}return urlContainerKind(node.object,sourceCode,seen)==="url"?"params":null}case"Identifier":{if(seen.has(node.name))return null;seen.add(node.name);const init=resolveBoundInitializer(node,sourceCode);return init===void 0?null:urlContainerKind(init,sourceCode,seen)}default:return null}}function isUrlContainerRead(node,sourceCode,seen){const probe=new Set(seen);if(node.type==="CallExpression"){const callee=node.callee;if(callee.type!=="MemberExpression")return false;const reader=staticProperty(callee);if(reader===null)return false;const kind=urlContainerKind(callee.object,sourceCode,probe);if(kind==="params")return PARAMS_READERS.has(reader);return kind==="url"&&URL_STRINGIFIERS.has(reader)}const property=staticProperty(node);return property!==null&&STEERABLE_LOCATION_PROPS.has(property)&&urlContainerKind(node.object,sourceCode,probe)==="url"}function isAttackerSteerableUrl(node,sourceCode,seen=new Set){switch(node.type){case"MemberExpression":return isSteerableMember(node)||isUrlContainerRead(node,sourceCode,seen);case"Identifier":{if(seen.has(node.name))return false;seen.add(node.name);const init=resolveBoundInitializer(node,sourceCode);return init!==void 0&&isAttackerSteerableUrl(init,sourceCode,seen)}case"BinaryExpression":return node.operator==="+"&&isAttackerSteerableUrl(node.left,sourceCode,seen);case"TemplateLiteral":return node.quasis[0].value.raw===""&&node.expressions.length>0&&isAttackerSteerableUrl(node.expressions[0],sourceCode,seen);case"CallExpression":{if(isUrlContainerRead(node,sourceCode,seen))return true;const callee=node.callee;if(callee.type==="MemberExpression"&&exports.STEERABILITY_PRESERVING_METHODS.has(staticProperty(callee)??"")){return isAttackerSteerableUrl(callee.object,sourceCode,seen)}if(callee.type==="Identifier"&&exports.STEERABILITY_PRESERVING_FUNCTIONS.has(callee.name)&&node.arguments.length>0){return isAttackerSteerableUrl(node.arguments[0],sourceCode,seen)}return false}case"ConditionalExpression":return isAttackerSteerableUrl(node.consequent,sourceCode,seen)||isAttackerSteerableUrl(node.alternate,sourceCode,seen);case"LogicalExpression":return isAttackerSteerableUrl(node.left,sourceCode,seen)||isAttackerSteerableUrl(node.right,sourceCode,seen);default:return false}}