mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)".
|
||||
|
||||
Reference in New Issue
Block a user