Skip to content

烦烦烦#2178

Open
zhostev wants to merge 30 commits intomicrosoft:mainfrom
zhostev:main
Open

烦烦烦#2178
zhostev wants to merge 30 commits intomicrosoft:mainfrom
zhostev:main

Conversation

@zhostev
Copy link
Copy Markdown

@zhostev zhostev commented Mar 30, 2026

Description

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

tbh4gug7sxoiw3pbuj@aliyun.com and others added 30 commits November 26, 2025 18:20
refactor(后端): 扩展用户模型和API响应字段

style(导航): 优化用户头像和下拉菜单样式

docs: 添加用户头像功能相关文档

test(实验): 增强表单验证和错误处理
- 添加用户模型完整字段(email, full_name, role等)
- 实现用户权限系统(admin, developer, viewer)
- 开发后台管理页面,支持用户增删改查
- 优化登录页面和表单验证
- 移除Profit-Loss页面
- 更新数据库结构和初始化脚本
- 添加权限控制路由和API
- 优化实验运行日志和性能计算
- 修复YAML编辑器性能问题
- 更新前端路由和导航菜单
feat(frontend): 实现benchmark样例选择功能

feat(experiment): 增强实验状态跟踪功能,添加进度、开始/结束时间字段

refactor(frontend): 国际化调整,将界面文本改为中文

feat(navigation): 添加用户管理链接入口

perf(task): 优化任务执行逻辑,添加进度更新

docs: 添加实现计划文档
重构实验运行流程,从直接后台运行改为任务队列方式
- 新增Task模型和服务类,用于管理实验任务
- 实现任务工作器,处理待执行任务
- 修改实验运行API,改为创建任务
- 前端添加benchmark选择功能
- 添加用户角色管理功能,确保admin用户具有管理员权限
- 修改用户头像点击行为,管理员直接跳转管理页面
- 优化select元素样式解决可见性问题
- 在登录后存储用户信息到localStorage
- 添加实验管理页面的权限控制
- 更新相关文档和修复计划
添加reset_task.py用于重置任务和实验状态
在train.py中导入sqlalchemy的func函数
- 添加因子管理相关API、模型和前端页面
- 实现数据管理功能,包括股票数据模型和API
- 更新前端导航栏添加因子管理和数据管理入口
- 修复实验日志功能,支持实时查看运行日志
- 优化用户认证和权限控制逻辑
- 添加QLib服务集成支持
- 更新数据库初始化脚本和文档
添加实验列表按创建时间排序功能,支持卡片和列表两种显示样式切换
修改时间戳转换格式,移除时区信息并简化为日期格式
refactor(实验列表): 优化布局和样式,增加卡片/列表视图切换功能

feat(因子服务): 添加Qlib因子服务获取实际因子定义

fix(数据库): 移除因子名称唯一约束,更新数据库结构

chore: 添加相关文档和计划文件
- 添加react-select依赖
- 修改vite配置中的代理目标端口
- 更新package.json文件
- 后端添加实验状态立即更新为pending的功能
- 启动任务执行器以处理待运行实验
- 添加GPU支持并优化模型训练性能
- 扩展回测结果数据,包括月度收益、回撤曲线等指标
- 前端优化实验状态实时更新和日志显示频率
- 改进回测结果展示,添加多种图表和详细指标
重构后端架构,移除主应用中的任务处理逻辑,改为独立的训练节点服务
添加训练节点实现,从数据库获取任务并执行训练
添加前后端解耦方案文档和部署计划文档
refactor(frontend): 调整全局样式使界面更紧凑
docs: 添加前后端联调测试计划和样式调整计划文档
build: 添加python-dotenv和httpx依赖
style: 更新日志导入路径
refactor(数据库): 迁移SQLite到MySQL,更新数据库连接配置
fix(日志): 解决日志频繁刷新问题,优化日志存储和查询
feat(任务管理): 添加任务重试机制和状态管理功能
docs: 更新相关文档,包括联调测试计划和优化方案
style: 统一代码格式,修复代码分析警告
test: 添加多种测试脚本,包括远程连接和API测试
refactor(backend): 重构监控和训练服务以增强稳定性

