refactor: 重构危险命令告警类型: Warning (#10970)

* refactor: 重构危险命令告警类型: Warning

* Update _msg_command_warning.html

* Update _msg_command_warning.html

* Update command.py

* Update django.po

* perf: 优化 command acl warning 的代码逻辑

* perf: 优化 command acl warning 的代码逻辑

* perf: 优化 CommandWarningMessage 逻辑

---------

Co-authored-by: fangfang.dong <fangfang.dong@fit2cloud.com>
Co-authored-by: Bai <baijiangjie@gmail.com>
This commit is contained in:
fit2bot
2023-07-17 20:52:54 +08:00
committed by GitHub
parent a2c6e5f3fb
commit 0771b804d1
8 changed files with 390 additions and 228 deletions

View File

@@ -27,6 +27,7 @@ from orgs.mixins.models import JMSOrgBaseModel
from perms.models import AssetPermission
from perms.utils import UserPermAssetUtil
from terminal.notifications import CommandExecutionAlert
from terminal.notifications import CommandWarningMessage
def get_parent_keys(key, include_self=True):
@@ -398,6 +399,16 @@ class JobExecution(JMSOrgBaseModel):
"user": self.creator,
}).publish_async()
raise Exception("command is rejected by ACL")
elif acl.is_action(CommandFilterACL.ActionChoices.warning):
# TODO: warning message
# user = ''
# command = {
# 'user': '',
# 'user_id': ''
# }
# CommandWarningMessage(user, command).publish_async()
return True
return False
def check_command_acl(self):