(root)
| 7823 | /* Collect anything executable reachable from a serialized string, walking |
| 7824 | into <template>.content and any activated shadowRoot. */ |
| 7825 | const _executableFindings = function (root) { |
| 7826 | const findings = []; |
| 7827 | const visit = (node) => { |
| 7828 | if (!node) return; |
| 7829 | if (node.nodeType === 1) { |
| 7830 | const tag = node.tagName ? node.tagName.toLowerCase() : ''; |
| 7831 | for (const name of node.getAttributeNames()) { |
| 7832 | if (/^on/i.test(name)) findings.push(`${tag}@${name}`); |
| 7833 | if ( |
| 7834 | (name === 'href' || name === 'src' || name === 'xlink:href') && |
| 7835 | /^\s*(?:java|vb)script:/i.test(node.getAttribute(name) || '') |
| 7836 | ) { |
| 7837 | findings.push(`${tag}@${name}=js`); |
| 7838 | } |
| 7839 | } |
| 7840 | if (tag === 'script') findings.push('script'); |
| 7841 | if (node.shadowRoot) visit(node.shadowRoot); |
| 7842 | if (tag === 'template' && node.content) visit(node.content); |
| 7843 | } |
| 7844 | for (const child of node.childNodes) visit(child); |
| 7845 | }; |
| 7846 | visit(root); |
| 7847 | return findings; |
| 7848 | }; |
| 7849 | const _findingsFromHTML = function (html) { |
| 7850 | const holder = document.createElement('div'); |
| 7851 | holder.innerHTML = html; |
no test coverage detected