feat: 系统设置-安全设置 支持配置 作业中心命令黑名单

This commit is contained in:
fangfangdong
2023-05-31 17:16:48 +08:00
committed by Jiangjie.Bai
parent 51d6090fdc
commit a0bb25e558
7 changed files with 1089 additions and 1339 deletions

View File

@@ -9,9 +9,6 @@ from .callback import DefaultCallback
class AdHocRunner:
cmd_modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
cmd_blacklist = [
"reboot", 'shutdown', 'poweroff', 'halt', 'dd', 'half', 'top'
]
def __init__(self, inventory, module, module_args='', pattern='*', project_dir='/tmp/', extra_vars={},
dry_run=False, timeout=-1):
@@ -30,7 +27,7 @@ class AdHocRunner:
def check_module(self):
if self.module not in self.cmd_modules_choices:
return
if self.module_args and self.module_args.split()[0] in self.cmd_blacklist:
if self.module_args and self.module_args.split()[0] in settings.SECURITY_COMMAND_BLACKLIST:
raise Exception("command not allowed: {}".format(self.module_args[0]))
def run(self, verbosity=0, **kwargs):