Skip to content

Fix security issues, reduce duplication, add Java tests, and reconcile agent instructions#36

Open
aseembits93 wants to merge 1 commit intomainfrom
fix/plugin-critique-improvements
Open

Fix security issues, reduce duplication, add Java tests, and reconcile agent instructions#36
aseembits93 wants to merge 1 commit intomainfrom
fix/plugin-critique-improvements

Conversation

@aseembits93
Copy link
Contributor

Summary

Addresses multiple issues identified in a code review of the plugin:

Security Fixes

  • Disable debug logging by default: set -x was unconditionally writing all execution traces (including env vars and API key checks) to a world-readable /tmp/codeflash-hook-debug.log. Now opt-in via CODEFLASH_HOOK_DEBUG=1.
  • Fix shell-to-Python injection in oauth-login.sh: All Python one-liners that interpolated bash variables directly into Python source code (e.g., json.load(open('${STATE_FILE}'))) now use sys.argv instead, preventing breakage or injection from paths containing quotes.

Refactoring

  • Extract append_auto_allow_msg() and emit_block() helpers: Eliminates 10 near-identical copies of the auto-allow message appending and JSON emission pattern throughout suggest-optimize.sh.
  • Rename CHANGED_COMMITSCHANGED_FILES: The variable holds file paths from --name-only, not commit hashes — the old name was misleading.
  • Quote paths in cd command strings: RUN_CMD="cd $PROJECT_DIR && ..." now quotes $PROJECT_DIR to handle paths with spaces.

Testing

  • Add Java project test coverage: 7 new test cases covering configured+installed, configured+not-installed, not-configured+installed, not-configured+not-installed, and auto-allow for Java projects. Includes new add_java_commit(), create_codeflash_toml(), and setup_mock_codeflash_bin() test helpers.

Documentation

  • Reconcile contradictory JS/TS setup instructions: The hook told Claude to "automatically determine" paths, while optimizer.md Step 3b said "ask the user two questions". Both now consistently auto-discover using Glob and Read.

Housekeeping

  • Add .idea/ and .claude/settings.local.json to .gitignore.

All 38 tests pass (7 find-venv + 31 suggest-optimize).

…e agent instructions

- Security: disable debug logging to /tmp by default (opt-in via CODEFLASH_HOOK_DEBUG=1)
- Security: fix shell-to-Python injection patterns in oauth-login.sh (use sys.argv instead of string interpolation)
- Refactor: extract append_auto_allow_msg() and emit_block() helpers to eliminate 10 copies of auto-allow message logic
- Refactor: rename misleading CHANGED_COMMITS variable to CHANGED_FILES
- Fix: quote paths in cd command strings to handle spaces
- Tests: add Java project test coverage (7 new test cases + helpers)
- Docs: reconcile contradictory JS/TS setup instructions between hook and agent (both now auto-discover)
- Housekeeping: add .idea/ and .claude/settings.local.json to .gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant