appbase/wwwroot/cron/switch_bizdate.dspy
yumoqing 21b4f0c3d8 security: switch_bizdate.dspy 校验补全 IPv6 + 拒绝时不回显 client_ip
原实现只认 127.0.0.1(漏 ::1),且校验失败时 return ip 把探测结果回显给调用方,
便于攻击者试探代理头处理方式。改为中性拒绝信息。
2026-08-25 15:01:22 +08:00

18 lines
713 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安全:定时任务入口(改全平台业务日期 business_date只允许本机调用。
# 校验失败不回显 client_ip原实现 `return ip` 把探测结果反馈给调用方,
# 便于攻击者试探代理头处理方式),统一返回中性拒绝信息。
ip = request.get('client_ip') or ''
if ip not in ('127.0.0.1', '::1', 'localhost'):
return 'Forbidden: 仅允许本机调用'
async with get_sor_context(request._run_ns, 'appbase') as sor:
try:
curdate = curDateString()
sql = """update params set params_value = ${curdate}$ where params_name='business_date'"""
await sor.sqlExe(sql, {'curdate': curdate})
return 'OK'
except Exception as e:
exception(f'{e}')
raise e