mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
This pull request introduces several improvements and security enhancements to the documentation build scripts in `apps/docs/scripts/fetch-remote-content.mjs`, as well as updates to the test configuration in `apps/docs/package.json` and `apps/docs/project.json`. The main focus is on enabling local development workflows, improving safety when handling refs and file paths, and making the codebase more robust against injection and traversal attacks. **Security and validation improvements:** * Added `safeLog` and `isValidRef` helper functions to sanitize logs and validate refs, preventing log and command injection vulnerabilities. * Updated logic for reading local files and external content to ensure paths are securely resolved and checked, preventing directory traversal and unauthorized file access. **Local development and workflow enhancements:** * Refactored content fetching logic to support copying local content and public assets when the source ref matches the local branch, enabling easier local testing and development. [[1]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L70-R202) [[2]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1R230-L145) [[3]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L155-R250) * Improved handling of external files (like `defaults.yaml` and `setup/steps.yaml`) in local and remote workflows, including secure copying and conditional downloading. [[1]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L70-R202) [[2]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1R266-R364) * Enhanced relative import fixing logic to robustly rewrite paths and ensure external files are downloaded or copied as needed, with clearer separation of cases for content, public, and external assets. (F768070bL263R373, [[1]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L310-R398) [[2]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L345-L349) [[3]](diffhunk://#diff-0d1ade7f3d86ad72c66b573c31b0bc34d318dbf964198164719822d300d397d1L360-R425) **Testing and configuration updates:** * Added a new `test:scripts` npm script for running script-level tests, and updated the Nx test command to use this script for the docs app. [[1]](diffhunk://#diff-d03d2ce97fad5059ad6248fca5f5919994b09bca360f883318c03f1f817ae677R19) [[2]](diffhunk://#diff-92d9997980c0871325f1a46a6d363cc28da597bd19ed327e979774d9e7838cabL216-R216) These changes improve the reliability, security, and developer experience of the documentation build process.