Skip to content

Diff parser recompiles regex per call; plugin argument injection via file paths #80

@haasonsaas

Description

@haasonsaas

Found during deep review of diff parser and plugins

1. Regex compiled on every call in diff parser (MEDIUM, performance)

`src/core/diff_parser.rs`, lines 295, 448:

`extract_file_path` and `parse_hunk_header` compile their regex every invocation. For a 100-file PR with 500 hunks = 600 regex compilations. Every other regex in the codebase uses `Lazy`.

Fix: Use `once_cell::sync::Lazy` like the rest of the codebase.

2. Argument injection via crafted file paths to eslint/semgrep (MEDIUM)

`src/plugins/builtin/eslint.rs`, lines 56-69:

File paths from diffs are passed as arguments to `eslint`/`semgrep` via `Command::new().args()`. While `.args()` is safe against shell injection, a file named `--config=evil.js` would be interpreted as a flag by eslint, loading a malicious config.

Fix: Prefix file paths with `./` or use `--` separator before file arguments.

3. HTTP allowed for pattern repository clones (MEDIUM, security)

`is_safe_git_url` accepts `http://` URLs ending with `.git`. Plaintext git clone is MITM-able — an attacker could inject malicious patterns into the LLM review context.

Fix: Reject `http://` entirely, or at minimum warn loudly.

4. Pattern repository cache uses DefaultHasher (LOW)

Rust's `DefaultHasher` is not stable across compiler versions. Cache directories become orphaned on compiler updates. Use a stable hash (SHA-256, FNV).

5. `git pull --ff-only` failure silently ignored (LOW)

Non-zero exit code from `git pull` is not checked. Only command execution failure is logged. Stale pattern repos used without warning.

Acceptance

  • Regex uses `Lazy` in diff parser
  • File paths prefixed with `./` before passing to plugins
  • HTTP rejected for git clone
  • Stable hash for cache directories
  • Check exit code on git pull

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not workingperformancePerformance and resource optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions