mirror of https://github.com/jumpserver/jumpserver
feat: add organization details to command alert messages
parent
be7a4c0d6e
commit
caa675442a
|
@ -453,6 +453,8 @@ class JobExecution(JMSOrgBaseModel):
|
|||
"input": self.material,
|
||||
"risk_level": RiskLevelChoices.reject,
|
||||
"user": self.creator,
|
||||
'org_id': self.org_id,
|
||||
'_org_name': self.org_name,
|
||||
}).publish_async()
|
||||
raise Exception("command is rejected by ACL")
|
||||
elif acl.is_action(CommandFilterACL.ActionChoices.warning):
|
||||
|
@ -491,6 +493,8 @@ class JobExecution(JMSOrgBaseModel):
|
|||
"input": self.material,
|
||||
"risk_level": RiskLevelChoices.reject,
|
||||
"user": self.creator,
|
||||
'org_id': self.org_id,
|
||||
'_org_name': self.org_name,
|
||||
}).publish_async()
|
||||
raise CommandInBlackListException(
|
||||
"Command is rejected by black list: {}".format(self.current_job.args))
|
||||
|
|
|
@ -152,6 +152,8 @@ class CommandAlertMessage(CommandAlertMixin, SystemMessage):
|
|||
def gen_html_string(self, **other_context) -> dict:
|
||||
command = self.command
|
||||
level = RiskLevelChoices.get_label(command['risk_level'])
|
||||
org_id = command['org_id']
|
||||
org_name = command.get('_org_name') or org_id
|
||||
items = {
|
||||
_("Asset"): command['asset'],
|
||||
_("User"): command['user'],
|
||||
|
@ -161,6 +163,7 @@ class CommandAlertMessage(CommandAlertMixin, SystemMessage):
|
|||
context = {
|
||||
'items': items,
|
||||
"command": command['input'],
|
||||
'org': org_name,
|
||||
}
|
||||
context.update(other_context)
|
||||
message = render_to_string('terminal/_msg_command_alert.html', context)
|
||||
|
@ -212,7 +215,8 @@ class CommandExecutionAlert(CommandAlertMixin, SystemMessage):
|
|||
def gen_html_string(self, **other_context):
|
||||
command = self.command
|
||||
level = RiskLevelChoices.get_label(command['risk_level'])
|
||||
|
||||
org_id = command['org_id']
|
||||
org_name = command.get('_org_name') or org_id
|
||||
items = {
|
||||
_("User"): command['user'],
|
||||
_("Level"): level,
|
||||
|
@ -221,6 +225,7 @@ class CommandExecutionAlert(CommandAlertMixin, SystemMessage):
|
|||
context = {
|
||||
'items': items,
|
||||
'command': command['input'],
|
||||
'org': org_name,
|
||||
}
|
||||
context.update(other_context)
|
||||
message = render_to_string('terminal/_msg_command_execute_alert.html', context)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
{% endfor %}
|
||||
<b>{% trans 'Session' %}:</b> <a href="{{ session_url }}" target="_blank">{% trans 'view' %}</a>
|
||||
<br />
|
||||
<b>{% trans 'Organization' %}: </b> <span>{{ org }}</span>
|
||||
<br/>
|
||||
<b>{% trans 'Command' %}: </b><br />
|
||||
<pre>
|
||||
{{ command }}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
</span>
|
||||
<br />
|
||||
{% endfor %}
|
||||
<b>{% trans 'Organization' %}: </b> <span>{{ org }}</span>
|
||||
<br/>
|
||||
<b>{% trans 'Command' %}: </b><br />
|
||||
<pre>
|
||||
{{ command }}
|
||||
|
|
Loading…
Reference in New Issue