Codebase review: high-priority security, reliability, maintainability, and bloat findings

未关闭
#1,249 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
mysql, postgresql, rust, sqlite

调研方向

Start with the concrete references in src/webserver/oidc.rs, src/webserver/database/sqlpage_functions/functions.rs, src/webserver/http.rs, src/filesystem.rs, and src/render.rs; read the relevant sections alongside the proposed execution plan. Run the applicable tests and cargo audit to establish current behavior. This issue spans security, dependency remediation, HTTP semantics, stability, and refactoring, so its completion criteria need to be narrowed into focused follow-up work.

由索引模型根据 Issue 内容生成。

描述

Summary

  • A deep review of the current codebase found several high-impact issues across security, reliability, maintainability, and code bloat/duplication. This issue tracks the highest-priority items with concrete references.

High priority

1) Sensitive auth/material is logged in plaintext (token/cookie/response leakage)

Current code logs OIDC secrets and arbitrary HTTP response bodies:

Why this matters:

  • Tokens and identity claims can leak into logs and downstream observability pipelines.
  • Any log access then becomes auth/session compromise risk.

Suggested fix:

  • Never log token/cookie values or raw OIDC responses.
  • Redact or hash sensitive values ([REDACTED]).
  • Keep only metadata: status code, endpoint host/path class, payload size, elapsed time.
2) Dependency security advisories in lockfile/dependency graph

cargo audit reports:

  • RUSTSEC-2023-0071 on rsa 0.9.10 (Marvin timing side-channel)
  • Unmaintained warnings:
    • RUSTSEC-2024-0436 (paste 1.0.15)
    • RUSTSEC-2025-0134 (rustls-pemfile 2.2.0)

Dependency entrypoints:

Why this matters:

  • Security debt accumulates in auth and DB-critical dependency paths.

Suggested fix:

  • Plan migration away from sqlx-oldapi 0.6.x line to maintained upstream.
  • Re-resolve OIDC stack and lockfile to versions without advisory hits when available.
  • Add cargo audit (or equivalent) to CI as informational gate at minimum.

Medium priority

3) Incorrect HTTP caching semantics for static files

Why this matters:

  • Weak/incorrect cache validation and inconsistent behavior between local FS and DB-backed FS.
  • Causes unnecessary cache misses and confusing revalidation behavior.

Suggested fix:

  • Set Last-Modified from actual source mtime (or omit if unknown).
  • Align local/db modified comparison semantics (> vs >=) to one consistent contract.
4) 404 fallback behavior returns 200 for custom 404.sql

Why this matters:

  • API clients, crawlers, and monitoring receive incorrect status codes for missing resources.

Suggested fix:

  • Preserve the custom body but set status code to 404 for custom not-found handlers.
5) Crash/panic edges in request path and response finalization

Why this matters:

  • A panic in request handling can take down worker tasks and create unstable behavior under malformed edge inputs.

Suggested fix:

  • Replace unwrap() with structured error propagation and explicit 400/500 mapping.

Maintainability / bloat / duplication

6) Very large multi-responsibility modules increase change risk

Key files:

Also note duplicated fetch pipelines:

Why this matters:

  • High cognitive load, difficult reviews, and increased regression risk.

Suggested fix:

  • Split by responsibility boundaries (parsing/rewrite/validation/execution; OIDC callback/logout/token; renderer header/body/format adapters).
  • Extract shared HTTP fetch execution into one reusable helper returning a structured internal response object.

Proposed execution plan

  • Security patch pass
    • Remove/redact sensitive logs in OIDC + fetch paths.
    • Add regression tests asserting no token value appears in logs for auth flow failures.
  • HTTP correctness pass
    • Fix Last-Modified source and local/db comparison contract.
    • Return proper 404 status for custom 404 handlers.
  • Stability pass
    • Eliminate production unwrap() in request/response hot paths.
  • Dependency/risk pass
    • Open follow-up migration issue for sqlx-oldapi and dependency audit remediation.
  • Refactor pass
    • Break down oversized files and deduplicate fetch logic with targeted tests.
主要语言
Rust
星标
2.6k
派生
175
平均合并
14 小时 16 分钟
30 天内合并 PR
43

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sqlpage/SQLPage 的其他 Issue

查看 sqlpage/SQLPage 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。