fix(backend): 修复benchmark服务目录不存在时的处理

test: 添加benchmark服务测试脚本

docs: 添加全面测试报告文档

style: 优化日志格式和错误处理

chore: 更新supervisor配置和nginx路径
refactor: 重构系统监控服务以支持服务状态检查
feat(frontend): 新增风险管理和回测页面
style: 更新前端样式以支持新功能
docs: 添加服务状态监控相关文档
test: 添加服务状态监控测试用例
chore: 更新依赖和配置文件
添加 email_verified、verification_token 和 verification_token_expiry 字段以支持邮箱验证功能
fix: 修复基准目录路径问题
refactor: 重构用户认证服务
chore: 更新依赖版本
docs: 添加测试脚本和说明
refactor: 将直接使用axios改为使用axios实例
style(导航): 添加下拉菜单样式和交互逻辑
fix(后端): 修复任务创建时实验状态更新问题
refactor: 重构主API路由分离训练相关端点

style: 更新前端服务状态显示样式

test: 添加训练服务器连接及API测试脚本

chore: 添加训练服务器启动脚本及supervisor配置
…ster train/tasks routes, CORS fix, data import script, automated test script, startup scripts

Agent-Logs-Url: https://github.com/zhostev/qlib_t/sessions/510c756a-7ce2-43da-a2b9-b6dcaece6b59

Co-authored-by: zhostev <57177476+zhostev@users.noreply.github.com>
…et key generation, test assertions

Agent-Logs-Url: https://github.com/zhostev/qlib_t/sessions/510c756a-7ce2-43da-a2b9-b6dcaece6b59

Co-authored-by: zhostev <57177476+zhostev@users.noreply.github.com>
Add integration testing infrastructure, data import, and dev startup scripts
Copilot AI review requested due to automatic review settings March 30, 2026 09:25
@microsoft-github-policy-service
Copy link
Copy Markdown

@zhostev please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR appears to introduce a full-stack “QLib AI” management platform setup, including a new Vite/React frontend, Docker-based deployment, and a large backend surface area (auth, tasks, monitoring, QLib integration, benchmarks, and various DB/scripts).

Changes:

  • Added Docker assets (compose + backend/frontend Dockerfiles) and Nginx config for serving the frontend and proxying /api.
  • Implemented/added substantial backend modules: auth, experiments/tasks APIs, monitoring, remote training client, QLib helpers, schemas/models.
  • Added various operational/debug scripts and test reports for environment validation, DB fixes, and manual testing.

Reviewed changes

Copilot reviewed 125 out of 7606 changed files in this pull request and generated 24 comments.

