From b7ad6cfe6238829434005629b76bc5c3452bb609 Mon Sep 17 00:00:00 2001
From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com>
Date: Thu, 25 Apr 2019 18:16:41 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E9=98=B2=E6=AD=A2=20XSS=20(#263?=
=?UTF-8?q?3)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* [Bugfix] 修改管理用户列表显示bug
* [Bugfix] 修复刷新批量命令页面的bug
* [Update] 防止 XSS
---
apps/assets/templates/assets/admin_user_assets.html | 1 +
apps/assets/templates/assets/admin_user_list.html | 2 +-
apps/assets/templates/assets/asset_list.html | 1 +
apps/assets/templates/assets/cmd_filter_list.html | 1 +
apps/assets/templates/assets/domain_list.html | 1 +
apps/assets/templates/assets/label_list.html | 1 +
apps/assets/templates/assets/system_user_asset.html | 1 +
apps/assets/templates/assets/system_user_list.html | 1 +
apps/common/const.py | 4 ++--
apps/ops/templates/ops/command_execution_create.html | 4 ++++
apps/perms/templates/perms/asset_permission_list.html | 1 +
apps/templates/_message.html | 3 ++-
apps/terminal/templates/terminal/terminal_list.html | 1 +
apps/users/templates/users/user_granted_asset.html | 4 +++-
apps/users/templates/users/user_group_granted_asset.html | 4 +++-
apps/users/templates/users/user_group_list.html | 2 ++
apps/users/templates/users/user_list.html | 1 +
17 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/apps/assets/templates/assets/admin_user_assets.html b/apps/assets/templates/assets/admin_user_assets.html
index d22c5406f..c893ead80 100644
--- a/apps/assets/templates/assets/admin_user_assets.html
+++ b/apps/assets/templates/assets/admin_user_assets.html
@@ -98,6 +98,7 @@ function initTable() {
order: [],
columnDefs: [
{targets: 0, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/assets/templates/assets/admin_user_list.html b/apps/assets/templates/assets/admin_user_list.html
index 9b14a3d9c..605e89060 100644
--- a/apps/assets/templates/assets/admin_user_list.html
+++ b/apps/assets/templates/assets/admin_user_list.html
@@ -91,7 +91,7 @@ $(document).ready(function(){
}}],
ajax_url: '{% url "api-assets:admin-user-list" %}',
columns: [{data: function(){return ""}}, {data: "name"}, {data: "username" }, {data: "assets_amount" },
- {data: "reachable_amount"}, {data: "unreachable_amount"}, {data: "id"}, {data: "comment"}]
+ {data: "reachable_amount"}, {data: "unreachable_amount"}, {data: "id"}, {data: "comment"}, {data: "id"}]
};
jumpserver.initServerSideDataTable(options)
})
diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html
index 8adc81de9..aa27de7a8 100644
--- a/apps/assets/templates/assets/asset_list.html
+++ b/apps/assets/templates/assets/asset_list.html
@@ -156,6 +156,7 @@ function initTable() {
ele: $('#asset_list_table'),
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
{% url 'assets:asset-detail' pk=DEFAULT_PK as the_url %}
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
diff --git a/apps/assets/templates/assets/cmd_filter_list.html b/apps/assets/templates/assets/cmd_filter_list.html
index 3a4feeae0..c7f8e7d3e 100644
--- a/apps/assets/templates/assets/cmd_filter_list.html
+++ b/apps/assets/templates/assets/cmd_filter_list.html
@@ -40,6 +40,7 @@ function initTable() {
ele: $('#cmd_filter_list_table'),
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/assets/templates/assets/domain_list.html b/apps/assets/templates/assets/domain_list.html
index a0c6e869e..5cd717535 100644
--- a/apps/assets/templates/assets/domain_list.html
+++ b/apps/assets/templates/assets/domain_list.html
@@ -41,6 +41,7 @@ function initTable() {
ele: $('#domain_list_table'),
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/assets/templates/assets/label_list.html b/apps/assets/templates/assets/label_list.html
index d2fa9958a..3cb90788a 100644
--- a/apps/assets/templates/assets/label_list.html
+++ b/apps/assets/templates/assets/label_list.html
@@ -30,6 +30,7 @@ function initTable() {
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
{# var detail_btn = '' + cellData + '';#}
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/assets/templates/assets/system_user_asset.html b/apps/assets/templates/assets/system_user_asset.html
index 4ffdf2a91..082e13fd8 100644
--- a/apps/assets/templates/assets/system_user_asset.html
+++ b/apps/assets/templates/assets/system_user_asset.html
@@ -144,6 +144,7 @@ function initAssetsTable() {
order: [],
columnDefs: [
{targets: 0, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/assets/templates/assets/system_user_list.html b/apps/assets/templates/assets/system_user_list.html
index 6ed0d0d26..b31039a46 100644
--- a/apps/assets/templates/assets/system_user_list.html
+++ b/apps/assets/templates/assets/system_user_list.html
@@ -49,6 +49,7 @@ function initTable() {
ele: $('#system_user_list_table'),
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
+ cellData = htmlEscape(cellData);
var detail_btn = '' + cellData + '';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}},
diff --git a/apps/common/const.py b/apps/common/const.py
index 6652593cb..018177d89 100644
--- a/apps/common/const.py
+++ b/apps/common/const.py
@@ -3,7 +3,7 @@
from django.utils.translation import ugettext_lazy as _
-create_success_msg = _("%(name)s was created successfully")
-update_success_msg = _("%(name)s was updated successfully")
+create_success_msg = _("%(name)s was created successfully")
+update_success_msg = _("%(name)s was updated successfully")
FILE_END_GUARD = ">>> Content End <<<"
celery_task_pre_key = "CELERY_"
diff --git a/apps/ops/templates/ops/command_execution_create.html b/apps/ops/templates/ops/command_execution_create.html
index 8352d1607..4aaee0406 100644
--- a/apps/ops/templates/ops/command_execution_create.html
+++ b/apps/ops/templates/ops/command_execution_create.html
@@ -82,6 +82,7 @@