-
Notifications
You must be signed in to change notification settings - Fork 27
Migrate to OpenAI-like API with enhanced security #3
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
base: main
Are you sure you want to change the base?
Conversation
…on validation - Add command sanitization to prevent shell injection attacks - Replace system() with popen() for safer command execution - Add validation for dangerous characters and shell constructs - Enhance configuration system with environment variable validation - Add proper error handling and buffer size checks - Improve JSON escaping to prevent injection attacks BREAKING CHANGE: Environment variable names changed from OR_KEY to OPENAI_KEY, and OPENAI_BASE and OPENAI_MODEL are now required
Replace OpenRouter integration with OpenAI API support, implement robust shell command sanitization, and introduce Napoleon Dynamite personality module. Add multi-step command chaining capabilities and update build configuration for new dependencies.
- Add GitHub Actions CI matrix build with basic tests - Add release workflow to build, checksum, and upload assets - Implement RAG via grep-based local context search - Add CLI args: --rag PATH and --rag-snippets N; env vars RAG_* - Integrate RAG snippets into user prompt when enabled - Add args.c and rag.c; extend Config with RAG fields - Move sources to src/ and update Makefile SOURCES - Escape control characters in JSON content - Secure temp files with 0600 and switch to exit() - Update README and relocate preview to docs/
… and RAG support - Add GitHub Actions CI matrix build with basic tests - Add release workflow to build, checksum, and upload assets - Implement RAG via grep-based local context search - Add CLI args: --rag PATH and --rag-snippets N; env vars RAG_* - Integrate RAG snippets into user prompt when enabled - Add args.c and rag.c; extend Config with RAG fields - Move sources to src/ and update Makefile SOURCES - Escape control characters in JSON content - Secure temp files with 0600 and switch to exit() - Update README and relocate preview to docs/
- Validate and sanitize path to prevent injection/traversal - Resolve paths with realpath and ensure they stay within CWD - Use resolved path in grep command - Add Windows realpath/getcwd shims and required headers
- Update Makefile to improve build flags and streamline Windows build process. - Implement platform-specific clean and install commands for better user experience. - Enhance command execution in agent.c with stricter sanitization and error handling. - Remove deprecated GitHub Actions CI workflow file. - Update README to reflect changes in API base URL and installation instructions.
- Simplify message array building logic in json_request() - Improve buffer size checking and error handling - Remove unnecessary compiled binary (agent-c.exe) - Enhance control character escaping efficiency - Add better memory management for JSON message construction
| if (!path || !query || !snippets || size == 0) return -1; | ||
|
|
||
| // Create temporary file for query | ||
| char query_file[] = "/tmp/rag_query_XXXXXX"; |
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.
Bug: Cross-Platform Temp Path Breaks Windows Compatibility
The search_rag_files function uses a hardcoded Unix-specific temporary file path (/tmp/rag_query_XXXXXX) for query files. This causes the function to fail on Windows systems, contradicting the codebase's general aim for cross-platform compatibility.
| src++; | ||
| } | ||
| continue; | ||
| } |
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.
Bug: Buffer overflow bug changes append to overwrite
In execute_command, the buffer boundary check for the >> operator is flawed. The check for space for the second > character happens after the first > is written, which can cause >> to be truncated to >. This changes command semantics from append to overwrite, risking data loss.
Replace OpenRouter integration with OpenAI-like API support, implement robust shell command sanitization, and introduce Napoleon Dynamite personality module. Add multi-step command chaining capabilities and update build configuration for new dependencies.
Note
Migrates to an OpenAI-compatible API, introduces local RAG search, strengthens shell command sanitization, and overhauls the cross‑platform build and configuration.
/v1/chat/completions) with configurableOPENAI_BASE,OPENAI_KEY, andOPENAI_MODEL.http_requestfor temp-file handling, API base normalization, and robust process exit checks.src/json.c.&&,>,>>; blocks expansions/quoting and dangerous chars).toolmessages.src/rag.c) with path validation and snippet limits.--ragand--rag-snippets; config via env (RAG_*).src/, addbuild/objects, and OS-specific targets (Windows/Linux/Darwin) with compression.RAG_ENABLED; enhanced CFLAGS/LDFLAGS; cross-platform compatibility macros in headers.OPENAI_KEY; addparse_args; maintain sliding window memory..gitignoreupdated to ignorebuild/.Written by Cursor Bugbot for commit 74e9cb5. This will update automatically on new commits. Configure here.