Show a summary per file
File Description
frontend/nginx.conf Adds Nginx server block to serve SPA and proxy /api.
frontend/index.html Adds Vite/React HTML entrypoint.
frontend/eslint.config.js Adds ESLint flat config for TS/React.
frontend/README.md Adds Vite template README.
docker/init.sql Seeds DB with admin user + initial config template.
docker/frontend.Dockerfile Builds + serves frontend via serve.
docker/docker-compose.yml Adds compose stack for backend/worker/frontend/mysql.
docker/backend.Dockerfile Builds backend image including local QLib build.
collect_benchmark_configs.py Script to collect benchmark YAML configs.
backend_supervisor_train.conf Supervisor config for training server.
backend_supervisor.conf Supervisor config for backend server.
backend/update_tasks_table.py Script to alter tasks table to add retry columns.
backend/update_experiment_config.py Script to normalize timestamps inside experiment configs (sqlite).
backend/update_db_schema.py Script to drop/recreate factors indexes.
backend/update_admin_password.py Script to update admin password in a remote MySQL DB.
backend/test_websocket.py Manual WebSocket communication test script.
backend/test_training_api.py Manual training API test script.
backend/test_run_experiment.py Manual script to create/run a task for an experiment.
backend/test_remote_server.py Manual script to test remote server health/status.
backend/test_remote_client.py Manual script to test RemoteClient behaviors.
backend/test_qlib_service.py Manual script to test QLibService and stock data fetching.
backend/test_performance_calc.py Manual script to validate performance calculation logic.
backend/test_local_websocket.py Manual local WebSocket test script.
backend/test_full_flow.sh Shell script to run an end-to-end flow via API calls.
backend/test_db_connection.py Script to test DB connectivity using DATABASE_URL.
backend/test_benchmark_service.py Script to debug benchmark directory scanning.
backend/test_benchmark_fix.py Script to verify benchmark service behavior under missing dirs.
backend/test_benchmark_dir_fixed.py Script to validate benchmark dir path calculation.
backend/test_benchmark_dir.py Script to validate benchmark dir path calculation.
backend/supervisor_train_worker.conf Supervisor config for training worker process.
backend/supervisor_monitoring.conf Supervisor config for monitoring process.
backend/start_worker.sh Startup script for task worker module.
backend/start_train_server.sh Startup script for training server via uvicorn.
backend/run_monitoring.py Monitoring loop runner with detailed logging.
backend/reset_task.py Script to reset a task/experiment status to pending.
backend/reset_factors.py Script to delete factors and reset factor_group counts.
backend/reset_experiment_status.py Script to reset an experiment status and create a new task.
backend/reset_db.py Script to drop and recreate DB tables.
backend/reset_admin_password.py Script to reset admin password using DATABASE_URL.
backend/requirements.txt Adds backend Python dependencies.
backend/qlib_ai_api.logrotate Logrotate config for uvicorn log.
backend/init_db.py DB initialization script with factor + stock data seeding.
backend/fix_user_table.py Script to alter remote users table schema + create admin.
backend/fix_tasks_table.py Script to alter tasks table columns based on parsed DATABASE_URL.
backend/fix_experiment_config.py Script to fix experiment config JSON and remove invalid params.
backend/fix_admin_user.py Script to create/fix admin user using app services.
backend/create_ultimate_test_experiment.py Script to create a test experiment + task.
backend/create_test_experiment.py Script to create a test experiment.
backend/create_task_for_experiment.py Script to create a task for an existing experiment.
backend/create_simple_experiment.py Script to create a simplified experiment + task.
backend/create_log_table.py Script to create all tables including experiment log table.
backend/create_fixed_experiment.py Script to create a “fixed” experiment + task.
backend/create_final_test_experiment.py Script to create a final test experiment + task.
backend/create_admin.py Script to create/update admin user.
backend/check_users.py Script to list users from a remote MySQL DB.
backend/check_ultimate_experiment.py Script to inspect experiment performance payload shape.
backend/check_tables.py Script to inspect DB tables and tasks schema.
backend/check_performance.py Script to inspect performance field on an experiment.
backend/check_final_experiment.py Script to inspect final experiment results.
backend/check_factors.py Script to inspect factor counts by group.
backend/check_experiments.py Script to list experiments and performance keys.
backend/check_experiment_logs.py Script to print experiment logs (legacy).
backend/check_experiment_config.py Script to dump experiment config.
backend/check_experiment_9.py Script to inspect experiment 9 results.
backend/check_experiment_8.py Script to inspect experiment 8 status and recent logs.
backend/check_experiment_7.py Script to inspect experiment 7 status and logs.
backend/check_existing_config.py Script to inspect config structure for an experiment.
backend/check_db.py Script to validate DB and basic table queries.
backend/app/yaml/parser.py Adds YAML parsing/generation/validation helpers.
backend/app/utils/remote_client.py Adds async remote training server client (HTTP + WS).
backend/app/utils/queue.py Adds DB-backed task queue helper + processor.
backend/app/utils/config_validation.py Adds environment/DB/training-server validation functions.
backend/app/tasks/task_worker.py Adds async task worker for processing pending tasks.
backend/app/services/training_client.py Adds httpx-based client to trigger training via API.
backend/app/services/task.py Adds TaskService including retry handling + status updates.
backend/app/services/qlib_service.py Adds QLibService with instrument + stock data helpers.
backend/app/services/qlib_factor.py Adds QlibFactorService to fetch factor definitions.
backend/app/services/monitoring.py Adds system monitoring using psutil + remote checks.
backend/app/services/model_version.py Adds CRUD-ish model version service functions.
backend/app/services/factor.py Adds factor + factor group service functions.
backend/app/services/experiment.py Adds experiment CRUD with timestamp conversion.
backend/app/services/email_service.py Adds SMTP email verification + password reset flow.
backend/app/services/data.py Adds stock data CRUD + QLib refresh + alignment logic.
backend/app/services/config.py Adds config CRUD.
backend/app/services/benchmark.py Adds benchmark discovery under benchmarks directory.
backend/app/services/auth.py Adds authentication helpers + password hashing.
backend/app/services/analysis.py Adds analysis data generation (mock/derived).
backend/app/schemas/model_version.py Adds pydantic schemas for model versions.
backend/app/schemas/factor.py Adds pydantic schemas for factors/factor groups.
backend/app/schemas/experiment.py Adds pydantic schemas for experiments.
backend/app/schemas/data.py Adds pydantic schemas for stock data.
backend/app/schemas/config.py Adds pydantic schemas for configs.
backend/app/schemas/auth.py Adds pydantic schemas for auth/user.
backend/app/models/user.py Adds SQLAlchemy User model with verification/reset fields.
backend/app/models/task.py Adds SQLAlchemy Task model with retry fields.
backend/app/models/stock_data.py Adds SQLAlchemy StockData model.
backend/app/models/model_version.py Adds SQLAlchemy ModelVersion model.
backend/app/models/log.py Adds SQLAlchemy ExperimentLog model.
backend/app/models/factor.py Adds SQLAlchemy Factor/FactorGroup models.
backend/app/models/experiment.py Adds SQLAlchemy Experiment model + ExperimentLog relationship.
backend/app/models/config.py Adds SQLAlchemy Config model + ConfigType enum.
backend/app/db/database.py Adds SQLAlchemy engine/session setup and get_db dependency.
backend/app/config.py Adds Settings object w/ DB, security, training server, SMTP, CORS.
backend/app/api/train.py Adds train task manager endpoints + WS updates (simulated training).
backend/app/api/tasks.py Adds task listing/detail + cancel/retry endpoints.
backend/app/api/monitoring.py Adds monitoring endpoints incl. health + service status.
backend/app/api/models.py Adds model-version endpoints.
backend/app/api/factors.py Adds factor + factor-group endpoints.
backend/app/api/experiments.py Adds experiments endpoints + run + logs + analysis endpoints.
backend/app/api/deps.py Adds auth dependencies / role guards for routes.
backend/app/api/data.py Adds stock data endpoints + QLib instruments/features + align endpoint.
backend/app/api/configs.py Adds config endpoints with YAML validation.
backend/app/api/benchmarks.py Adds benchmark endpoints.
backend/app/api/auth.py Adds auth endpoints: token/login + user admin CRUD + register/verify/reset.
backend/app/api/init.py Registers API routers under the main API router.
backend/add_missing_columns.py Script to alter tasks table columns.
backend/TEST_REPORT.md Adds integration test report doc.
backend/COMPREHENSIVE_TEST_REPORT.md Adds comprehensive integration/test report doc.
.trae/documents/增加用户信息头像到右上角.md Adds design/notes doc for user avatar UI.
.trae/documents/优化用户头像和显示层面.md Adds design/notes doc for user avatar UI refinement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, jwt
from sqlalchemy.orm import Session
from app.db.database import get_db, settings
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.db.database (as added in this PR) defines engine/SessionLocal/Base/get_db but does not define settings, so this import will raise ImportError and prevent the API from starting. Fix by importing settings from app.config instead (and update other files with the same pattern, e.g. app/api/auth.py and app/services/email_service.py).

