Fix missing JavaScript files and implement security sanitization features#2935
Fix missing JavaScript files and implement security sanitization features#2935
Conversation
…mmand sanitization Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pkg/workflow/js/lib/sanitize.cjs
Outdated
| // Convert opening tags: <tag> or <tag attr="value"> to (tag) or (tag attr="value") | ||
| // Convert closing tags: </tag> to (/tag) | ||
| // Convert self-closing tags: <tag/> or <tag /> to (tag/) or (tag /) | ||
| return s.replace(/<(\/?[A-Za-z][A-Za-z0-9]*(?:[^>]*?))>/g, "($1)"); |
There was a problem hiding this comment.
Added support for preserving safe HTML tags (details, summary, code, em, b) in commit 6513b6f. These tags are now allowed and won't be converted to parentheses format, while potentially dangerous tags like <script> and <div> are still sanitized.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…root Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the content sanitization utilities for GitHub Actions workflows by adding new security features and improving URL handling. The changes are made to a core sanitization module that is then replicated across multiple workflow files.
Key changes include:
- Added command neutralization to prevent bot command injection (e.g.,
/bot-name) - Added XML tag conversion to prevent injection attacks while allowing safe HTML tags
- Improved URL protocol sanitization with better handling of edge cases (namespaces, file paths)
- Fixed import paths to reference
./sanitize.cjsinstead of./lib/sanitize.cjs - Updated URL domain matching regex to handle full URLs with paths, queries, and fragments
Reviewed Changes
Copilot reviewed 61 out of 61 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/js/sanitize.cjs | Core sanitization module with new security features |
| pkg/workflow/js/sanitize_output.cjs | Updated import path for sanitize module |
| pkg/workflow/js/compute_text.cjs | Updated import path for sanitize module |
| pkg/workflow/js/collect_ndjson_output.cjs | Updated import path for sanitize module |
| .github/workflows/*.lock.yml | Applied sanitization changes to all workflow lock files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot fix all references to libs/sanitize.cjs |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Head branch was pushed to by a user without write access
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot merge main and fix all JavaScript tests |
…assets cleanup Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Merged main and fixed all JavaScript tests in commit 4143f71. All 638 tests now passing (100%):
Test results:
|
|
@copilot format lint fix tests |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Head branch was pushed to by a user without write access
Fix CI and JavaScript test failures - Complete ✅
Summary
Successfully fixed ALL CI failures and JavaScript test issues. The main "Build JavaScript" job was failing with 27 test failures due to missing
.cjsfiles and unimplemented sanitization features. All 638 JavaScript tests now pass (100%).Root Cause
Recent commit added test files (
compute_text.test.cjs,sanitize_output.test.cjs,collect_ndjson_output.test.cjs) that expected implementation files in the rootjs/directory, but the actual implementation files were placed in thesrc/subdirectory.Fixes Implemented
File Organization - Flattened directory structure: all
.cjsfiles now inpkg/workflow/js/root directorylib/andsrc/subdirectories./lib/sanitize.cjsto./sanitize.cjsjs/lib/sanitize.cjstojs/sanitize.cjsjs/src/*.cjstojs/*.cjsXML Tag Sanitization - Added conversion of XML/HTML tags to parentheses format (
<tag>→(tag))<details>,<summary>,<code>,<em>,<b>are preserved for formatting<![CDATA[<script>alert("xss")</script>]]>→(![CDATA[(script)alert("xss")(/script)]])Command Neutralization - Added bot command neutralization at start of text (
/bot-name→`/bot-name`)Protocol Filtering - Improved protocol detection to avoid false positives:
-v:10)::), and ratios (3:1)Domain Filtering - Fixed to handle complex URL scenarios:
https://evil.com/path?goto=https://github.com/safe→(redacted)?goto=https://github.com/safeUpload Assets Test Fix - Fixed race condition in upload_assets test
Merged main branch - Incorporated latest changes from main (twice) and recompiled all workflows
Code Quality - Fixed linting errors
ExtractExpressionsfunctionTest Results
CI Status
The original failing job "Build JavaScript" now passes with 100% test success rate. All files have been reorganized and all security sanitization features have been fully implemented and tested.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.