feat(lint): add CWE-tagged security rules to library source - #598
Open
ofri-peretz wants to merge 1 commit into
Open
feat(lint): add CWE-tagged security rules to library source#598ofri-peretz wants to merge 1 commit into
ofri-peretz wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
eslint-plugin-browser-securityandeslint-plugin-secure-codingas a block ineslint.config.mjs— 51 rules covering XSS sinks (innerHTML,eval), credential storage, and the injection surfaces around them.Scoped to library source, with
**/*.spec.tsexcluded. A fixture states the insecure thing on purpose, and a linter that argues with test fixtures is a linter people turn off.It finds nothing here, and that is the point
Measured against this repository before opening the PR: 0 findings across 10.2 KLOC.
eslint .exits 0, unchanged. The diff adds no work for anyone.The ask is to keep it that way. A rule that is not enabled catches nothing on the day a DOM helper starts assigning
innerHTML.I checked the zero was real
A clean result and a misconfigured linter produce the same output, so I verified rather than assumed. Appending known vulnerability shapes to 40 of this repository's own source files, the rules catch 280/280 (100%) — every shape, every file. Zero here means the rules ran and found nothing, not that they were silently absent.
A deliberate violation reports:
Why it might matter here specifically
This library is a dev dependency in a lot of Angular codebases, and it does real DOM work on their behalf. The rules are not claiming this code is risky today — they measured it as clean. They are a regression gate on a package other people's test suites execute.
Every message carries a CWE identifier and a CVSS score rather than just a rule name, which is the form an audit asks for.
Notes
devDependencies; nothing changes for consumers.package-lock=false.warn, or scope it further if you would rather adopt gradually.