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

2.5.2 #884

Merged
merged 63 commits into from
Jan 31, 2023
Merged

2.5.2 #884

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4337389
feat(api return): full error detail when auth failed
nannan00 Nov 17, 2022
1cf5e12
Merge pull request #801 from nannan00/ft_auth_exception_full_detail
nannan00 Nov 18, 2022
c1c467b
test(unittest): fix #747 (#789)
wklken Nov 18, 2022
54456c2
feat(src/build): merge build files from another repo
wklken Nov 21, 2022
c426319
Merge pull request #806 from wklken/ft_merge_build_files
wklken Nov 21, 2022
fcdc18c
fix: 修复 xss 攻击漏洞 #796
yuri0528 Nov 21, 2022
cb57bff
fix(profile/create): fail when got no settings of expired_after_days
wklken Nov 21, 2022
1b8a27b
feat(wsgi/faulthandler): enable faulthandler in wsgi.py (#805)
wklken Nov 22, 2022
57f49a3
Merge pull request #809 from wklken/fix_profile_celery_task
wklken Nov 22, 2022
d1b2905
fix(audit/export): export fail when got ugettext_lazy
wklken Nov 23, 2022
cc41f04
Merge pull request #814 from wklken/fix_audit_login_log
wklken Nov 23, 2022
12b07d6
fix: xss 写入时转换数据
yuri0528 Nov 23, 2022
edb7de2
fix: 用户信息转译
yuri0528 Nov 25, 2022
110006d
Merge pull request #817 from yuri0528/yutyi/bug-xss-2
wklken Nov 28, 2022
003ae19
fix: 修复职务显示问题 #820
yuri0528 Dec 5, 2022
48a686f
feat: 本地目录导入excel支持选择更新 #728 (#813)
Canway-shiisa Dec 6, 2022
1f5bec1
fix:lint check #issue728
Canway-shiisa Dec 6, 2022
d63b6c4
Merge pull request #826 from Canway-shiisa/pre_2.5.2-fix-lint
wklken Dec 6, 2022
4ba9f2f
feat: 登录密码试错锁定机制取消对admin用户豁免 #810
Canway-shiisa Dec 6, 2022
f3fe95d
Merge pull request #827 from Canway-shiisa/pre_2.5.2-issue810
wklken Dec 6, 2022
481626e
fix: mypy check #728
Canway-shiisa Dec 7, 2022
ba7b72c
Merge pull request #828 from Canway-shiisa/pre_2.5.2-fix-mypy
wklken Dec 7, 2022
bcb724b
feature: 页面操作密码重置,rsa加密 (#818)
neronkl Dec 7, 2022
324d10a
ci(github_action): enable check for pre_*
wklken Dec 7, 2022
f09160d
Merge pull request #829 from wklken/ft_github_action_trigger
wklken Dec 7, 2022
ccc1477
fix: 修复失效toml文件;mypy check failed (#830)
neronkl Dec 7, 2022
0287c71
feat: 导出增加<全名> #618 (#835)
Canway-shiisa Dec 9, 2022
ffaa738
fix: xss校验优化
yuri0528 Dec 12, 2022
4246028
feat: check old password for admin #811 (#840)
Canway-shiisa Dec 14, 2022
b57b90a
feature: admin账户重置密码需要先输入原密码进行校验 #811
Dec 14, 2022
4989e36
fix: slz 转义display_name (#846)
neronkl Dec 15, 2022
7ef6234
feature: 支持密码重置可选择短信验证方式 #631 (#849)
caohua Dec 16, 2022
0a8c842
Revert "feature: 支持密码重置可选择短信验证方式 #631 (#849)" (#850)
wklken Dec 16, 2022
9d0e1bf
Revert "feature: admin账户重置密码需要先输入原密码进行校验 #811" (#852)
wklken Dec 16, 2022
42e889a
feature: 支持密码重置可选择短信验证方式 #631 (#854)
caohua Dec 16, 2022
a11c21c
feature: 1、审计日志中新增人员全名列&导出列表优化 #618 2、通过excel导入用户组织支持全量更新 #728 (#855)
caohua Dec 16, 2022
92a6894
feature: admin账户重置密码需要先输入原密码进行校验 #811 (#856)
caohua Dec 16, 2022
3f22a86
feat: rsa 前端加密 #808
yuri0528 Nov 25, 2022
de6e9e4
feature: 忘记密码支持手机号验证,进行密码重置 # issue631 (#837)
neronkl Dec 19, 2022
496a561
feat:rsa 前端加密优化
yuri0528 Dec 19, 2022
4c372cc
fix(src/build): support binary version redis
wklken Dec 21, 2022
0cc6b6e
Merge pull request #860 from wklken/fix_binary_redis
wklken Dec 21, 2022
61e3ef4
fix(poetry.lock): update
wklken Dec 21, 2022
9e2f277
Merge pull request #861 from wklken/fix_poetry_loc
wklken Dec 21, 2022
179c781
fix: Saas层补充代理接口,增加相关接口的免登陆白名单
neronkl Dec 21, 2022
5123191
Merge pull request #862 from neronkl/fix_saas
wklken Dec 21, 2022
4ca8466
docs(changelog): update to 2.5.2
wklken Dec 30, 2022
d6d50e6
Merge pull request #866 from wklken/fix_2.5.2_version
wklken Dec 30, 2022
af8bc27
fix: 修复侧边栏展示空白问题 & 更改文件头
yuri0528 Jan 4, 2023
2c1100a
fix: 前端国际化补充 (#867)
neronkl Jan 9, 2023
32a1663
fix: 目录meta list接口rsa设置不返回 (#868)
neronkl Jan 9, 2023
f406adf
fix: 修复点击忘记,需进行登录态校验 (#869)
neronkl Jan 9, 2023
e2e1098
fix: 搜索前端展示空白/错乱 #875 (#877)
yuri0528 Jan 10, 2023
46bcd4f
fix(audit/login): fix #876 login audit log login_time not local time …
wklken Jan 10, 2023
091fc90
fix: 前端交互问题修复 #879 (#880)
yuri0528 Jan 11, 2023
c62aba6
fix(poetry): update (#881)
wklken Jan 11, 2023
00c15ae
refactor: 变更重置密码验证码短信文案 (#882)
neronkl Jan 12, 2023
9e4686e
fix(reset_password/sms): tempalte wrong (#883)
wklken Jan 13, 2023
5903a0f
Merge pull request #807 from TencentBlueKing/pre_2.5.2
wklken Jan 13, 2023
df2648d
fix: 修改密码报错问题修复
yuri0528 Jan 13, 2023
f4ad978
Merge pull request #886 from yuri0528/dev/bugfix
wklken Jan 30, 2023
8d36ca6
fix(saas/search): fix profiles/search response userinfo miss account_…
wklken Jan 30, 2023
be952b8
fix(.github/actions): upgrade ubuntu (#891)
wklken Jan 31, 2023
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
12 changes: 6 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ master, develop ]
schedule:
- cron: '22 11 * * 4'

Expand All @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
21 changes: 0 additions & 21 deletions .github/workflows/eslint.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ESLint

on:
push:
branches: [ master, develop, pre_*, ft_* ]
pull_request:
branches: [ master, develop, pre_*, ft_* ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: 'src/pages/yarn.lock'
- name: Install modules
run: |
cd src/pages
npm i
- name: Run ESLint
run: |
cd src/pages
npx eslint --ext .js,.vue src/
23 changes: 12 additions & 11 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Python CI Check

on:
push:
branches: [ master, develop ]
branches: [ master, develop, pre_*, ft_* ]
pull_request:
branches: [ master, develop ]
branches: [ master, develop, pre_*, ft_* ]

jobs:
build:
Expand All @@ -14,23 +14,24 @@ jobs:
matrix:
python-version: [3.6.14]
poetry-version: [1.1.7]
os: [ubuntu-18.04]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- name: Export requirements.txt
run: poetry export -f requirements.txt --dev --without-hashes -o requirements.txt --no-ansi
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install dependencies
run: poetry config virtualenvs.create false && poetry install
run: pip install -r requirements.txt -i https://pypi.org/simple/
- name: Lint with flake8
run: pflake8 src/ --config=pyproject.toml
- name: Lint with mypy
run: mypy src/ --config-file=pyproject.toml

24 changes: 14 additions & 10 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Unittest

on:
push:
branches: [ master, develop ]
branches: [ master, develop, pre_*, ft_* ]
pull_request:
branches: [ master, develop ]
branches: [ master, develop, pre_*, ft_* ]

jobs:
build:
Expand All @@ -13,7 +13,7 @@ jobs:
matrix:
python-version: [3.6.14]
poetry-version: [1.1.7]
os: [ubuntu-18.04]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}

env:
Expand All @@ -23,26 +23,30 @@ jobs:
DB_PORT: 3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: samin/[email protected]
with:
mysql version: '5.7'
mysql database: ${{ env.DB_DATABASE }}
mysql root password: ${{ env.DB_PASSWORD }}
mysql user: ${{ env.DB_USER }}
mysql password: ${{ env.DB_PASSWORD }}
- name: Install poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- name: Export requirements.txt
run: |
cd src/api/
bash bin/export_requirements_txt.sh
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
cache: 'pip'
cache-dependency-path: 'src/api/requirements.txt'
- name: Install dependencies
run: |
cd src/api/
poetry config virtualenvs.create false && bash bin/install_ci_dependencies.sh
pip install -r requirements.txt -i https://pypi.org/simple/
- name: Run api unittest
env:
DJANGO_SETTINGS_MODULE: "bkuser_core.config.overlays.unittest"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generate-release-md:
mv src/saas/release.md docs/

test:
cd src/api && source ./test_env.sh && poetry run pytest bkuser_core/tests --disable-pytest-warnings
cd src/api && export DJANGO_SETTINGS_MODULE="bkuser_core.config.overlays.unittest" && poetry run pytest bkuser_core/tests --disable-pytest-warnings

link:
rm src/api/bkuser_global || true
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "蓝鲸用户管理"
version = "2.3.3"
description = "project description file for ci"
authors = ["IMBlues <bluesedenyu@gmail.com>"]
authors = ["TencentBlueKing <contactus_bk@tencent.com>"]

[tool.poetry.dependencies]
python = "3.6.14"
python = "^3.8"
apigw-manager = "^1.0.3"

[tool.poetry.dev-dependencies]
Expand All @@ -14,8 +14,8 @@ black = "^22.3.0"
# isort
isort = "^5.9.2"
# flake8
pyproject-flake8 = "^0.0.1-alpha.2"
flake8-comprehensions = "^3.5.0"
pyproject-flake8 = "0.0.1-alpha.2"
flake8-comprehensions = "3.5.0"
# pytest
pytest = "^6.2.4"
pytest-django = "^3.9.0"
Expand All @@ -39,6 +39,7 @@ exclude = '''
| .+/migrations
| .+/sdk
| .+/node_modules
| .+/build
)/
'''

Expand All @@ -59,7 +60,7 @@ format = "pylint"
show_source = "true"
statistics = "true"
count = "true"
exclude = "*migrations*,*.pyc,.git,__pycache__,*/node_modules/*,*/templates_module*,*/bin/*,*/config/*,*sdk*"
exclude = "*migrations*,*.pyc,.git,__pycache__,*/node_modules/*,*/templates_module*,*/bin/*,*/config/*,*sdk*,*build*"

[tool.mypy]
ignore_missing_imports = true
Expand All @@ -70,6 +71,7 @@ pretty=true
exclude = '''(?x)(
instrumentor\.py$
| otel\.py$
| src/build/.*\.py$
)'''

[[tool.mypy.overrides]]
Expand All @@ -78,5 +80,6 @@ module = [
"*.config.*",
"bkuser_sdk.*",
"*.bkuser_sdk.*",
"*.build.*",
]
ignore_errors = true
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ sed -i '/^--extra-index-url*/d' requirements.txt
sed -i '/gevent/d' requirements.txt
sed -i '/greenlet/d' requirements.txt
sed -i '/gunicorn/d' requirements.txt

pip install -r requirements.txt -i https://pypi.org/simple/
2 changes: 2 additions & 0 deletions src/api/bkuser_core/api/login/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Meta:
"status",
"time_zone",
"language",
"domain",
"category_id",
# NOTE: 这里缩减登陆成功之后的展示字段
# "position",
# "logo_url", => to logo?
Expand Down
4 changes: 2 additions & 2 deletions src/api/bkuser_core/api/login/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def login(self, request):

time_aware_now = now()
config_loader = ConfigProvider(category_id=category.id)
# Admin 用户只需直接判断 密码是否正确 (只有本地目录有密码配置)
if not profile.is_superuser and category.type in [CategoryType.LOCAL.value]:
# 由于安全检测等原因,取消原先对admin用户的检查豁免
if category.type in [CategoryType.LOCAL.value]:

# 判断账户状态
if profile.status in [
Expand Down
15 changes: 12 additions & 3 deletions src/api/bkuser_core/api/web/audit/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import datetime
from typing import Optional

from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers

from .constants import LOGIN_FAILED_REASON_MAP, OPERATION_ABOUT_PASSWORD, OPERATION_NAME_MAP, OPERATION_OBJ_NAME_MAP
from bkuser_core.profiles.models import Profile

PLACE_HOLDER = "--"

Expand All @@ -35,6 +37,7 @@ class GeneralLogListInputSLZ(LogListInputSLZ):
class GeneralLogOutputSLZ(serializers.Serializer):
id = serializers.IntegerField(help_text=_("ID"))
extra_value = serializers.JSONField(help_text=_("额外信息"))
display_name = serializers.CharField(help_text=_("用户全名"), read_only=True)
operator = serializers.CharField(help_text=_("操作者"))
create_time = serializers.DateTimeField(help_text=_("创建时间"))
status = serializers.CharField(help_text=_("状态"))
Expand All @@ -57,12 +60,15 @@ def to_representation(self, obj):

category_id = extra_value.get("category_id")
category_display_name = category_name_map.get(category_id, PLACE_HOLDER)
operator_profile = Profile.objects.filter(username=obj.operator).first()
display_name = operator_profile.display_name if operator_profile else ""

return {
"datetime": datetime.datetime.strptime(instance["create_time"], "%Y-%m-%dT%H:%M:%S.%fZ"),
"operator": instance["operator"],
"target_obj": instance["target_obj"],
"category_display_name": category_display_name,
"display_name": display_name,
"operation": instance["operation"],
"client_ip": extra_value.get("client_ip", PLACE_HOLDER),
}
Expand All @@ -79,14 +85,16 @@ class LoginLogOutputSLZ(serializers.Serializer):
# datetime = serializers.CharField(source="create_time", help_text=_("登录时间"), required=False)
is_success = serializers.BooleanField(help_text=_("是否登录成功"), required=False)
username = serializers.CharField(help_text=_("登录用户"), source="profile.username")

display_name = serializers.CharField(help_text=_("用户全名"), source="profile.display_name")
datetime = serializers.SerializerMethodField(help_text=_("登录时间"), required=False)
category_display_name = serializers.SerializerMethodField(help_text=_("所属目录"), required=False)
client_ip = serializers.SerializerMethodField(help_text=_("客户端 IP"), required=False)
reason = serializers.SerializerMethodField(help_text=_("失败原因"), required=False)

def get_datetime(self, obj):
return obj.create_time
# 转换成本地时间
local_time = timezone.localtime(obj.create_time)
return local_time.strftime("%Y-%m-%d %H:%M:%S")

def get_reason(self, obj) -> Optional[str]:
"""get reason display name"""
Expand Down Expand Up @@ -132,7 +140,8 @@ def get_reason(self, obj) -> Optional[str]:
"""get reason display name"""
if obj.is_success:
return None
return LOGIN_FAILED_REASON_MAP.get(obj.reason, _("未知失败原因"))
# bugfix: ugettext_lazy
return str(LOGIN_FAILED_REASON_MAP.get(obj.reason, _("未知失败原因")))

def get_datetime(self, obj):
return obj.create_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
4 changes: 4 additions & 0 deletions src/api/bkuser_core/api/web/category/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class CategoryFileImportInputSLZ(serializers.Serializer):
file = serializers.FileField(required=False)


class CategoryFileImportQuerySLZ(serializers.Serializer):
is_overwrite = serializers.BooleanField(required=False, default=False)


class CategorySyncResponseOutputSLZ(serializers.Serializer):
task_id = serializers.CharField(help_text="task_id for the sync job.")

Expand Down
Loading