From c0cdccda15e895baa934f19021ecbbe06a661d10 Mon Sep 17 00:00:00 2001 From: Giveen Date: Sun, 14 Dec 2025 13:26:23 -0700 Subject: [PATCH] standardize parameter order - Fixed parameter order inconsistency in cat_file to match other filesystem tools (path first) - Added proper quoting around file paths to handle spaces and special characters - Standardized command construction across all filesystem functions - Improved documentation with consistent formatting and examples - Maintained integration with generic_linux_command's comprehensive security filtering - Enhanced usability while preserving existing security infrastructure --- src/cai/tools/reconnaissance/filesystem.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cai/tools/reconnaissance/filesystem.py b/src/cai/tools/reconnaissance/filesystem.py index 8f9f4c98..b85c1648 100644 --- a/src/cai/tools/reconnaissance/filesystem.py +++ b/src/cai/tools/reconnaissance/filesystem.py @@ -9,7 +9,7 @@ from cai.sdk.agents import function_tool def list_dir(path: str, args: str = "", ctf=None) -> str: """ List the contents of a directory. - by def . + Args: path: The directory path to list contents from args: Additional arguments to pass to the ls command @@ -17,7 +17,7 @@ def list_dir(path: str, args: str = "", ctf=None) -> str: Returns: str: The output of running the ls command """ - command = f'ls {path} {args}' + command = f'ls {args} "{path}"' return run_command(command, ctf=ctf) @function_tool @@ -26,13 +26,13 @@ def cat_file(file_path: str, args: str = "", ctf=None) -> str: Display the contents of a file. Args: - args: Additional arguments to pass to the cat command file_path: Path to the file to display contents of + args: Additional arguments to pass to the cat command Returns: str: The output of running the cat command """ - command = f'cat {args} {file_path} ' + command = f'cat {args} "{file_path}"' return run_command(command, ctf=ctf) @@ -60,6 +60,13 @@ def pwd_command(ctf=None) -> str: def find_file(file_path: str, args: str = "", ctf=None) -> str: """ Find a file in the filesystem. + + Args: + file_path: The search path or pattern to find files + args: Additional arguments to pass to the find command + + Returns: + str: The output of running the find command """ - command = f'find {file_path} {args}' + command = f'find {args} "{file_path}"' return run_command(command, ctf=ctf)