mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-23 00:38:39 +00:00
feat: 站内信 (#6183)
* 添加站内信 * s * s * 添加接口 * fix * fix * 重构了一些 * 完成 * 完善 * s * s * s * s * s * s * 测试ok * 替换业务中发送消息的方式 * 修改 * s * 去掉 update 兼容 create * 添加 unread total 接口 * 调整json字段 Co-authored-by: xinwen <coderWen@126.com>
This commit is contained in:
@@ -68,78 +68,6 @@ def get_session_replay_url(session):
|
||||
return local_path, url
|
||||
|
||||
|
||||
def send_command_alert_mail(command):
|
||||
session_obj = Session.objects.get(id=command['session'])
|
||||
|
||||
input = command['input']
|
||||
if isinstance(input, str):
|
||||
input = input.replace('\r\n', ' ').replace('\r', ' ').replace('\n', ' ')
|
||||
|
||||
subject = _("Insecure Command Alert: [%(name)s->%(login_from)s@%(remote_addr)s] $%(command)s") % {
|
||||
'name': command['user'],
|
||||
'login_from': session_obj.get_login_from_display(),
|
||||
'remote_addr': session_obj.remote_addr,
|
||||
'command': input
|
||||
}
|
||||
|
||||
recipient_list = settings.SECURITY_INSECURE_COMMAND_EMAIL_RECEIVER.split(',')
|
||||
message = _("""
|
||||
Command: %(command)s
|
||||
<br>
|
||||
Asset: %(host_name)s (%(host_ip)s)
|
||||
<br>
|
||||
User: %(user)s
|
||||
<br>
|
||||
Level: %(risk_level)s
|
||||
<br>
|
||||
Session: <a href="%(session_detail_url)s">session detail</a>
|
||||
<br>
|
||||
""") % {
|
||||
'command': command['input'],
|
||||
'host_name': command['asset'],
|
||||
'host_ip': session_obj.asset_obj.ip,
|
||||
'user': command['user'],
|
||||
'risk_level': Command.get_risk_level_str(command['risk_level']),
|
||||
'session_detail_url': reverse('api-terminal:session-detail',
|
||||
kwargs={'pk': command['session']},
|
||||
external=True, api_to_ui=True),
|
||||
}
|
||||
logger.debug(message)
|
||||
|
||||
send_mail_async.delay(subject, message, recipient_list, html_message=message)
|
||||
|
||||
|
||||
def send_command_execution_alert_mail(command):
|
||||
subject = _("Insecure Web Command Execution Alert: [%(name)s]") % {
|
||||
'name': command['user'],
|
||||
}
|
||||
input = command['input']
|
||||
input = input.replace('\n', '<br>')
|
||||
recipient_list = settings.SECURITY_INSECURE_COMMAND_EMAIL_RECEIVER.split(',')
|
||||
|
||||
assets = ', '.join([str(asset) for asset in command['assets']])
|
||||
message = _("""
|
||||
<br>
|
||||
Assets: %(assets)s
|
||||
<br>
|
||||
User: %(user)s
|
||||
<br>
|
||||
Level: %(risk_level)s
|
||||
<br>
|
||||
|
||||
----------------- Commands ---------------- <br>
|
||||
%(command)s <br>
|
||||
----------------- Commands ---------------- <br>
|
||||
""") % {
|
||||
'command': input,
|
||||
'assets': assets,
|
||||
'user': command['user'],
|
||||
'risk_level': Command.get_risk_level_str(command['risk_level']),
|
||||
}
|
||||
|
||||
send_mail_async.delay(subject, message, recipient_list, html_message=message)
|
||||
|
||||
|
||||
class ComputeStatUtil:
|
||||
# system status
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user