liferay/liferay-portal / .claude/skills/pr-check
pr-check
VerifiedCheck that a PR is ready to be sent for review.
validations/branch/html-escaping.md
View on GitHub# HTML Escaping
Catches an added line in hand written JavaScript or TypeScript that renders a value as HTML without escaping it first, which is a cross site scripting defect.
## Match
`\.(js|jsx|ts|tsx)$`
## Command
The scope is the whole branch diff, so a line added in one commit and escaped in a later one is not a finding.
List the changed files:
```bash
bash "${SKILL_DIR}/select_paths.sh" "${MERGE_BASE}" "${VALIDATION_FILE}"
```
Skip any file the branch deleted, which no longer exists, and any file containing `@generated`, matched case insensitively. For each file that remains, list the added lines that render a value as HTML:
```bash
git diff "${MERGE_BASE}...HEAD" -- <file> \
| command grep '^+[^+]' \
| command grep \
--extended-regexp \
--regexp='(bodyHTML|headerHTML)[[:space:]]*:' \
--regexp='(inner|outer)HTML[[:space:]]*=' \
--regexp='createContextualFragment\(' \
--regexp='dangerouslySetInnerHTML' \
--regexp='document\.write\(' \
--regexp='insertAdjacentHTML\(' \
--regexp='new Function\(' \
--regexp='open(Toast|Modal)\(' \
--regexp='srcdoc'
```
When no file remains to scan, because every selected path was deleted on the branch or is generated, nothing was examined. Report **NOT APPLICABLE** naming what was left out, since a pass over an empty set reads as a branch that was checked. When files remain and none produces output, the validation passes.
Otherwise, each printed line is a candidate, not a finding. Read the file to classify it and find the line number.
A candidate is not a finding when:
- A `// XSS:` waiver comment appears above the line.
- The call is `openToast` or `openModal` and passes no `bodyHTML`, `headerHTML`, `message`, or `title` argument.
- The line only renames, reformats, or moves existing code.
- The value comes from `Liferay.Language.get` or `sub` on a literal key.
- The value is a static literal, including a template literal whose every interpolation is a literal.
- The value is already escaped by `escapeHTML` from `frontend-js-web` or by `Liferay.Util.escapeHTML`.
Everything else is a finding, including any value that cannot be traced.
Report every finding as a FAIL and return the block below as the failure note.
```markdown
**A value is rendered as HTML without being escaped.** Escape each value below with `escapeHTML` from `frontend-js-web` where it is rendered. When it is already escaped earlier, keep the code as it is and add a `// XSS: <value> is escaped by <where>` comment above the line. Do not add a second escape.
| File | Line | Rendered by | Value |
| --- | --- | --- | --- |
| <file> | <line> | <call> | <expression> |
```
## Time Estimate
~20-40 sec (static, no build).Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |