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