18 lines
713 B
Plaintext
18 lines
713 B
Plaintext
# 安全:定时任务入口(改全平台业务日期 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
|
||
|