(root)
| 8755 | /* Collect anything executable reachable from a serialized string, walking |
| 8756 | into <template>.content and any activated shadowRoot. */ |
| 8757 | const _executableFindings = function (root) { |
| 8758 | const findings = []; |
| 8759 | const visit = (node) => { |
| 8760 | if (!node) return; |
| 8761 | if (node.nodeType === 1) { |
| 8762 | const tag = node.tagName ? node.tagName.toLowerCase() : ''; |
| 8763 | for (const name of node.getAttributeNames()) { |
| 8764 | if (/^on/i.test(name)) findings.push(`${tag}@${name}`); |
| 8765 | if ( |
| 8766 | (name === 'href' || name === 'src' || name === 'xlink:href') && |
| 8767 | /^\s*(?:java|vb)script:/i.test(node.getAttribute(name) || '') |
| 8768 | ) { |
| 8769 | findings.push(`${tag}@${name}=js`); |
| 8770 | } |
| 8771 | } |
| 8772 | if (tag === 'script') findings.push('script'); |
| 8773 | if (node.shadowRoot) visit(node.shadowRoot); |
| 8774 | if (tag === 'template' && node.content) visit(node.content); |
| 8775 | } |
| 8776 | for (const child of node.childNodes) visit(child); |
| 8777 | }; |
| 8778 | visit(root); |
| 8779 | return findings; |
| 8780 | }; |
| 8781 | const _findingsFromHTML = function (html) { |
| 8782 | const holder = document.createElement('div'); |
| 8783 | holder.innerHTML = html; |
no test coverage detected