eslint-plugin-node-security 4.8.0 → 4.9.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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/src/index.js +1 -95
  4. package/src/oxlint.js +1 -3
  5. package/src/rules/detect-child-process/index.js +1 -625
  6. package/src/rules/detect-eval-with-expression/index.js +1 -364
  7. package/src/rules/detect-non-literal-fs-filename/index.js +1 -516
  8. package/src/rules/detect-suspicious-dependencies/index.js +1 -69
  9. package/src/rules/lock-file/index.js +1 -92
  10. package/src/rules/no-arbitrary-file-access/index.js +1 -152
  11. package/src/rules/no-buffer-overread/index.js +1 -543
  12. package/src/rules/no-cryptojs/index.js +1 -99
  13. package/src/rules/no-cryptojs-weak-random/index.js +1 -103
  14. package/src/rules/no-data-in-temp-storage/index.js +1 -85
  15. package/src/rules/no-deprecated-buffer/index.js +1 -84
  16. package/src/rules/no-deprecated-cipher-method/index.js +1 -112
  17. package/src/rules/no-dynamic-algorithm-selection/index.js +1 -72
  18. package/src/rules/no-dynamic-command-string/index.js +1 -201
  19. package/src/rules/no-dynamic-dependency-loading/index.js +1 -45
  20. package/src/rules/no-dynamic-require/index.js +1 -96
  21. package/src/rules/no-ecb-mode/index.js +1 -108
  22. package/src/rules/no-insecure-key-derivation/index.js +1 -109
  23. package/src/rules/no-insecure-rsa-padding/index.js +1 -104
  24. package/src/rules/no-math-random-crypto/index.js +1 -192
  25. package/src/rules/no-self-signed-certs/index.js +1 -110
  26. package/src/rules/no-sha1-hash/index.js +1 -121
  27. package/src/rules/no-shell-injection/index.js +1 -68
  28. package/src/rules/no-ssrf/index.js +1 -221
  29. package/src/rules/no-static-iv/index.js +1 -129
  30. package/src/rules/no-timing-unsafe-compare/index.js +1 -106
  31. package/src/rules/no-toctou-vulnerability/index.js +1 -195
  32. package/src/rules/no-unsafe-buffer-alloc/index.js +1 -87
  33. package/src/rules/no-unsafe-dynamic-require/index.js +1 -93
  34. package/src/rules/no-weak-cipher-algorithm/index.js +1 -174
  35. package/src/rules/no-weak-hash-algorithm/index.js +1 -199
  36. package/src/rules/no-zip-slip/index.js +1 -410
  37. package/src/rules/prefer-native-crypto/index.js +1 -119
  38. package/src/rules/require-dependency-integrity/index.js +1 -62
  39. package/src/rules/require-secure-credential-storage/index.js +1 -45
  40. package/src/rules/require-secure-deletion/index.js +1 -82
  41. package/src/rules/require-storage-encryption/index.js +1 -45
  42. package/src/types/index.js +1 -2
