feat(lint): add eight browser-security ESLint rules - #209
Conversation
Mirror of laststance/eslint-config-ts-prefixer#636 (open, not yet released). Adds eslint-plugin-browser-security and enables 8 rules for runtime XSS sinks and token-storage risks (no-innerhtml, no-eval, no-jwt-in-storage, no-sensitive-localstorage, no-credentials-in-query-params, require-cookie-secure-attrs, no-postmessage-wildcard-origin, no-insecure-redirects). Whole repo lints clean, 0 violations. Delete the block once eslint-config-ts-prefixer ships a release with them.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Included review availability: 7 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour. 📝 WalkthroughWalkthroughThe project adds ChangesBrowser security linting
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change adds browser-security lint rules and their development dependency without changing runtime behavior; lint and type checks pass, and no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
=======================================
Coverage 70.68% 70.68%
=======================================
Files 172 172
Lines 4820 4820
Branches 1251 1277 +26
=======================================
Hits 3407 3407
Misses 1394 1394
Partials 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🧪 E2E Coverage Report (Sharded: 12 parallel jobs)
📊 Full report available in workflow artifacts |
Summary
Adds eight browser-security ESLint rules to catch runtime XSS sinks and token-storage risks that a type checker cannot see.
Mirrors laststance/eslint-config-ts-prefixer#636. That PR is still open / unreleased, so the rules are added directly to gitbox's
eslint.config.mjsfor now. The block is commented to be deleted onceeslint-config-ts-prefixerships a release that already includes them — at which point the...tsPrefixerspread provides them automatically.Changes
eslint-plugin-browser-security(devDependency,^2.0.6).error) ineslint.config.mjs, in a dedicated, self-documenting block:no-innerhtml— assigning toinnerHTML/outerHTML(top XSS sink)no-eval—eval()and its string-compiling relativesno-jwt-in-storage— JWT inlocalStorage/sessionStorage(readable by any XSS, unlike an HttpOnly cookie)no-sensitive-localstorage— other secrets in Web Storageno-credentials-in-query-params— creds leak into history / Referer / access logsrequire-cookie-secure-attrs—Secure+SameSiteon JS-set cookiesno-postmessage-wildcard-origin—postMessage(..., '*')origin-wildcard leakno-insecure-redirects— open redirect from unvalidated inputRule names were verified against the installed plugin (2.0.6 ships 46 rules; these are the 8 enabled by #636), rather than trusting the unmerged PR's spelling. No per-file overrides were needed — the repo lints clean as-is.
Testing
pnpm lint— passes, 0 violations repo-wide (lint-staged pre-commit hook also green)pnpm typecheck— passespnpm test— N/A (ESLint-config-only change; no runtime code touched)pnpm build— N/Apnpm exec playwright test --reporter=list— N/AWhy existing code passes clean:
no-innerhtmltargets.innerHTML =assignments, not React'sdangerouslySetInnerHTMLprop, sosrc/app/layout.tsx's theme-flash script is unaffected.sessionStoragevalue insrc/lib/utils/handle-github-token-missing.tsis a numeric retry counter, not a secret, so the storage rules don't flag it.Screenshots or Recordings
N/A — no UI change.
Checklist
CONTRIBUTING.md🌙 Prepared overnight at the maintainer's request. Ready for review.
Summary by CodeRabbit
New Features
Chores