Suggested change
from app.db.database import get_db, settings
from app.db.database import get_db
from app.config import settings

Copilot uses AI. Check for mistakes.
import secrets
from sqlalchemy.orm import Session
from app.models.user import User
from app.db.database import settings
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as deps.py: settings is defined in app.config, not app.db.database. This will crash imports at runtime; switch to from app.config import settings (and keep DB-related imports in app.db.database).

Suggested change
from app.db.database import settings
from app.config import settings

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +27
r"mysql://",
r"mysql\+pymysql://",
r"postgresql://",
r"postgresql\+psycopg2://",
r"sqlite://"
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DATABASE_URL validation is currently incorrect for URLs like mysql+pymysql://... and postgresql+psycopg2://... because the patterns contain backslashes (regex-escaped) but you perform a plain substring check. Replace DB_URL_PATTERNS with literal prefixes (no escaping) or actually use regex matching via re.search.

Suggested change
r"mysql://",
r"mysql\+pymysql://",
r"postgresql://",
r"postgresql\+psycopg2://",
r"sqlite://"
"mysql://",
"mysql+pymysql://",
"postgresql://",
"postgresql+psycopg2://",
"sqlite://"

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +56
db_url = os.environ["DATABASE_URL"]
valid_db_url = any(pattern in db_url for pattern in ConfigValidator.DB_URL_PATTERNS)
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DATABASE_URL validation is currently incorrect for URLs like mysql+pymysql://... and postgresql+psycopg2://... because the patterns contain backslashes (regex-escaped) but you perform a plain substring check. Replace DB_URL_PATTERNS with literal prefixes (no escaping) or actually use regex matching via re.search.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +32
def authenticate_user(db: Session, username: str, password: str):
# For development purposes, allow admin user with fixed password
if username == "admin" and password == "admin123":
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a hard-coded authentication backdoor for the admin account. This must be removed or strictly gated behind an explicit development-only feature flag (e.g., an env var that defaults to disabled) to avoid shipping an account takeover vector.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,7 @@
-- 创建管理员用户
INSERT INTO users (username, password_hash, created_at, updated_at)
VALUES ('admin', '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', NOW(), NOW());
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seeds a globally known admin username with a precomputed bcrypt hash, while app/services/auth.py uses pbkdf2_sha256 only. Besides being a security risk (predictable seeded admin), it will also cause authentication inconsistencies. Seed users via the same hash scheme as the application (and avoid shipping default admin credentials in production; require setting via env/one-time bootstrap).

