Fix #1721: char-safe truncation in sanitize_system_prompt#882
Open
AlexMikhalev wants to merge 23 commits into
Open
Fix #1721: char-safe truncation in sanitize_system_prompt#882AlexMikhalev wants to merge 23 commits into
AlexMikhalev wants to merge 23 commits into
Conversation
…1721 Replace byte-slice truncation prompt[..MAX_PROMPT_LENGTH] with prompt.chars().take(MAX_PROMPT_LENGTH).collect() to prevent panic when MAX_PROMPT_LENGTH falls inside a multi-byte UTF-8 character. Adds test_sanitize_multibyte_boundary to verify correct behaviour.
- Redirect all command output through tee to build-output.log - ADF agent runner truncates stderr at ~8KB, hiding clippy/build/test results - Fix parse_build_md: was concatenating lines without newlines - BUILD_LOG set to $ADF_WORKING_DIR/build-output.log per run Refs #1721
- Add project.rs with discover() function that walks up from cwd to find .terraphim/ - Change global_shortcut from String to Option<String> in Config - Add merge_with() and with_project() methods to ConfigBuilder - Update TuiService::new to accept no_project_config parameter - Add merge_project_config() helper that discovers and merges project config - Update all call sites and tests to use new signatures Refs #1674
- Add project.rs with discover() function that walks up from cwd to find .terraphim/ - Change global_shortcut from String to Option<String> in Config - Add merge_with() and with_project() methods to ConfigBuilder - Update TuiService::new to accept no_project_config parameter - Add merge_project_config() helper that discovers and merges project config - Update all call sites and tests to use new signatures Refs #1674
- cargo clippy -D warnings caught &real.join() where real.join() works - Affects create_dir_all and canonicalize calls in test Refs #1721
# Conflicts: # crates/terraphim_config/src/project.rs
…ld-runner fixes - Replace byte-indexed prompt truncation with .chars().take() to prevent UTF-8 byte-boundary panic in sanitize_system_prompt (Fixes #1721) - Add test_sanitize_multibyte_boundary test for char-safe truncation - Implement project-level config discovery for .terraphim/ directories - Fix build-runner-llm.sh: pipefail for correct exit codes, tee output to build-output.log (ADF truncates stderr), fix parse_build_md command extraction - Fix clippy warnings: needless_borrows_for_generic_args in project.rs, unnecessary_cast in llm_bridge.rs, field-reassign-with-default in config - Revert incorrect TuiService::new(None, false) to TuiService::new(None) - Fix global_shortcut Option<String> consistency across test files - Mark LLM bridge integration tests as #[ignore] (require live client) Refs #1721
Refs: release v2026.05.19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Security fix for UTF-8 boundary panic in
sanitize_system_prompt.Changes
Root Cause
The
sanitize_system_promptfunction was using byte-indexed truncation which could cause UTF-8 multibyte characters to be split, potentially exposing internal state or causing panics.Fix
Replace byte-indexed truncation with char-safe truncation that properly handles multibyte UTF-8 characters.
Related