Skip to content

Avoid shell execution in ReadFileTool ranged reads #5267

Description

@petrmarinec

Summary

ReadFileTool currently has two code paths:

  • full reads use environment.read_file(path) and slice/number lines in Python
  • ranged reads build and execute cat -n '{path}' | sed -n ...

That ranged-read branch shells out on caller-controlled path instead of reusing the normal file-read path.

Problem

Because path is interpolated into a shell command, filenames containing shell metacharacters are interpreted by the shell rather than treated as literal file paths. This also makes ranged reads behave differently from the default ReadFileTool path and introduces an unnecessary shell dependency into a read-oriented tool.

Expected behavior

ReadFileTool should read files through environment.read_file(...) for both full reads and ranged reads, and apply line slicing/numbering in Python.

Proposed fix

Remove the shell-based ranged-read branch and reuse the existing Python file-read logic for all reads.

Validation

I have a PR prepared that:

  • removes the shell-based ranged-read path
  • adds regression tests showing ranged reads no longer invoke execute()
  • confirms in Linux that a path payload that previously executed a proof command is now treated as a literal filename and does not write a proof file
  • passes pytest tests/unittests/tools

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

needs review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions