diff --git a/cmd/skillshare/update.go b/cmd/skillshare/update.go index 0c29ac2d1..686230110 100644 --- a/cmd/skillshare/update.go +++ b/cmd/skillshare/update.go @@ -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 { diff --git a/internal/server/handler_update.go b/internal/server/handler_update.go index 674a65417..0d24c8abb 100644 --- a/internal/server/handler_update.go +++ b/internal/server/handler_update.go @@ -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, } } diff --git a/website/docs/commands/update.md b/website/docs/commands/update.md index 463cd1ddc..aa2f6f52b 100644 --- a/website/docs/commands/update.md +++ b/website/docs/commands/update.md @@ -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)".