bash_commands.go

  1package tools
  2
  3import "runtime"
  4
  5var safeCommands = []string{
  6	// Bash builtins and core utils
  7	"cal",
  8	"date",
  9	"df",
 10	"du",
 11	"echo",
 12	"env",
 13	"free",
 14	"groups",
 15	"hostname",
 16	"id",
 17	"kill",
 18	"killall",
 19	"ls",
 20	"nice",
 21	"nohup",
 22	"printenv",
 23	"ps",
 24	"pwd",
 25	"set",
 26	"time",
 27	"timeout",
 28	"top",
 29	"type",
 30	"uname",
 31	"unset",
 32	"uptime",
 33	"whatis",
 34	"whereis",
 35	"which",
 36	"whoami",
 37
 38	// Git
 39	"git blame",
 40	"git branch",
 41	"git config --get",
 42	"git config --list",
 43	"git describe",
 44	"git diff",
 45	"git grep",
 46	"git log",
 47	"git ls-files",
 48	"git ls-remote",
 49	"git remote",
 50	"git rev-parse",
 51	"git shortlog",
 52	"git show",
 53	"git status",
 54	"git tag",
 55
 56	// Go
 57	"go build",
 58	"go clean",
 59	"go doc",
 60	"go env",
 61	"go fmt",
 62	"go help",
 63	"go install",
 64	"go list",
 65	"go mod",
 66	"go run",
 67	"go test",
 68	"go version",
 69	"go vet",
 70}
 71
 72func init() {
 73	if runtime.GOOS == "windows" {
 74		safeCommands = append(
 75			safeCommands,
 76			// Windows-specific commands
 77			"ipconfig",
 78			"nslookup",
 79			"ping",
 80			"systeminfo",
 81			"tasklist",
 82			"where",
 83		)
 84	}
 85}
 86
 87var bannedCommands = []string{
 88	// Network/Download tools
 89	"alias",
 90	"aria2c",
 91	"axel",
 92	"chrome",
 93	"curl",
 94	"curlie",
 95	"firefox",
 96	"http-prompt",
 97	"httpie",
 98	"links",
 99	"lynx",
100	"nc",
101	"safari",
102	"scp",
103	"ssh",
104	"telnet",
105	"w3m",
106	"wget",
107	"xh",
108
109	// System administration
110	"doas",
111	"su",
112	"sudo",
113
114	// Package managers
115	"apk",
116	"apt",
117	"apt-cache",
118	"apt-get",
119	"dnf",
120	"dpkg",
121	"emerge",
122	"home-manager",
123	"makepkg",
124	"opkg",
125	"pacman",
126	"paru",
127	"pkg",
128	"pkg_add",
129	"pkg_delete",
130	"portage",
131	"rpm",
132	"yay",
133	"yum",
134	"zypper",
135
136	// System modification
137	"at",
138	"batch",
139	"chkconfig",
140	"crontab",
141	"fdisk",
142	"mkfs",
143	"mount",
144	"parted",
145	"service",
146	"systemctl",
147	"umount",
148
149	// Network configuration
150	"firewall-cmd",
151	"ifconfig",
152	"ip",
153	"iptables",
154	"netstat",
155	"pfctl",
156	"route",
157	"ufw",
158}