Security & Quality: Comprehensive code review fixes #458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses security vulnerabilities and code quality issues identified during a comprehensive code review of
lib/types.ts,lib/utils.ts,lib/validation.ts,lib/xmllint.ts, andlib/errors.ts.Security Fixes (Critical)
🔒 Command Injection Prevention
lib/xmllint.ts🔒 Enhanced Path Traversal Protection
lib/validation.ts..path traversal sequences..in all positions (beginning, middle, end, standalone)/) and Windows (\) separators🔒 XSL URL Security Hardening
lib/validation.ts<script,<ScRiPt,<SCRIPT>, etc.javascript:,data:,vbscript:,file:,about:%3cscript,javascript%3a, etc.Quality Improvements
✅ Number Validation
lib/utils.tsparseFloat()andparseInt()could produceNaNthat propagated to XML✅ Date Validation
lib/utils.tsInvalid DateobjectsNumber.isNaN(date.getTime())to detect invalid dates✅ Language Regex Fix
lib/types.ts/^zh-cn|zh-tw|([a-z]{2,3})$/had incorrect grouping/^(zh-cn|zh-tw|[a-z]{2,3})$/for proper validation✅ Path Resolution Robustness
lib/xmllint.tsprocess.cwd()based search with fallback paths📝 Type Documentation
lib/types.tsPriceTypeandResolutiontypesDocumentation
📖 Security Documentation
api.mdsimpleSitemapAndIndexxmlLintdocumentation about stdin piping📖 JSDoc Security Comments
Testing
✅ Test Updates
tests/xmllint.test.tsto pass XML content instead of file pathsBreaking Changes
..that were previously acceptedAll breaking changes are documented in the updated
api.md.Checklist
🤖 Generated with Claude Code