Skip to content

Commit 2204ab9

Browse files
committed
remove the complexity malicious commands validations
1 parent 61ec0d0 commit 2204ab9

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

codeflash/code_utils/code_utils.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,6 @@
1919
from codeflash.code_utils.config_parser import find_pyproject_toml, get_all_closest_config_files
2020
from codeflash.lsp.helpers import is_LSP_enabled
2121

22-
_DANGEROUS_PATTERNS = [
23-
"cd ",
24-
"ls ",
25-
"rm ",
26-
"mkdir ",
27-
"rmdir ",
28-
"del ",
29-
"dir ",
30-
"type ",
31-
"cat ",
32-
"echo ",
33-
"&&",
34-
"||",
35-
";",
36-
"|",
37-
">",
38-
"<",
39-
"$",
40-
"`",
41-
]
42-
43-
_DANGEROUS_PATTERNS_SET = set(_DANGEROUS_PATTERNS)
44-
45-
_DANGEROUS_PATTERNS_LOWER = tuple(pat.lower() for pat in _DANGEROUS_PATTERNS)
46-
4722
_INVALID_CHARS_NT = {"<", ">", ":", '"', "|", "?", "*"}
4823

4924
_INVALID_CHARS_UNIX = {"\0"}
@@ -427,11 +402,6 @@ def validate_relative_directory_path(path: str) -> tuple[bool, str]:
427402

428403
# Normalize whitespace
429404
path = path.strip()
430-
path_lower = path.lower()
431-
# Instead of for-loop, use generator with next() for early exit
432-
found_pattern = next((pattern for pattern in _DANGEROUS_PATTERNS_LOWER if pattern in path_lower), None)
433-
if found_pattern is not None:
434-
return False, f"Path contains invalid characters or commands: {found_pattern.strip()}"
435405

436406
# Check for path traversal attempts (cross-platform)
437407
# Normalize path separators for checking

0 commit comments

Comments
 (0)