-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --unsafe mode, add barebone safe mode to LLDB/GDB.
Summary: Test Plan:
- Loading branch information
Showing
5 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import re | ||
|
||
|
||
# A very simple whitelist-based approach. | ||
# If ChatDBG wants to call other commands not listed here, they should be | ||
# evaluated and added if not possibly harmful. | ||
def command_is_safe(cmd: str) -> bool: | ||
cmd = cmd.strip() | ||
command_name = cmd.split()[0] | ||
|
||
# Allowed unconditionally. | ||
if command_name in [ | ||
"apropos", | ||
"bt", | ||
"down", | ||
"frame", | ||
"h", | ||
"help", | ||
"language", | ||
"l", | ||
"list", | ||
"source", | ||
"up", | ||
"version", | ||
]: | ||
return True | ||
|
||
# Allowed conditionally. | ||
if command_name in ["p", "print"]: | ||
return re.fullmatch(r"[a-zA-Z0-9_ *]+", cmd) is not None | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters