Repository navigation
Open
Labels
enhancementNew feature or request
Description
Current Behavior
Vitest and Playwright are set up and run in CI, but the pure helpers that guard security-relevant behavior have no unit tests:
isUrlSaveForRedirect()insrc/shared/utils.jsis the open-redirect guard for the post-loginredirectquery parameter. Nothing checks that it keeps rejecting other origins, protocol-relative URLs,javascript:/data:/blob:URLs or paths outside the allowed roots.hasPermission(),storePermissions()andgetPermissions()insrc/shared/permissions.jsgate what the UI shows (via thev-permissiondirective andpermissionsMixin). The e2e permission specs cover them through the UI, but nothing checks edge cases such as missing or corrupt stored permissions directly.- The HTML-building formatters in
src/shared/common.jsrely onxss-filtersfor escaping. Nothing checks that untrusted values stay escaped, so removing an escape call during a refactoring would go unnoticed.
There is also no coverage report, so it is not visible which parts of the code are untested.
These are what remains of #1731 after the move to Vitest and Playwright.
Proposed Behavior
- Unit tests (Vitest, colocated
*.test.js) for:isUrlSaveForRedirect(): allowed same-origin paths, including under a non-root context path, and rejection of other origins,//host, backslash and percent-encoded variants, non-http(s) schemes, disallowed paths and empty input.hasPermission()/storePermissions()/getPermissions(): granted and missing permissions, and absent, corrupt or non-array stored data.- The HTML-building formatters in
src/shared/common.js: hostile input (<script>, attribute break-outs,javascript:links) comes out escaped, while normal input renders as before.
- Each test group proven effective by mutation: temporarily removing the guarded check makes the tests fail.
- Optional, report-only coverage:
@vitest/coverage-v8and annpm run test-coveragescript that writescoverage/(text + lcov), with no enforced threshold.
No production code changes are intended. Surprising behavior found along the way would be documented in the tests and raised separately.
Checklist
- I have read and understand the contributing guidelines
- I have checked the existing issues for whether this enhancement was already requested
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity