Potential fix for code scanning alert no. 11: DOM text reinterpreted as HTML#21
Conversation
…as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe click handler displaying accumulated search results for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Potential fix for https://github.com/luni/dccbot/security/code-scanning/11
Use safe DOM APIs instead of composing HTML strings with untrusted content. Specifically in
userscript/add-dccbot-btn.jsat theh4.onclickhandler (around line 811), replace:msg.innerHTML = '<textarea ...>' + all_results.join('\n') + '</textarea>';with code that:
msg.textContent = ''),<textarea>node viadocument.createElement('textarea'),style.width,rows),textarea.value(ortextContent),msg.This preserves functionality (showing batch lines in a textarea) while removing HTML parsing of tainted data.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by CodeRabbit
Refactor