fix: server rollback error reporting and isSecurityError classification

- handler_update.go: check git.ResetHard return value; if rollback
  fails, append explicit warning to blocked message instead of
  silently claiming rolled back
- update.go: add "post-update audit" to isSecurityError keywords
  so install.Install audit failures are correctly classified as
  security blocks in batch exit code
This commit is contained in:
Willie
2026-02-23 04:18:01 +08:00
parent b216e3539e
commit 5ce6507799
3 changed files with 25 additions and 12 deletions
+6 -1
View File
@@ -903,12 +903,17 @@ func renderDiffSummary(repoPath, beforeHash, afterHash string) {
}
// isSecurityError returns true if the error originated from the audit gate.
// Matches errors from auditGateAfterPull ("security audit", "rolled back"),
// install.Install post-update path ("post-update audit"), and rollback failures.
func isSecurityError(err error) bool {
if err == nil {
return false
}
msg := err.Error()
return strings.Contains(msg, "security audit") || strings.Contains(msg, "rolled back") || strings.Contains(msg, "rollback failed")
return strings.Contains(msg, "security audit") ||
strings.Contains(msg, "post-update audit") ||
strings.Contains(msg, "rolled back") ||
strings.Contains(msg, "rollback failed")
}
func truncateString(s string, maxLen int) string {
+12 -4
View File
@@ -204,21 +204,29 @@ func (s *Server) auditGateTrackedRepo(name, repoPath, beforeHash string) *update
}
if err != nil {
git.ResetHard(repoPath, beforeHash) //nolint:errcheck
msg := "security audit failed: " + err.Error()
if resetErr := git.ResetHard(repoPath, beforeHash); resetErr != nil {
msg += " (WARNING: rollback also failed: " + resetErr.Error() + " — malicious content may remain)"
}
return &updateResultItem{
Name: name,
Action: "blocked",
Message: "security audit failed: " + err.Error(),
Message: msg,
IsRepo: true,
}
}
if result.HasHigh() {
git.ResetHard(repoPath, beforeHash) //nolint:errcheck
msg := "blocked by security audit — HIGH/CRITICAL findings detected"
if resetErr := git.ResetHard(repoPath, beforeHash); resetErr != nil {
msg += " (WARNING: rollback failed: " + resetErr.Error() + " — malicious content may remain)"
} else {
msg += ", rolled back"
}
return &updateResultItem{
Name: name,
Action: "blocked",
Message: "blocked by security audit — HIGH/CRITICAL findings detected, rolled back",
Message: msg,
IsRepo: true,
}
}
+7 -7
View File
@@ -171,13 +171,13 @@ skillshare update team-skills --diff
```
┌─ Files Changed ─────────────────────────────┐
│ │
│ ~ SKILL.md (+12 -3) │
│ + scripts/deploy.sh (+45 -0) │
│ - old-helper.sh (+0 -22) │
│ ~ utils/format.md (+5 -2) │
│ │
└──────────────────────────────────────────────┘
│ │
│ ~ SKILL.md (+12 -3) │
│ + scripts/deploy.sh (+45 -0) │
│ - old-helper.sh (+0 -22) │
│ ~ utils/format.md (+5 -2) │
│ │
└─────────────────────────────────────────────┘
```
Markers: `+` added, `-` deleted, `~` modified. Shows up to 20 files; additional files are summarized as "... and N more file(s)".