eslint-plugin-secure-coding 5.1.4 → 5.2.1

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireSecureDefaults=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DEFAULT_INSECURE_WHEN_FALSE=["strictSSL","httpOnly","requireTLS","sslValidate"];const DEFAULT_INSECURE_WHEN_TRUE=["tlsAllowInvalidCertificates","tlsAllowInvalidHostnames","allowInvalidCertificates","ignoreHTTPSErrors"];const CORROBORATION_REQUIRED=new Set(["secure"]);const DEFAULT_COOKIE_ATTRIBUTES=["httpOnly","sameSite","maxAge","expires","domain","path","signed","partitioned","priority"];const COOKIE_CONTAINER_KEYS=new Set(["cookie","cookies"]);const VERIFICATION_CALLBACKS=new Set(["checkServerIdentity"]);const isBenignReturnValue=node=>node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.name==="undefined"||node.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&(node.value===null||node.value===true);const isNoopCallback=node=>{if(node.type!==eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression&&node.type!==eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){return false}if(node.body.type!==eslint_devkit_1.AST_NODE_TYPES.BlockStatement)return isBenignReturnValue(node.body);if(node.body.body.length===0)return true;const[only]=node.body.body;if(node.body.body.length!==1||only?.type!==eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return false;return only.argument===null||isBenignReturnValue(only.argument)};const propertyKey=node=>{if(node.computed)return void 0;if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return node.key.name;if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof node.key.value==="string"){return node.key.value}return void 0};const hasCookieContext=(property,cookieAttributes)=>{const object=property.parent;for(const sibling of object.properties){if(sibling===property)continue;if(sibling.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;const siblingKey=propertyKey(sibling);if(siblingKey!==void 0&&cookieAttributes.has(siblingKey))return true}const owner=object.parent;if(owner.type!==eslint_devkit_1.AST_NODE_TYPES.Property)return false;const ownerKey=propertyKey(owner);return ownerKey!==void 0&&COOKIE_CONTAINER_KEYS.has(ownerKey)};const isLiteral=(node,value)=>node.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&node.value===value;exports.requireSecureDefaults=(0,eslint_devkit_1.createRule)({name:"require-secure-defaults",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-secure-defaults.md",description:"Ensure secure default configurations",cwe:"CWE-1188",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-1188",description:"Ensure secure default configurations detected - Insecure default values",severity:"MEDIUM",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/1188.html"})},schema:[{type:"object",properties:{insecureWhenFalse:{type:"array",items:{type:"string"},default:DEFAULT_INSECURE_WHEN_FALSE,description:"Config keys whose `false` value is the insecure one. Replaces the built-in list; matched as an exact key name, never a substring."},additionalInsecureWhenFalse:{type:"array",items:{type:"string"},default:[],description:"Extra keys where `false` is insecure, on top of `insecureWhenFalse`."},insecureWhenTrue:{type:"array",items:{type:"string"},default:DEFAULT_INSECURE_WHEN_TRUE,description:"Config keys whose `true` value accepts the insecure thing. Replaces the built-in list."},additionalInsecureWhenTrue:{type:"array",items:{type:"string"},default:[],description:"Extra keys where `true` is insecure, on top of `insecureWhenTrue`."},cookieAttributes:{type:"array",items:{type:"string"},default:DEFAULT_COOKIE_ATTRIBUTES,description:"Keys that exist on a cookie and nowhere else. Used only as corroborating structure for `secure: false`. Replaces the built-in list."},additionalCookieAttributes:{type:"array",items:{type:"string"},default:[],description:"Extra cookie attribute names, on top of `cookieAttributes`."}},additionalProperties:false}]},defaultOptions:[{insecureWhenFalse:DEFAULT_INSECURE_WHEN_FALSE,additionalInsecureWhenFalse:[],insecureWhenTrue:DEFAULT_INSECURE_WHEN_TRUE,additionalInsecureWhenTrue:[],cookieAttributes:DEFAULT_COOKIE_ATTRIBUTES,additionalCookieAttributes:[]}],create(context,[options={}]){const{insecureWhenFalse=DEFAULT_INSECURE_WHEN_FALSE,additionalInsecureWhenFalse=[],insecureWhenTrue=DEFAULT_INSECURE_WHEN_TRUE,additionalInsecureWhenTrue=[],cookieAttributes=DEFAULT_COOKIE_ATTRIBUTES,additionalCookieAttributes=[]}=options;const falseIsInsecure=new Set([...insecureWhenFalse,...additionalInsecureWhenFalse]);const trueIsInsecure=new Set([...insecureWhenTrue,...additionalInsecureWhenTrue]);const cookieKeys=new Set([...cookieAttributes,...additionalCookieAttributes]);return{Property(node){const key=propertyKey(node);if(key===void 0)return;const insecure=falseIsInsecure.has(key)&&isLiteral(node.value,false)||trueIsInsecure.has(key)&&isLiteral(node.value,true)||VERIFICATION_CALLBACKS.has(key)&&isNoopCallback(node.value)||CORROBORATION_REQUIRED.has(key)&&isLiteral(node.value,false)&&hasCookieContext(node,cookieKeys);if(insecure){context.report({node,messageId:"violationDetected"})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireSecureDefaults=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DEFAULT_INSECURE_WHEN_FALSE=["strictSSL","httpOnly","requireTLS","sslValidate"];const DEFAULT_INSECURE_WHEN_TRUE=["tlsAllowInvalidCertificates","tlsAllowInvalidHostnames","allowInvalidCertificates","ignoreHTTPSErrors"];const CORROBORATION_REQUIRED=new Set(["secure"]);const DEFAULT_COOKIE_ATTRIBUTES=["httpOnly","sameSite","maxAge","expires","domain","path","signed","partitioned","priority"];const COOKIE_CONTAINER_KEYS=new Set(["cookie","cookies"]);const VERIFICATION_CALLBACKS=new Set(["checkServerIdentity"]);const isBenignReturnValue=node=>node.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.name==="undefined"||node.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&(node.value===null||node.value===true);const isNoopCallback=node=>{if(node.type!==eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression&&node.type!==eslint_devkit_1.AST_NODE_TYPES.FunctionExpression){return false}if(node.body.type!==eslint_devkit_1.AST_NODE_TYPES.BlockStatement)return isBenignReturnValue(node.body);if(node.body.body.length===0)return true;const[only]=node.body.body;if(node.body.body.length!==1||only?.type!==eslint_devkit_1.AST_NODE_TYPES.ReturnStatement)return false;return only.argument===null||isBenignReturnValue(only.argument)};const propertyKey=node=>{if(node.computed)return void 0;if(node.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return node.key.name;const staticText=(0,eslint_devkit_1.staticString)(node.key);if(staticText!==null){return staticText}return void 0};const hasCookieContext=(property,cookieAttributes)=>{const object=property.parent;for(const sibling of object.properties){if(sibling===property)continue;if(sibling.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;const siblingKey=propertyKey(sibling);if(siblingKey!==void 0&&cookieAttributes.has(siblingKey))return true}const owner=object.parent;if(owner.type!==eslint_devkit_1.AST_NODE_TYPES.Property)return false;const ownerKey=propertyKey(owner);return ownerKey!==void 0&&COOKIE_CONTAINER_KEYS.has(ownerKey)};const isLiteral=(node,value)=>node.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&node.value===value;exports.requireSecureDefaults=(0,eslint_devkit_1.createRule)({name:"require-secure-defaults",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-secure-defaults.md",description:"Ensure secure default configurations",cwe:"CWE-1188",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-1188",description:"Ensure secure default configurations detected - Insecure default values",severity:"MEDIUM",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/1188.html"})},schema:[{type:"object",properties:{insecureWhenFalse:{type:"array",items:{type:"string"},default:DEFAULT_INSECURE_WHEN_FALSE,description:"Config keys whose `false` value is the insecure one. Replaces the built-in list; matched as an exact key name, never a substring."},additionalInsecureWhenFalse:{type:"array",items:{type:"string"},default:[],description:"Extra keys where `false` is insecure, on top of `insecureWhenFalse`."},insecureWhenTrue:{type:"array",items:{type:"string"},default:DEFAULT_INSECURE_WHEN_TRUE,description:"Config keys whose `true` value accepts the insecure thing. Replaces the built-in list."},additionalInsecureWhenTrue:{type:"array",items:{type:"string"},default:[],description:"Extra keys where `true` is insecure, on top of `insecureWhenTrue`."},cookieAttributes:{type:"array",items:{type:"string"},default:DEFAULT_COOKIE_ATTRIBUTES,description:"Keys that exist on a cookie and nowhere else. Used only as corroborating structure for `secure: false`. Replaces the built-in list."},additionalCookieAttributes:{type:"array",items:{type:"string"},default:[],description:"Extra cookie attribute names, on top of `cookieAttributes`."}},additionalProperties:false}]},defaultOptions:[{insecureWhenFalse:DEFAULT_INSECURE_WHEN_FALSE,additionalInsecureWhenFalse:[],insecureWhenTrue:DEFAULT_INSECURE_WHEN_TRUE,additionalInsecureWhenTrue:[],cookieAttributes:DEFAULT_COOKIE_ATTRIBUTES,additionalCookieAttributes:[]}],create(context,[options={}]){const{insecureWhenFalse=DEFAULT_INSECURE_WHEN_FALSE,additionalInsecureWhenFalse=[],insecureWhenTrue=DEFAULT_INSECURE_WHEN_TRUE,additionalInsecureWhenTrue=[],cookieAttributes=DEFAULT_COOKIE_ATTRIBUTES,additionalCookieAttributes=[]}=options;const falseIsInsecure=new Set([...insecureWhenFalse,...additionalInsecureWhenFalse]);const trueIsInsecure=new Set([...insecureWhenTrue,...additionalInsecureWhenTrue]);const cookieKeys=new Set([...cookieAttributes,...additionalCookieAttributes]);return{Property(node){const key=propertyKey(node);if(key===void 0)return;const insecure=falseIsInsecure.has(key)&&isLiteral(node.value,false)||trueIsInsecure.has(key)&&isLiteral(node.value,true)||VERIFICATION_CALLBACKS.has(key)&&isNoopCallback(node.value)||CORROBORATION_REQUIRED.has(key)&&isLiteral(node.value,false)&&hasCookieContext(node,cookieKeys);if(insecure){context.report({node,messageId:"violationDetected"})}}}}});