Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL权限申请“有效时间”字段值漏洞修复 #2818

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6ca8e7f
添加favicon图片
May 9, 2024
870ea4e
Merge branch 'master' of https://github.com/hhyo/Archery
May 10, 2024
d24784d
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 20, 2024
e80b335
firset
Jun 20, 2024
e4d02bb
修改
Jun 20, 2024
118504c
撤销
Jun 20, 2024
a4531d0
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 21, 2024
7c2fea5
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 27, 2024
64abe26
Merge branch 'master' of https://github.com/hhyo/Archery
Jul 31, 2024
bf3f327
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 7, 2024
d23edba
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 7, 2024
405b79e
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 14, 2024
36bdde6
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 16, 2024
75edaf7
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 16, 2024
44230c0
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 19, 2024
d9bea16
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 20, 2024
09834da
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 28, 2024
aee2867
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 30, 2024
dd0c01c
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 2, 2024
a769d28
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
c4734b7
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
1598adc
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
a7514d0
修复valid_date-bug
feiazifeiazi Sep 20, 2024
6684005
valid_date
feiazifeiazi Sep 20, 2024
6b9c7ee
检查申请账号是否已拥库查询权限 删除
feiazifeiazi Sep 20, 2024
1132f68
valid_date改为服务端计算
feiazifeiazi Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 44 additions & 28 deletions sql/query_privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@ def query_priv_apply(request):
valid_date = request.POST.get("valid_date")
limit_num = request.POST.get("limit_num")

# 用于存储计算后的新日期
new_valid_date = None
current_date = datetime.datetime.now()
if valid_date == "day":
new_valid_date = current_date + datetime.timedelta(days=1)
elif valid_date == "week":
new_valid_date = current_date + datetime.timedelta(days=7)
elif valid_date == "month":
new_valid_date = current_date + datetime.timedelta(days=30)
elif valid_date == "year":
new_valid_date = current_date + datetime.timedelta(days=365 * 1)
elif valid_date == "year2":
new_valid_date = current_date + datetime.timedelta(days=365 * 2)
else:
new_valid_date = current_date + datetime.timedelta(days=1)

# 获取用户信息
user = request.user

Expand Down Expand Up @@ -239,33 +255,33 @@ def query_priv_apply(request):

# 库权限
ins = Instance.objects.get(instance_name=instance_name)
if int(priv_type) == 1:
# 检查申请账号是否已拥库查询权限
for db_name in db_list:
if _db_priv(user, ins, db_name):
result["status"] = 1
result["msg"] = (
f"你已拥有{instance_name}实例{db_name}库权限,不能重复申请"
)
return HttpResponse(json.dumps(result), content_type="application/json")

# 表权限
elif int(priv_type) == 2:
# 先检查是否拥有库权限
if _db_priv(user, ins, db_name):
result["status"] = 1
result["msg"] = (
f"你已拥有{instance_name}实例{db_name}库的全部权限,不能重复申请"
)
return HttpResponse(json.dumps(result), content_type="application/json")
# 检查申请账号是否已拥有该表的查询权限
for tb_name in table_list:
if _tb_priv(user, ins, db_name, tb_name):
result["status"] = 1
result["msg"] = (
f"你已拥有{instance_name}实例{db_name}.{tb_name}表的查询权限,不能重复申请"
)
return HttpResponse(json.dumps(result), content_type="application/json")
# if int(priv_type) == 1:
# # 检查申请账号是否已拥库查询权限
# for db_name in db_list:
# if _db_priv(user, ins, db_name):
# result["status"] = 1
# result["msg"] = (
# f"你已拥有{instance_name}实例{db_name}库权限,不能重复申请"
# )
# return HttpResponse(json.dumps(result), content_type="application/json")

# # 表权限
# elif int(priv_type) == 2:
# # 先检查是否拥有库权限
# if _db_priv(user, ins, db_name):
# result["status"] = 1
# result["msg"] = (
# f"你已拥有{instance_name}实例{db_name}库的全部权限,不能重复申请"
# )
# return HttpResponse(json.dumps(result), content_type="application/json")
# # 检查申请账号是否已拥有该表的查询权限
# for tb_name in table_list:
# if _tb_priv(user, ins, db_name, tb_name):
# result["status"] = 1
# result["msg"] = (
# f"你已拥有{instance_name}实例{db_name}.{tb_name}表的查询权限,不能重复申请"
# )
# return HttpResponse(json.dumps(result), content_type="application/json")

apply_info = QueryPrivilegesApply(
title=title,
Expand All @@ -277,7 +293,7 @@ def query_priv_apply(request):
user_display=user.display,
instance=ins,
priv_type=int(priv_type),
valid_date=valid_date,
valid_date=new_valid_date,
status=WorkflowStatus.WAITING,
limit_num=limit_num,
)
Expand Down
16 changes: 1 addition & 15 deletions sql/templates/queryapplylist.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h4 class="modal-title" id="myModalLabel">申请数据库查询权限</h4>
<option value="week">一周</option>
<option value="month">一月</option>
<option value="year">长期(一年)</option>
<option value="year2">超长期(二年)</option>
</select>
</div>
<div class="form-group">
Expand Down Expand Up @@ -514,21 +515,6 @@ <h4 class="modal-title text-danger">工单日志</h4>

// 参数校验
if (applyvalidate()) {
//时间格式化
var date = new Date();
if (valid_date === 'day') {
valid_date = addDate(date, 1);

} else if (valid_date === 'week') {
valid_date = addDate(date, 7);
} else if (valid_date === 'month') {
valid_date = addDate(date, 30);
} else if (valid_date === 'year') {
valid_date = addDate(date, 365);
} else {
valid_date = addDate(date, 1);
}

//禁用按钮
$('button[type=button]').addClass('disabled');
$('button[type=button]').prop('disabled', true);
Expand Down
Loading