-
Notifications
You must be signed in to change notification settings - Fork 2
Update theme formatting and add tests #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| *.o | ||
| build/ | ||
| *.test | ||
| *.test | ||
| *.dSYM/ | ||
| nutshell |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,8 @@ Theme* create_test_theme() { | |
| // Directory segment | ||
| theme->segments[0] = calloc(1, sizeof(ThemeSegment)); | ||
| theme->segments[0]->enabled = true; | ||
| theme->segments[0]->key = strdup("directory"); // Add this line to set the segment key | ||
| theme->segments[0]->format = strdup("{directory}"); | ||
|
|
||
| // New format with multiple commands | ||
| theme->segments[0]->command_count = 1; | ||
| theme->segments[0]->commands = calloc(2, sizeof(ThemeCommand*)); // +1 for NULL terminator | ||
|
|
@@ -61,6 +61,7 @@ Theme* create_test_theme() { | |
| theme->segments[1] = calloc(1, sizeof(ThemeSegment)); | ||
| theme->segments[1]->enabled = true; | ||
| // Use git_info as the segment key to match prompt format | ||
| theme->segments[1]->key = strdup("git_info"); // Set key to match prompt format | ||
| theme->segments[1]->format = strdup("{secondary}git:({branch}){dirty_flag}{reset}"); | ||
|
Comment on lines
63
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainInconsistency between test and default theme segment keys There's a naming inconsistency between the test theme and the default theme JSON. The test uses 🏁 Script executed: #!/bin/bash
# Check for inconsistencies between test theme and default theme JSON
echo "Checking segment key naming in default.json:"
grep -A 5 "segments" themes/default.json | grep -A 10 "git"
echo "Checking left prompt format in default.json:"
grep -A 3 "left" themes/default.json | grep "format"
echo "Comparing with test theme usage:"
grep -n "git_info" tests/test_theme.cLength of output: 991 Action Required: Align Git Key Naming Consistency The verification confirms that the test theme uses
This change will resolve the naming conflict between the test and the default theme. |
||
|
|
||
| theme->segments[1]->command_count = 2; | ||
|
|
@@ -271,7 +272,8 @@ int test_segment_commands() { | |
| printf("DEBUG: Theme segment count: %d\n", theme->segment_count); | ||
| printf("DEBUG: Left prompt format: '%s'\n", theme->left_prompt->format); | ||
| for (int i = 0; i < theme->segment_count; i++) { | ||
| printf("DEBUG: Segment %d format: '%s'\n", i, theme->segments[i]->format); | ||
| printf("DEBUG: Segment %d key: '%s', format: '%s'\n", i, | ||
| theme->segments[i]->key, theme->segments[i]->format); | ||
| } | ||
|
|
||
| // Test executing commands for a segment | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Risk of buffer overflow for long segment keys.
Using a fixed buffer (
char placeholder[256]) andsnprintf(placeholder, sizeof(placeholder), "{%s}", segment->key);risks truncation or buffer overflow if a malicious or accidentally large key is encountered. Consider either validating the maximum length ofsegment->keyor dynamically allocating the buffer.Please run the following script to see if there are any notes or constraints on the maximum key length in the codebase or related documentation:
🏁 Script executed:
Length of output: 486
Action Required: Mitigate Buffer Overflow Risk in
src/utils/theme.cThe investigation did not reveal any constraints on the length of
segment->keyanywhere in the codebase. As a result, using a fixed-size buffer (char placeholder[256]) for constructing the placeholder poses a real risk of data truncation and potential buffer overflow if a very long key is encountered.Recommended Actions:
segment->keybefore using it to format the placeholder.Implementing one of these measures will help eliminate the risk associated with processing unusually long segment keys.