Skip to content

Bound pre-commit hook reads when checking managed hook markers #2872

Description

@Widthdom

Summary

Hook install/status/uninstall paths read the entire pre-commit hook file to check whether it is managed by cdidx.

Evidence

src/CodeIndex/Cli/HookCommandRunner.cs calls File.ReadAllText(ioHookPath) and IsManagedHook(File.ReadAllText(ioHookPath)) when checking existing hooks. There is no file-size cap before reading the hook into memory.

Impact

A large pre-existing hook can make hook commands allocate excessive memory or take longer than necessary, even though cdidx only needs to detect a small managed marker.

Suggested fix

Check length before reading, or stream a bounded prefix/suffix sufficient to detect the managed marker. Keep behavior distinct from the separate atomic hook swap issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions