carlos / platform Public

Probe burst limit: name the burst group on the console (Task 6)

The Protection tab's table words burst/probe-burst (PB-C02), and the
catalogue-group test now covers the burst rule. The Logs filter already
kept burst watch and block records and drops trip records; a test holds
that and the comment says why.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7f90115659a403c088f0ec4429e00944d47b3075 parent 6dbb366
4 files changed, +42 −4
  • internal/console/approved_burst_copy_test.go +2 −0
  • internal/console/protectiongroups.go +2 −1
  • internal/console/protectionview.go +5 −2
  • internal/console/protectionview_test.go +33 −1
diff --git a/internal/console/approved_burst_copy_test.go b/internal/console/approved_burst_copy_test.go
index f3b7a6897..68e564aa3 100644
--- a/internal/console/approved_burst_copy_test.go
+++ b/internal/console/approved_burst_copy_test.go
@@ -25,6 +25,8 @@ const (
var burstCopyBuilt = map[string]bool{
// Task 1: the 429 body already lives in internal/edge/burst_refusal.go.
"PB-C01": true,
+ // Task 6: the burst group's name in the Protection tab's table.
+ "PB-C02": true,
// Task 5: the record-only switch, on the Protection tab, its flashes
// and `carlos protection`.
"PB-C03": true,
diff --git a/internal/console/protectiongroups.go b/internal/console/protectiongroups.go
index 8b1982483..0450636c8 100644
--- a/internal/console/protectiongroups.go
+++ b/internal/console/protectiongroups.go
@@ -5,7 +5,7 @@ package console
// "<tier>/<group>" (internal/edge/usagemeter.go), so a group that sits in
// both tiers (dumps) has a name per tier. Every catalogue group has a name
// here; TestEveryCatalogueGroupHasAName holds that true as the catalogue
-// grows. The text is the approved copy deck's (PT-C20 to PT-C35).
+// grows. The text is the approved copy deck's (PT-C20 to PT-C35); the burst group's is PB-C02.
var protectionGroupNames = map[string]string{
"hard/traversal": "Paths that try to climb out of the site's folder",
"hard/secrets": "Secret files such as .env and .git",
@@ -23,6 +23,7 @@ var protectionGroupNames = map[string]string{
"probe/php": "PHP scripts",
"probe/status": "Server status pages",
"probe/wordpress": "WordPress logins and admin pages",
+ "burst/probe-burst": "Bursts of probes from one address",
}
// protectionOtherGroup is the name of every group the table has no name
diff --git a/internal/console/protectionview.go b/internal/console/protectionview.go
index f69c8b60e..ce97ab14a 100644
--- a/internal/console/protectionview.go
+++ b/internal/console/protectionview.go
@@ -184,8 +184,11 @@ func protectionLogsURL(nav, app string, dates []string, now time.Time) string {
// protectionLogRecord reports whether rec is one of the requests the tab
// counts as caught: an edge record of a watch or block match on a catalogue
-// rule that acts on a single request. Burst rules (admin pages) are checked
-// but never caught, so their records are not the tab's. Only the edge
+// rule that acts on a single request. Burst-mode rules (admin pages) are
+// checked but never caught, so their records are not the tab's. The
+// probe-burst rule is a watch or block like any other, so its refusals (and
+// record-only would-be refusals) are kept; its trip records are kind "trip",
+// not a request caught, and stay out. Only the edge
// stream counts: an app's own output can carry any fields it likes.
func protectionLogRecord(rec applog.Record) bool {
if rec.Stream != applog.StreamEdge {
diff --git a/internal/console/protectionview_test.go b/internal/console/protectionview_test.go
index fd3f47d43..f9b899caa 100644
--- a/internal/console/protectionview_test.go
+++ b/internal/console/protectionview_test.go
@@ -242,7 +242,9 @@ func TestEveryCatalogueGroupHasAName(t *testing.T) {
if got := protectionGroupName("probe/nosuch"); got != other {
t.Errorf("unknown group = %q, want %q", got, other)
}
- for _, r := range edgeguard.Rules() {
+ // The burst rule sits outside Rules(), but its refusals are tallied
+ // under its group too.
+ for _, r := range append(edgeguard.Rules(), *edgeguard.BurstRule) {
key := r.Tier.String() + "/" + r.Group
if protectionGroupName(key) == other {
t.Errorf("catalogue group %s has no name", key)
@@ -250,6 +252,16 @@ func TestEveryCatalogueGroupHasAName(t *testing.T) {
}
}
+func TestBurstGroupNamed(t *testing.T) {
+ key := edgeguard.BurstRule.Tier.String() + "/" + edgeguard.BurstRule.Group
+ if key != "burst/probe-burst" {
+ t.Fatalf("burst rule group key = %q", key)
+ }
+ if got, want := protectionGroupName(key), pbCopy(t, "PB-C02"); got != want {
+ t.Errorf("burst group name = %q, want %q", got, want)
+ }
+}
+
func ptCopyText(t *testing.T, id string) string { return ptCopy(t, id, nil) }
func TestAppNavHasProtection(t *testing.T) {
@@ -339,6 +351,26 @@ func TestLogsProtectionFilter(t *testing.T) {
}
}
+// A refusal (or would-be refusal, in record-only) is a catalogue match and
+// is kept. The trip record is the client being put on cool-down, not a
+// request caught, so it stays out; it shows in Logs under the edge stream.
+func TestLogsProtectionFilterKeepsBurst(t *testing.T) {
+ fx, c := ptFixture(t)
+ now := time.Now().UTC().Add(-10 * time.Minute)
+ ptLogRecords(t, fx, "box-a", []applog.Record{
+ ptEdgeRecord(now, 100, "block", edgeguard.BurstRule.ID, "/wp-login.php"),
+ ptEdgeRecord(now.Add(time.Second), 101, "watch", edgeguard.BurstRule.ID, "/wp-login.php"),
+ ptEdgeRecord(now.Add(2*time.Second), 102, "trip", edgeguard.BurstRule.ID, "/wp-login.php"),
+ })
+ got := ptMsgs(ptLogsData(t, fx, c, "stream=edge&protection=1").Lines)
+ if len(got) != 2 || !strings.Contains(got[0], "block") || !strings.Contains(got[1], "watch") {
+ t.Errorf("protection=1 lines = %q, want the burst block and the burst watch", got)
+ }
+ if all := ptLogsData(t, fx, c, "stream=edge").Lines; len(all) != 3 {
+ t.Errorf("edge stream = %d lines, want 3 with the trip", len(all))
+ }
+}
+
// The filter runs inside the read, before the collect cap trims the
// window's oldest records: a match older than a full cap of ordinary edge
// records is still found, by the data door, its follow, and the CLI door.