Suggested change
VALUES ('admin', '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', NOW(), NOW());
VALUES ('admin', NULL, NOW(), NOW());

Copilot uses AI. Check for mistakes.
database_url = os.getenv("DATABASE_URL", "sqlite:///./test.db")

# Security settings
secret_key = os.getenv("SECRET_KEY", "your-secret-key-here")
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security-sensitive defaults are committed (fallback SECRET_KEY and SMTP credentials). In production, these should not have hard-coded fallbacks; require env vars (fail fast on missing), and remove any real credentials from the codebase (rotate the exposed SMTP password).

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +29
smtp_username = os.getenv("SMTP_USERNAME", "qlib@uszho.com")
smtp_password = os.getenv("SMTP_PASSWORD", "Moshou99")
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security-sensitive defaults are committed (fallback SECRET_KEY and SMTP credentials). In production, these should not have hard-coded fallbacks; require env vars (fail fast on missing), and remove any real credentials from the codebase (rotate the exposed SMTP password).

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +15
- DATABASE_URL=mysql+pymysql://user:password@mysql:3306/qlib_management
- SECRET_KEY=your-secret-key-here
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compose file contains default credentials and SECRET_KEY. Even for dev, this pattern often gets promoted to production accidentally. Prefer using an .env file (not committed) or compose secrets: / environment overrides, and ensure production deployments require non-default values.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,182 @@
# QLib分布式管理平台 - 全面联调与测试报告
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title (\"烦烦烦\") and the PR description template are not filled in (no summary/motivation/testing), but the diff introduces major product + infrastructure changes. Please update the PR title to a conventional-commit style summary and fill in Description/Motivation/Testing so reviewers can validate intent and scope.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants