Repository navigation
fix(auth): reject unreadable assistant headers instead of raising #1478 - #1480
Open
borealisalastor-byte wants to merge 1 commit into
Open
borealisalastor-byte wants to merge 1 commit into
borealisalastor-byte wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
common/core/deps.py::get_current_assistant读取X-SQLBOT-ASSISTANT-CERTIFICATE/X-SQLBOT-ASSISTANT-ONLINE时直接写到request.state.assistant上,没有判断这个助手身份是否存在:request.state.assistant)却带上证书头时,base_assistant为None,赋值抛AttributeError→ 500;b64decode/decode抛错 → 同样 500。改动
None,不再写属性;400(invalid assistant certificate),避免把客户端输入错误变成 500;online头逻辑等价改写,去掉一次多余的下标取值。验证(
cd backend后执行)pytest -q tests/test_assistant_request_headers.py→ 修复前 4 failed / 2 passed,修复后 6 passedNone;无助手身份 + online 头 →None;证书正常解码并unquote;TRUE归一为True;非法 base64(A)与非 UTF-8 内容(//4=)→ 400pytest -q tests --continue-on-collection-errors→ 383 passed;仅test_model_discovery.py::test_real_route_permission_and_safe_error因本机缺少sqlbot_xpack失败,与改动无关Fixes #1478