Skip to content

Commit c8c05b5

Browse files
committed
fix(alibaba): anchor token-plan host suffix and apply ruff format
Anchor the maas.aliyuncs.com suffix check on a leading dot so spoofed hosts (e.g. evilmaas.aliyuncs.com) no longer match the token-plan quota-skip path, resolving the CodeQL py/incomplete-url-substring- sanitization alert. Also wrap the long ALIBABA_TOKEN_PLAN_BASE_URL literal to satisfy ruff format.
1 parent dbdcd49 commit c8c05b5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/pythinker_code/auth/alibaba.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
ALIBABA_BASE_URL = "https://dashscope-us.aliyuncs.com/compatible-mode/v1"
2222
ALIBABA_CHINA_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
2323
# Shared international (Team Edition) Token Plan endpoint — the default for plan keys.
24-
ALIBABA_TOKEN_PLAN_BASE_URL = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
24+
ALIBABA_TOKEN_PLAN_BASE_URL = (
25+
"https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
26+
)
2527
ALIBABA_PROVIDER_KEY = managed_provider_key(ALIBABA_PLATFORM_ID)
2628
ALIBABA_DEFAULT_MODEL_ALIAS = f"{ALIBABA_PLATFORM_ID}/qwen3.7-plus"
2729
ALIBABA_DEFAULT_CONTEXT = 131_072

src/pythinker_code/ui/shell/usage_adapters/alibaba.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _endpoint_without_quota_api(base_url: str) -> bool:
5353
host = urlparse(base_url).netloc
5454
if host.startswith("coding") and "dashscope" in host:
5555
return True
56-
return host.startswith("token-plan") and host.endswith("maas.aliyuncs.com")
56+
return host.startswith("token-plan") and host.endswith(".maas.aliyuncs.com")
5757

5858

5959
def _parse_quota_response(data: object) -> list[UsageRow]:

0 commit comments

Comments
 (0)