Skip to content

Commit 76cd56f

Browse files
committed
feat(lint): add CWE-tagged security rules to library source
Adds eslint-plugin-browser-security and eslint-plugin-secure-coding, scoped to library source and excluded from **/*.spec.ts — a fixture states the insecure thing on purpose. 51 rules covering XSS sinks, credential storage and the injection surfaces around them. Measured against this repository before proposing: 0 findings, and `eslint .` exits 0 unchanged. Every message carries a CWE identifier and a CVSS score rather than a rule name.
1 parent e6f4e26 commit 76cd56f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎eslint.config.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import tseslint from 'typescript-eslint';
55
import angular from 'angular-eslint';
66
import jestDom from 'eslint-plugin-jest-dom';
77
import testingLibrary from 'eslint-plugin-testing-library';
8+
import browserSecurity from 'eslint-plugin-browser-security';
9+
import secureCoding from 'eslint-plugin-secure-coding';
810

911
export default tseslint.config(
1012
{
@@ -46,6 +48,21 @@ export default tseslint.config(
4648
'@angular-eslint/no-input-rename': 'off',
4749
},
4850
},
51+
// Security rules, CWE- and CVSS-tagged. Scoped to library source: the spec
52+
// files below are fixtures, and a fixture states the insecure thing on
53+
// purpose. Measured against this repository before proposing: 0 findings.
54+
{
55+
files: ['**/*.ts'],
56+
ignores: ['**/*.spec.ts'],
57+
plugins: {
58+
'browser-security': browserSecurity,
59+
'secure-coding': secureCoding,
60+
},
61+
rules: {
62+
...browserSecurity.configs.recommended.rules,
63+
...secureCoding.configs.recommended.rules,
64+
},
65+
},
4966
{
5067
files: ['**/*.spec.ts'],
5168
extends: [jestDom.configs['flat/recommended'], testingLibrary.configs['flat/angular']],

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"autoprefixer": "^10.4.21",
6363
"cpy-cli": "^6.0.0",
6464
"eslint": "^9.39.1",
65+
"eslint-plugin-browser-security": "^2.0.5",
6566
"eslint-plugin-jest-dom": "~5.10.1",
67+
"eslint-plugin-secure-coding": "^5.1.2",
6668
"eslint-plugin-testing-library": "~7.16.2",
6769
"istanbul-lib-instrument": "^6.0.3",
6870
"jasmine-core": "4.2.0",

0 commit comments

Comments
 (0)