feat: add linux course diagnostics
This commit is contained in:
14
sandbox.py
14
sandbox.py
@@ -75,6 +75,17 @@ COMMAND_INDEX = {
|
||||
"python3": "/usr/bin/python3",
|
||||
}
|
||||
|
||||
SUPPORTED_COMMANDS = {
|
||||
"alias", "apt", "awk", "bash", "bc", "cat", "cd", "chmod", "chgrp", "chown",
|
||||
"clear", "cp", "crontab", "curl", "cut", "date", "df", "dig", "du", "echo",
|
||||
"env", "export", "fdisk", "find", "free", "grep", "head", "history", "id",
|
||||
"ifconfig", "ip", "journalctl", "kill", "last", "less", "ls", "lsof", "mkdir",
|
||||
"more", "mount", "mv", "netstat", "nohup", "passwd", "ping", "pkill", "ps",
|
||||
"pwd", "rm", "sed", "service", "sort", "ss", "stat", "su", "systemctl", "tail",
|
||||
"tar", "top", "touch", "traceroute", "uniq", "uptime", "vi", "vim", "w",
|
||||
"wc", "wget", "whereis", "which", "yum"
|
||||
}
|
||||
|
||||
|
||||
class LinuxSandbox:
|
||||
def __init__(self):
|
||||
@@ -121,6 +132,9 @@ class LinuxSandbox:
|
||||
node = self.get_node(self.resolve_path(path))
|
||||
return bool(node and len(node.get("perm", "")) >= 3 and node["perm"][2] == "1" or node and "x" in node.get("perm_human", ""))
|
||||
|
||||
def supported_commands(self) -> set[str]:
|
||||
return set(SUPPORTED_COMMANDS)
|
||||
|
||||
def _perm_human(self, perm: str, is_dir: bool) -> str:
|
||||
mapping = {
|
||||
"0": "---", "1": "--x", "2": "-w-", "3": "-wx",
|
||||
|
||||
Reference in New Issue
Block a user