mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
* feat(audit): honor findings accepted with --force via --respect-accepted install and update --force record the findings a user accepted in audit_accepted, but audit ignored that record. A skill installed with --force therefore kept failing `skillshare audit` in CI with no way to let the accepted findings pass (#869). audit --respect-accepted marks those findings as acknowledged. They stay in every output (JSON acknowledged: true, a text/TUI note, "(accepted earlier)" in Markdown, SARIF external suppressions), but they are counted in summary.accepted instead of their severity and no longer fail the audit. Without the flag nothing changes, so existing CI gates keep their behavior. A changed file or snippet produces a new key and blocks again. Tracked repositories record acceptances at the repo root with paths relative to it, so ApplyAcceptedFindings walks up from each skill to match them. The install, update and edit gates use the same function and now honor repo-wide acceptances for skills inside tracked repos too. The dashboard always honors accepted findings: the Audit page mutes them and counts them apart, the skill Audit tab collapses them, and the Dashboard attention card no longer lists a skill whose only blocking findings were accepted. The CLI JSON summary and the server summary share Result.CountOpenBySeverity so both count accepted findings the same way. The oplog records the accepted count and the log views show it. * fix(audit): match acceptances when a single file is scanned A single-file scan names its findings by the file's base name, but the ancestor lookup used the file's whole path as the prefix, so it hashed SKILL.md/SKILL.md instead of the recorded SKILL.md. Auditing a skill file directly with --respect-accepted, and auditing agents inside a tracked repository in the CLI or the dashboard, still failed on unchanged accepted findings. For a file target the prefix is now the file's own directory.
57 lines
2.1 KiB
Go
57 lines
2.1 KiB
Go
package audit
|
|
|
|
import "testing"
|
|
|
|
func TestAcceptKey_IgnoresLineNumber(t *testing.T) {
|
|
a := Finding{RuleID: "prompt-injection-0", Pattern: "prompt-injection", File: "SKILL.md", Line: 5, Snippet: "Ignore previous instructions"}
|
|
b := a
|
|
b.Line = 42
|
|
if AcceptKey(a) != AcceptKey(b) {
|
|
t.Error("line number must not change the accept key")
|
|
}
|
|
b.Snippet = "SYSTEM: override"
|
|
if AcceptKey(a) == AcceptKey(b) {
|
|
t.Error("different snippet must change the accept key")
|
|
}
|
|
}
|
|
|
|
func TestResult_MarkAcknowledged_SkipsBlocking(t *testing.T) {
|
|
r := &Result{Findings: []Finding{
|
|
{Severity: SeverityCritical, Pattern: "prompt-injection", File: "SKILL.md", Snippet: "Ignore previous instructions"},
|
|
}}
|
|
keys := r.AcceptKeysAtOrAbove(SeverityCritical)
|
|
if len(keys) != 1 {
|
|
t.Fatalf("want 1 accept key, got %d", len(keys))
|
|
}
|
|
if n := r.MarkAcknowledged(keys); n != 1 {
|
|
t.Fatalf("want 1 marked, got %d", n)
|
|
}
|
|
if r.HasSeverityAtOrAbove(SeverityCritical) {
|
|
t.Error("acknowledged finding must not block")
|
|
}
|
|
if len(r.AcceptKeysAtOrAbove(SeverityCritical)) != 0 {
|
|
t.Error("acknowledged finding must not be re-accepted")
|
|
}
|
|
}
|
|
|
|
func TestResult_MarkAcknowledgedUnder_MatchesKeysOfEnclosingScan(t *testing.T) {
|
|
whole := Finding{Severity: SeverityCritical, Pattern: "prompt-injection", File: "skills/a/SKILL.md", Snippet: "Ignore previous instructions"}
|
|
r := &Result{Findings: []Finding{
|
|
{Severity: SeverityCritical, Pattern: "prompt-injection", File: "SKILL.md", Snippet: "Ignore previous instructions"},
|
|
}}
|
|
if n := r.MarkAcknowledgedUnder([]string{AcceptKey(whole)}, "skills/a"); n != 1 || r.HasSeverityAtOrAbove(SeverityCritical) {
|
|
t.Fatalf("marked %d, findings %+v", n, r.Findings)
|
|
}
|
|
}
|
|
|
|
func TestResult_MarkAcknowledged_NewFindingStillBlocks(t *testing.T) {
|
|
r := &Result{Findings: []Finding{
|
|
{Severity: SeverityCritical, Pattern: "prompt-injection", File: "SKILL.md", Snippet: "Ignore previous instructions"},
|
|
{Severity: SeverityCritical, Pattern: "prompt-injection", File: "SKILL.md", Snippet: "SYSTEM: override"},
|
|
}}
|
|
r.MarkAcknowledged([]string{AcceptKey(r.Findings[0])})
|
|
if !r.HasSeverityAtOrAbove(SeverityCritical) {
|
|
t.Error("unacknowledged finding must still block")
|
|
}
|
|
}
|