fix(exec): refine format command deny pattern to allow URL parameters
The previous regex r"(?:^|[;&|]\s*)format\b" incorrectly blocked commands containing URL parameters like &format=json. Added negative lookahead (?!=) so format= (URL param key=value) is allowed while standalone format commands (e.g. ;format, &format, |format) remain blocked. Added test cases for both blocking and allowing scenarios.
This commit is contained in:
@@ -106,7 +106,7 @@ class ExecTool(Tool):
|
||||
r"\brm\s+-[rf]{1,2}\b", # rm -r, rm -rf, rm -fr
|
||||
r"\bdel\s+/[fq]\b", # del /f, del /q
|
||||
r"\brmdir\s+/s\b", # rmdir /s
|
||||
r"(?:^|[;&|]\s*)format\b", # format (as standalone command only)
|
||||
r"(?:^|[;&|]\s*)format(?!=)\b", # format (as standalone command only)
|
||||
r"\b(mkfs|diskpart)\b", # disk operations
|
||||
r"\bdd\s+if=", # dd
|
||||
r">\s*/dev/sd", # write to disk
|
||||
|
||||
Reference in New Issue
Block a user