The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
intel: read benign as covered in a retired-shape check answer
Claude407f2dec6e4b
diff --git a/cli/beacon/cmd/intel.go b/cli/beacon/cmd/intel.goindex c0ff1c86..fc6027fb 100644--- a/cli/beacon/cmd/intel.go+++ b/cli/beacon/cmd/intel.go@@ -292,11 +292,40 @@ func parseIntelFailOn(value string) (*intelGate, error) {return nil, fmt.Errorf("--fail-on must be high, medium, low or partial, not %q", termLine(value, 40))}+// intelRetiredShape reports whether a check answer comes from an index still on the retired+// verdicts: its counts or results carry malicious, suspicious or inconclusive, or no matched+// result names a coverage at all (the current shape always does). In that shape the verdict+// carried coverage itself, inconclusive being the partial one, so a benign there was covered+// and --fail-on partial must not read its missing coverage as unrecognized. An answer where+// some matched results name a coverage and others do not is current, and still fails closed.+func intelRetiredShape(res *intelapi.CheckResult) bool {+ for key, n := range res.Counts {+ if _, ok := intelRetiredRisks[key]; ok && n > 0 {+ return true+ }+ }+ matched := false+ for _, r := range res.Results {+ if r.Status != "matched" {+ continue+ }+ if _, ok := intelRetiredRisks[r.Risk]; ok {+ return true+ }+ if r.Coverage != "" {+ return false+ }+ matched = true+ }+ return matched+}+// fails says why a check result fails the gate, or "" when it passes. Only matched results// can fail: ambiguous and not_found claim no risk. It fails closed: a matched result whose// risk this build does not know fails at every threshold rather than ranking lowest, and with// partial, so does one whose coverage is neither complete nor partial.-func (g *intelGate) fails(r intelapi.CheckOutcome) string {+// retiredShape is intelRetiredShape of the whole answer.+func (g *intelGate) fails(r intelapi.CheckOutcome, retiredShape bool) string {if r.Status != "matched" {return ""}@@ -315,9 +344,10 @@ func (g *intelGate) fails(r intelapi.CheckOutcome) string {return fmt.Sprintf("%s (%s, partial)", termLine(r.Q, 80), risk)}return fmt.Sprintf("%s (%s)", termLine(r.Q, 80), risk)- case !g.partial || r.Risk == "unchecked" || retired || r.Coverage == "complete":+ case !g.partial || r.Risk == "unchecked" || retired || r.Coverage == "complete" || (retiredShape && r.Coverage == ""):// unchecked was never analyzed, so it has no coverage, and a retired verdict carried- // its coverage in the verdict itself (inconclusive ranks as low above).+ // its coverage in the verdict itself (inconclusive ranks as low above), as does a+ // benign in an answer of the retired shape.return ""case r.Coverage == "partial":return fmt.Sprintf("%s (%s, partial)", termLine(r.Q, 80), risk)@@ -411,8 +441,9 @@ func runIntelCheck(cmd *cobra.Command, args []string) error {}if gate != nil {var failed []string+ retiredShape := intelRetiredShape(res)for _, r := range res.Results {- if why := gate.fails(r); why != "" {+ if why := gate.fails(r, retiredShape); why != "" {failed = append(failed, why)}}diff --git a/cli/beacon/cmd/intel_test.go b/cli/beacon/cmd/intel_test.goindex e3b1fa7f..118e4c68 100644--- a/cli/beacon/cmd/intel_test.go+++ b/cli/beacon/cmd/intel_test.go@@ -347,13 +347,23 @@ func TestIntelCheckFailOnFailsClosed(t *testing.T) {if !strings.Contains(out, "1 benign, 1 inconclusive, 1 malicious.") {t.Errorf("counts line hid a retired count:\n%s", out)}+ // In the retired shape a benign was covered: --fail-on partial, the hint for+ // --fail-on inconclusive, fails what inconclusive failed and passes the benign._, err = runIntel(t, "", "check", "a", "--fail-on", "partial")- if !errors.Is(err, errIntelCheckFailed) || !strings.Contains(err.Error(), "3 at or above low or with partial coverage") ||- !strings.Contains(err.Error(), "old-ok (benign, coverage - not recognized)") {- // benign with no coverage cannot be told from a new answer missing its coverage, so- // --fail-on partial fails it rather than read it as complete.+ if !errors.Is(err, errIntelCheckFailed) || !strings.Contains(err.Error(), "2 at or above low or with partial coverage") || strings.Contains(err.Error(), "old-ok") {t.Fatalf("retired values under --fail-on partial: %v", err)}+ // An old answer of only benign matches carries no retired key, and no coverage either.+ f.answer("/api/v1/check", 200, `{"api":"intel.v1","results":[{"q":"old-ok","status":"matched","risk":"benign"},{"q":"gone","status":"not_found","risk":null}],"counts":{"benign":1,"not_found":1}}`)+ if _, err := runIntel(t, "", "check", "a", "--fail-on", "partial"); err != nil {+ t.Fatalf("old all-benign answer under --fail-on partial: %v", err)+ }+ // A current answer missing one result's coverage still fails closed.+ f.answer("/api/v1/check", 200, `{"api":"intel.v1","results":[{"q":"ok","status":"matched","risk":"benign","coverage":"complete"},{"q":"bare","status":"matched","risk":"benign"}],"counts":{"benign":2}}`)+ _, err = runIntel(t, "", "check", "a", "--fail-on", "partial")+ if !errors.Is(err, errIntelCheckFailed) || !strings.Contains(err.Error(), "1 at or above low or with partial coverage: bare (benign, coverage - not recognized)") {+ t.Fatalf("current answer missing coverage: %v", err)+ }f.answer("/api/v1/check", 200, `{"api":"intel.v1","results":[{"q":"odd","status":"matched","risk":"critical","coverage":"complete"},diff --git a/docs/cli/intel.mdx b/docs/cli/intel.mdxindex dc92703f..00a95d9e 100644--- a/docs/cli/intel.mdx+++ b/docs/cli/intel.mdx@@ -113,6 +113,9 @@ they claim no risk. The gate fails closed: a matched artifact whose risk this `brecognize fails every `--fail-on`, and under `--fail-on partial` so does one whose coverage isneither `complete` nor `partial`. An index that still answers with a retired verdict is rankedas its replacement (`malicious` as `high`, `suspicious` as `medium`, `inconclusive` as `low`).+In an answer of that retired shape (it carries retired verdicts, or no matched artifact names a+coverage), coverage was part of the verdict, so a `benign` there passes `--fail-on partial`, as+it passed `--fail-on inconclusive`.The retired values `malicious`, `suspicious` and `inconclusive` are refused as `--fail-on`thresholds with a message naming the new ones, so update CI scripts that pass them: `--fail-on