Skip to content

Conversation

@Erickw87
Copy link
Collaborator

变更背景和解决方案

关联issue: #

文档更新(架构文档、API文档、升级文档)

Checklist

  • 确认是否有文档更新
  • 确认是否自测
  • 确认是否考虑兼容升级,不兼容升级需要有对应的解决方案
  • 确认是否考虑添加监控指标
  • API 设计是否符合 API 设计规范, 如果没有 API 变更,请忽略
  • 我已经添加了相关人员到 Reviewers 列表中
  • 我已经设置了 Development 关联的 Issue

@Erickw87 Erickw87 merged commit 262a778 into qiniu:develop Oct 10, 2025
1 check passed
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Erickw87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求主要侧重于更新 Go 依赖项、将服务管理器的部署 API 重构为使用 gin-gonic/gin 进行路由,以及优化告警服务。主要变更包括数据库模式更新,将与告警问题相关的字段重命名,调整健康检查阈值的计算逻辑,以及移除 webhook 认证。此外,它还更新了 Docker Compose 配置以挂载新的内部配置文件,并清理了未使用的前端组件。

Highlights

  • API 框架迁移与依赖更新: 将 gin-gonic/gin 升级到 v1.11.0,并开始将 service_manager 的部署 API 处理程序从 fox-gonic/fox 迁移到 gin-gonic/gin 进行上下文处理。同时,还更新或添加了其他多个 Go 模块依赖。
  • 数据库模式优化: 在文档、SQL 模式中将 service_states 表中的 correlation_id 字段重命名为 alert_issue_ids,并更新了相应的 Go 模型和数据库查询。
  • 健康检查阈值逻辑调整: 修改了健康检查中异常检测阈值的计算方式,从简单的百分比 (baseTh * 0.99) 调整为使用 math.Ceil(baseTh * 0.01) 进行更精确的计算。
  • Webhook 认证移除: 禁用了告警服务 webhook 接收器的认证功能,将 AuthMiddleware 变为无操作。
  • Docker 配置更新: 在生产环境的 Docker Compose 配置中,为 ./internal/deploy/config.yaml 添加了一个新的只读卷挂载。
  • 前端清理: 从 ChangeLogView.vue 组件中移除了占位符选项卡。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🚀 Frontend deployed successfully!

📱 Preview URL: https://zeroops-of5ayyvef-liuscrafts-projects.vercel.app

✅ Build completed successfully

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

本次更新包含多个文件的修改,包括依赖项更新、数据库字段重命名、以及从 fox 框架迁移到 gin 框架。这些变更大部分是积极的维护和重构。

然而,其中一个变动是完全移除了告警 webhook 的认证逻辑,这是一个严重的安全风险,需要立即处理。此外,我还发现了一个模型字段命名不一致的问题,以及一个需要完善的测试用例。

PR 的描述过于简单,没有解释这些重要变更(尤其是安全相关的)背后的原因,建议后续提供更详细的说明。

Comment on lines +7 to +11
// ConfigureAuth is a no-op; authentication disabled at source.
func ConfigureAuth(user, pass, bearer string) {}

// AuthMiddleware returns false if unauthorized and writes a 401 response.
func AuthMiddleware(c *gin.Context) bool {
if !authEnabled() {
return true
}

// prefer config
user := cfgBasicUser
pass := cfgBasicPass
bearer := cfgBearer
// fallback to env if not set in config
if user == "" && pass == "" && bearer == "" {
user = os.Getenv("ALERT_WEBHOOK_BASIC_USER")
pass = os.Getenv("ALERT_WEBHOOK_BASIC_PASS")
bearer = os.Getenv("ALERT_WEBHOOK_BEARER")
}

if user != "" || pass != "" {
u, p, ok := c.Request.BasicAuth()
if !ok || u != user || p != pass {
c.JSON(http.StatusUnauthorized, map[string]any{"ok": false, "error": "unauthorized"})
return false
}
return true
}

if bearer != "" {
if c.GetHeader("Authorization") != "Bearer "+bearer {
c.JSON(http.StatusUnauthorized, map[string]any{"ok": false, "error": "unauthorized"})
return false
}
}
return true
}
func AuthMiddleware(c *gin.Context) bool { return true }
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

此变更移除了告警 webhook 的全部认证逻辑,导致该端点完全暴露,没有任何安全防护。这是一个严重的安全漏洞,任何知道该端点地址的人都可以向系统发送任意告警,可能导致系统被滥用或攻击。如果此端点暴露在公网上,风险极高。

请立即恢复认证机制。如果这是为了临时调试,请确保在合并到主分支前恢复认证逻辑。

ReportAt time.Time `json:"reportAt" db:"report_at"` // time - 报告时间
ResolvedAt *time.Time `json:"resolvedAt" db:"resolved_at"` // time - 解决时间
HealthState HealthState `json:"healthState" db:"health_state"` // 健康状态
CorrelationID string `json:"alertIssueIds" db:"alert_issue_ids"` // varchar - 关联ID
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

结构体字段名 CorrelationID 与其 JSON 标签 json:"alertIssueIds" 和数据库标签 db:"alert_issue_ids" 不一致。为了保持代码的清晰性和一致性,建议将字段名修改为 AlertIssueIDs,以遵循 Go 的命名规范并与标签含义保持一致。

Suggested change
CorrelationID string `json:"alertIssueIds" db:"alert_issue_ids"` // varchar - 关联ID
AlertIssueIDs string "json:\"alertIssueIds\" db:\"alert_issue_ids\"" // varchar - 关联ID

Comment on lines +9 to +14
func TestCommon(t *testing.T) {
baseTh := 97.0

newThreshold := baseTh - math.Ceil(baseTh*0.01)
fmt.Println(newThreshold)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

这个测试函数 TestCommon 只是打印了一个计算结果,并没有使用任何断言来验证其正确性。一个有效的单元测试应该包含明确的输入、预期输出和断言。如果这只是一个用于临时调试的测试,请在合并前将其移除或完善成一个真正的测试用例。

Suggested change
func TestCommon(t *testing.T) {
baseTh := 97.0
newThreshold := baseTh - math.Ceil(baseTh*0.01)
fmt.Println(newThreshold)
}
func TestCommon(t *testing.T) {
baseTh := 97.0
expected := 96.0
newThreshold := baseTh - math.Ceil(baseTh*0.01)
if newThreshold != expected {
t.Errorf("Expected newThreshold to be %f, but got %f", expected, newThreshold)
}
}

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.

2 participants