@@ -1,119 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preferNativeCrypto = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const THIRD_PARTY_CRYPTO_LIBS = new Set([
6
- 'crypto-js',
7
- 'cryptojs',
8
- 'sjcl',
9
- 'forge',
10
- 'node-forge',
11
- 'jsencrypt',
12
- 'bcryptjs',
13
- 'js-sha256',
14
- 'js-sha512',
15
- 'js-sha3',
16
- 'js-md5',
17
- 'blueimp-md5',
18
- 'aes-js',
19
- ]);
20
- exports.preferNativeCrypto = (0, eslint_devkit_1.createRule)({
21
- name: 'prefer-native-crypto',
22
- meta: {
23
- type: 'suggestion',
24
- docs: {
25
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/prefer-native-crypto.md',
26
- description: 'Prefer native crypto over third-party libraries',
27
- cwe: 'CWE-1104',
28
- cvss: 5.3,
29
- },
30
- hasSuggestions: true,
31
- messages: {
32
- preferNative: (0, eslint_devkit_1.formatLLMMessage)({
33
- icon: eslint_devkit_1.MessageIcons.WARNING,
34
- issueName: 'Third-party crypto library',
35
- cwe: 'CWE-1104',
36
- description: '{{library}} is a third-party crypto library. Native crypto (Node.js crypto or Web Crypto API) is faster, more secure, and always maintained.',
37
- severity: 'MEDIUM',
38
- fix: 'Migrate to native crypto module',
39
- documentationLink: 'https://nodejs.org/api/crypto.html',
40
- }),
41
- useNodeCrypto: (0, eslint_devkit_1.formatLLMMessage)({
42
- icon: eslint_devkit_1.MessageIcons.INFO,
43
- issueName: 'Use Node.js crypto',
44
- description: 'Node.js crypto module is built-in and maintained',
45
- severity: 'LOW',
46
- fix: 'import crypto from "node:crypto"',
47
- documentationLink: 'https://nodejs.org/api/crypto.html',
48
- }),
49
- useWebCrypto: (0, eslint_devkit_1.formatLLMMessage)({
50
- icon: eslint_devkit_1.MessageIcons.INFO,
51
- issueName: 'Use Web Crypto API',
52
- description: 'Web Crypto API is built into browsers and Node.js 15+',
53
- severity: 'LOW',
54
- fix: 'globalThis.crypto.subtle',
55
- documentationLink: 'https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API',
56
- }),
57
- },
58
- schema: [
59
- {
60
- type: 'object',
61
- properties: {
62
- severity: {
63
- type: 'string',
64
- enum: ['error', 'warn'],
65
- default: 'warn',
66
- description: 'Severity level',
67
- },
68
- },
69
- additionalProperties: false,
70
- },
71
- ],
72
- },
73
- defaultOptions: [
74
- {
75
- severity: 'warn',
76
- },
77
- ],
78
- create(context) {
79
- function reportThirdPartyLib(node, library) {
80
- context.report({
81
- node,
82
- messageId: 'preferNative',
83
- data: { library },
84
- suggest: [
85
- {
86
- messageId: 'useNodeCrypto',
87
- fix: () => null,
88
- },
89
- {
90
- messageId: 'useWebCrypto',
91
- fix: () => null,
92
- },
93
- ],
94
- });
95
- }
96
- return {
97
- ImportDeclaration(node) {
98
- if (typeof node.source.value === 'string') {
99
- const lib = node.source.value.split('/')[0];
100
- if (THIRD_PARTY_CRYPTO_LIBS.has(lib)) {
101
- reportThirdPartyLib(node, lib);
102
- }
103
- }
104
- },
105
- CallExpression(node) {
106
- if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
107
- node.callee.name === 'require' &&
108
- node.arguments.length === 1 &&
109
- node.arguments[0].type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
110
- typeof node.arguments[0].value === 'string') {
111
- const lib = node.arguments[0].value.split('/')[0];
112
- if (THIRD_PARTY_CRYPTO_LIBS.has(lib)) {
113
- reportThirdPartyLib(node, lib);
114
- }
115
- }
116
- },
117
- };
118
- },
119
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.preferNativeCrypto=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const THIRD_PARTY_CRYPTO_LIBS=new Set(["crypto-js","cryptojs","sjcl","forge","node-forge","jsencrypt","bcryptjs","js-sha256","js-sha512","js-sha3","js-md5","blueimp-md5","aes-js"]);exports.preferNativeCrypto=(0,eslint_devkit_1.createRule)({name:"prefer-native-crypto",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/prefer-native-crypto.md",description:"Prefer native crypto over third-party libraries",cwe:"CWE-1104",cvss:5.3},hasSuggestions:true,messages:{preferNative:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Third-party crypto library",cwe:"CWE-1104",description:"{{library}} is a third-party crypto library. Native crypto (Node.js crypto or Web Crypto API) is faster, more secure, and always maintained.",severity:"MEDIUM",fix:"Migrate to native crypto module",documentationLink:"https://nodejs.org/api/crypto.html"}),useNodeCrypto:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Node.js crypto",description:"Node.js crypto module is built-in and maintained",severity:"LOW",fix:'import crypto from "node:crypto"',documentationLink:"https://nodejs.org/api/crypto.html"}),useWebCrypto:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Web Crypto API",description:"Web Crypto API is built into browsers and Node.js 15+",severity:"LOW",fix:"globalThis.crypto.subtle",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API"})},schema:[{type:"object",properties:{severity:{type:"string",enum:["error","warn"],default:"warn",description:"Severity level"}},additionalProperties:false}]},defaultOptions:[{severity:"warn"}],create(context){function reportThirdPartyLib(node,library){context.report({node,messageId:"preferNative",data:{library},suggest:[{messageId:"useNodeCrypto",fix:()=>null},{messageId:"useWebCrypto",fix:()=>null}]})}return{ImportDeclaration(node){if(typeof node.source.value==="string"){const lib=node.source.value.split("/")[0];if(THIRD_PARTY_CRYPTO_LIBS.has(lib)){reportThirdPartyLib(node,lib)}}},CallExpression(node){if(node.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.callee.name==="require"&&node.arguments.length===1&&node.arguments[0].type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof node.arguments[0].value==="string"){const lib=node.arguments[0].value.split("/")[0];if(THIRD_PARTY_CRYPTO_LIBS.has(lib)){reportThirdPartyLib(node,lib)}}}}}});
@@ -1,62 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireDependencyIntegrity = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.requireDependencyIntegrity = (0, eslint_devkit_1.createRule)({
6
- name: 'require-dependency-integrity',
7
- meta: {
8
- type: 'problem',
9
- docs: {
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-dependency-integrity.md',
11
- description: 'Require SRI (Subresource Integrity) for CDN resources',
12
- cwe: 'CWE-494',
13
- cvss: 8.1,
14
- },
15
- messages: {
16
- violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
17
- icon: eslint_devkit_1.MessageIcons.SECURITY,
18
- issueName: 'Missing SRI',
19
- cwe: 'CWE-494',
20
- description: 'External resource loaded without integrity hash - supply chain risk',
21
- severity: 'HIGH',
22
- fix: 'Add integrity="sha384-..." and crossorigin="anonymous" attributes',
23
- documentationLink: 'https://cwe.mitre.org/data/definitions/494.html',
24
- })
25
- },
26
- schema: [],
27
- },
28
- defaultOptions: [],
29
- create(context) {
30
- function report(node) {
31
- context.report({ node, messageId: 'violationDetected' });
32
- }
33
- return {
34
- Literal(node) {
35
- if (typeof node.value !== 'string')
36
- return;
37
- const value = node.value.toLowerCase();
38
- if ((value.includes('<script') && value.includes('src=')) ||
39
- (value.includes('<link') && value.includes('href='))) {
40
- if (value.includes('cdn.') || value.includes('cdnjs.') ||
41
- value.includes('unpkg.') || value.includes('jsdelivr.')) {
42
- if (!value.includes('integrity=')) {
43
- report(node);
44
- }
45
- }
46
- }
47
- },
48
- TemplateLiteral(node) {
49
- const text = context.sourceCode.getText(node).toLowerCase();
50
- if ((text.includes('<script') && text.includes('src=')) ||
51
- (text.includes('<link') && text.includes('href='))) {
52
- if (text.includes('cdn.') || text.includes('cdnjs.') ||
53
- text.includes('unpkg.') || text.includes('jsdelivr.')) {
54
- if (!text.includes('integrity=')) {
55
- report(node);
56
- }
57
- }
58
- }
59
- },
60
- };
61
- },
62
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireDependencyIntegrity=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireDependencyIntegrity=(0,eslint_devkit_1.createRule)({name:"require-dependency-integrity",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-dependency-integrity.md",description:"Require SRI (Subresource Integrity) for CDN resources",cwe:"CWE-494",cvss:8.1},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing SRI",cwe:"CWE-494",description:"External resource loaded without integrity hash - supply chain risk",severity:"HIGH",fix:'Add integrity="sha384-..." and crossorigin="anonymous" attributes',documentationLink:"https://cwe.mitre.org/data/definitions/494.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}return{Literal(node){if(typeof node.value!=="string")return;const value=node.value.toLowerCase();if(value.includes("<script")&&value.includes("src=")||value.includes("<link")&&value.includes("href=")){if(value.includes("cdn.")||value.includes("cdnjs.")||value.includes("unpkg.")||value.includes("jsdelivr.")){if(!value.includes("integrity=")){report(node)}}}},TemplateLiteral(node){const text=context.sourceCode.getText(node).toLowerCase();if(text.includes("<script")&&text.includes("src=")||text.includes("<link")&&text.includes("href=")){if(text.includes("cdn.")||text.includes("cdnjs.")||text.includes("unpkg.")||text.includes("jsdelivr.")){if(!text.includes("integrity=")){report(node)}}}}}}});
@@ -1,45 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireSecureCredentialStorage = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.requireSecureCredentialStorage = (0, eslint_devkit_1.createRule)({
6
- name: 'require-secure-credential-storage',
7
- meta: {
8
- type: 'problem',
9
- docs: {
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-secure-credential-storage.md',
11
- description: 'Enforce secure storage patterns for credentials',
12
- cwe: 'CWE-312',
13
- cvss: 7.5,
14
- },
15
- messages: {
16
- violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
17
- icon: eslint_devkit_1.MessageIcons.SECURITY,
18
- issueName: 'violation Detected',
19
- cwe: 'CWE-312',
20
- description: 'Enforce secure storage patterns for credentials detected - Credentials without encryption',
21
- severity: 'HIGH',
22
- fix: 'Review and apply secure practices',
23
- documentationLink: 'https://cwe.mitre.org/data/definitions/312.html',
24
- })
25
- },
26
- schema: [],
27
- },
28
- defaultOptions: [],
29
- create(context) {
30
- return {
31
- CallExpression(node) {
32
- if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
33
- node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
34
- ['setItem', 'writeFile'].includes(node.callee.property.name)) {
35
- const hasEncryption = node.arguments.some(arg => arg.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
36
- arg.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
37
- arg.callee.name.includes('encrypt'));
38
- if (!hasEncryption) {
39
- context.report({ node, messageId: 'violationDetected' });
40
- }
41
- }
42
- },
43
- };
44
- },
45
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireSecureCredentialStorage=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireSecureCredentialStorage=(0,eslint_devkit_1.createRule)({name:"require-secure-credential-storage",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-secure-credential-storage.md",description:"Enforce secure storage patterns for credentials",cwe:"CWE-312",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-312",description:"Enforce secure storage patterns for credentials detected - Credentials without encryption",severity:"HIGH",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/312.html"})},schema:[]},defaultOptions:[],create(context){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&&["setItem","writeFile"].includes(node.callee.property.name)){const hasEncryption=node.arguments.some(arg=>arg.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&arg.callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&arg.callee.name.includes("encrypt"));if(!hasEncryption){context.report({node,messageId:"violationDetected"})}}}}}});
@@ -1,82 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireSecureDeletion = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- const SENSITIVE_PROPERTY_FRAGMENTS = [
6
- 'password', 'passwd', 'pwd', 'passphrase',
7
- 'secret', 'apikey', 'api_key',
8
- 'token', 'jwt', 'bearer',
9
- 'credential', 'privatekey', 'private_key', 'signingkey', 'signing_key',
10
- 'sessionid', 'session_id', 'refreshtoken', 'refresh_token',
11
- 'ssn', 'creditcard', 'credit_card', 'cardnumber', 'card_number', 'cvv',
12
- ];
13
- exports.requireSecureDeletion = (0, eslint_devkit_1.createRule)({
14
- name: 'require-secure-deletion',
15
- meta: {
16
- type: 'problem',
17
- docs: {
18
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-secure-deletion.md',
19
- description: 'Require secure data deletion patterns',
20
- cwe: 'CWE-459',
21
- cvss: 5,
22
- },
23
- messages: {
24
- violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
25
- icon: eslint_devkit_1.MessageIcons.SECURITY,
26
- issueName: 'Incomplete Secret Cleanup',
27
- cwe: 'CWE-459',
28
- description: '`delete` on the sensitive property `{{property}}` unbinds it without scrubbing the value',
29
- severity: 'MEDIUM',
30
- fix: 'Overwrite the value before deleting it (obj.{{property}} = undefined, or zero-fill the Buffer), and make sure no copy of the object was spread, logged, or serialised first',
31
- documentationLink: 'https://cwe.mitre.org/data/definitions/459.html',
32
- })
33
- },
34
- schema: [
35
- {
36
- type: 'object',
37
- properties: {
38
- additionalSensitiveProperties: {
39
- type: 'array',
40
- items: { type: 'string' },
41
- default: [],
42
- description: 'Extra property-name fragments to treat as sensitive',
43
- },
44
- },
45
- additionalProperties: false,
46
- },
47
- ],
48
- },
49
- defaultOptions: [{ additionalSensitiveProperties: [] }],
50
- create(context, [options = {}]) {
51
- const { additionalSensitiveProperties = [] } = options;
52
- const fragments = [
53
- ...SENSITIVE_PROPERTY_FRAGMENTS,
54
- ...additionalSensitiveProperties.map((f) => f.toLowerCase()),
55
- ];
56
- function deletedPropertyName(node) {
57
- const argument = node.type === 'ChainExpression' ? node.expression : node;
58
- if (argument.type !== 'MemberExpression')
59
- return undefined;
60
- const property = argument.property;
61
- if (!argument.computed && property.type === 'Identifier')
62
- return property.name;
63
- if (argument.computed && property.type === 'Literal' && typeof property.value === 'string') {
64
- return property.value;
65
- }
66
- return undefined;
67
- }
68
- return {
69
- UnaryExpression(node) {
70
- if (node.operator !== 'delete')
71
- return;
72
- const property = deletedPropertyName(node.argument);
73
- if (!property)
74
- return;
75
- const normalized = property.toLowerCase().replace(/[^a-z0-9_]/g, '');
76
- if (!fragments.some((fragment) => normalized.includes(fragment)))
77
- return;
78
- context.report({ node, messageId: 'violationDetected', data: { property } });
79
- },
80
- };
81
- },
82
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireSecureDeletion=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const SENSITIVE_PROPERTY_FRAGMENTS=["password","passwd","pwd","passphrase","secret","apikey","api_key","token","jwt","bearer","credential","privatekey","private_key","signingkey","signing_key","sessionid","session_id","refreshtoken","refresh_token","ssn","creditcard","credit_card","cardnumber","card_number","cvv"];exports.requireSecureDeletion=(0,eslint_devkit_1.createRule)({name:"require-secure-deletion",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-secure-deletion.md",description:"Require secure data deletion patterns",cwe:"CWE-459",cvss:5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Incomplete Secret Cleanup",cwe:"CWE-459",description:"`delete` on the sensitive property `{{property}}` unbinds it without scrubbing the value",severity:"MEDIUM",fix:"Overwrite the value before deleting it (obj.{{property}} = undefined, or zero-fill the Buffer), and make sure no copy of the object was spread, logged, or serialised first",documentationLink:"https://cwe.mitre.org/data/definitions/459.html"})},schema:[{type:"object",properties:{additionalSensitiveProperties:{type:"array",items:{type:"string"},default:[],description:"Extra property-name fragments to treat as sensitive"}},additionalProperties:false}]},defaultOptions:[{additionalSensitiveProperties:[]}],create(context,[options={}]){const{additionalSensitiveProperties=[]}=options;const fragments=[...SENSITIVE_PROPERTY_FRAGMENTS,...additionalSensitiveProperties.map(f=>f.toLowerCase())];function deletedPropertyName(node){const argument=node.type==="ChainExpression"?node.expression:node;if(argument.type!=="MemberExpression")return void 0;const property=argument.property;if(!argument.computed&&property.type==="Identifier")return property.name;if(argument.computed&&property.type==="Literal"&&typeof property.value==="string"){return property.value}return void 0}return{UnaryExpression(node){if(node.operator!=="delete")return;const property=deletedPropertyName(node.argument);if(!property)return;const normalized=property.toLowerCase().replace(/[^a-z0-9_]/g,"");if(!fragments.some(fragment=>normalized.includes(fragment)))return;context.report({node,messageId:"violationDetected",data:{property}})}}}});
@@ -1,45 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireStorageEncryption = void 0;
4
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
- exports.requireStorageEncryption = (0, eslint_devkit_1.createRule)({
6
- name: 'require-storage-encryption',
7
- meta: {
8
- type: 'problem',
9
- docs: {
10
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-storage-encryption.md',
11
- description: 'Require encryption for persistent storage',
12
- cwe: 'CWE-312',
13
- cvss: 7.5,
14
- },
15
- messages: {
16
- violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
17
- icon: eslint_devkit_1.MessageIcons.SECURITY,
18
- issueName: 'violation Detected',
19
- cwe: 'CWE-312',
20
- description: 'Require encryption for persistent storage detected - Storage without encryption',
21
- severity: 'HIGH',
22
- fix: 'Review and apply secure practices',
23
- documentationLink: 'https://cwe.mitre.org/data/definitions/312.html',
24
- })
25
- },
26
- schema: [],
27
- },
28
- defaultOptions: [],
29
- create(context) {
30
- return {
31
- CallExpression(node) {
32
- if (node.callee.type === 'MemberExpression' &&
33
- node.callee.property.type === 'Identifier' &&
34
- ['setItem', 'writeFile'].includes(node.callee.property.name)) {
35
- const hasEncryption = node.arguments.some(arg => arg.type === 'CallExpression' &&
36
- arg.callee.type === 'Identifier' &&
37
- arg.callee.name.includes('encrypt'));
38
- if (!hasEncryption) {
39
- context.report({ node, messageId: 'violationDetected' });
40
- }
41
- }
42
- },
43
- };
44
- },
45
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireStorageEncryption=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireStorageEncryption=(0,eslint_devkit_1.createRule)({name:"require-storage-encryption",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/require-storage-encryption.md",description:"Require encryption for persistent storage",cwe:"CWE-312",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-312",description:"Require encryption for persistent storage detected - Storage without encryption",severity:"HIGH",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/312.html"})},schema:[]},defaultOptions:[],create(context){return{CallExpression(node){if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"&&["setItem","writeFile"].includes(node.callee.property.name)){const hasEncryption=node.arguments.some(arg=>arg.type==="CallExpression"&&arg.callee.type==="Identifier"&&arg.callee.name.includes("encrypt"));if(!hasEncryption){context.report({node,messageId:"violationDetected"})}}}}}});
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});