Name log fields, metrics and the Core Rule Set package for what they are (closes #192)
check / check (push) Failing after 5m32s
check / check (push) Failing after 5m32s
Log field, metric, action and event names now say what they count and, for timings, the unit. Package internal/waf is internal/coreruleset. Model: opus-5-5
This commit is contained in:
1 parent
aede434f6a
commit
9e6abf8496
58 files changed
+743
-691
No files matched your search
+2
-2
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"sneak.berlin/go/smallwebwaf/internal/alerts"
|
||||
"sneak.berlin/go/smallwebwaf/internal/config"
|
||||
"sneak.berlin/go/smallwebwaf/internal/coreruleset"
|
||||
"sneak.berlin/go/smallwebwaf/internal/discriminator"
|
||||
"sneak.berlin/go/smallwebwaf/internal/lookup"
|
||||
"sneak.berlin/go/smallwebwaf/internal/remotelog"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"sneak.berlin/go/smallwebwaf/internal/requestlog"
|
||||
"sneak.berlin/go/smallwebwaf/internal/rules"
|
||||
"sneak.berlin/go/smallwebwaf/internal/state"
|
||||
"sneak.berlin/go/smallwebwaf/internal/waf"
|
||||
)
|
||||
|
||||
// shutdownTimeout is how long requests in progress may take to finish
|
||||
@@ -197,7 +197,7 @@ func RunDiscriminator(ctx context.Context, params Params) int {
|
||||
func newServer(
|
||||
cfg *config.Config, stdout io.Writer, processLog *slog.Logger,
|
||||
now func() time.Time, ruleFiles *rules.Files, alertQueue *alerts.Queue,
|
||||
crs *waf.CoreRuleSet,
|
||||
crs *coreruleset.CoreRuleSet,
|
||||
) (*discriminator.Server, error) {
|
||||
var lookupFile *lookup.File
|
||||
|
||||
|
||||
@@ -962,7 +962,7 @@ func TestStalledRemoteLogEndpointHoldsUpNoRequest(t *testing.T) {
|
||||
metrics := metricsText(t, url+"_sww/metrics", token)
|
||||
for _, series := range []string{
|
||||
`sww_remote_log_lines_sent_total{instance="fsn1app1/blog"} 0`,
|
||||
`sww_remote_log_buffer_depth{instance="fsn1app1/blog"} 1`,
|
||||
`sww_remote_log_lines_waiting{instance="fsn1app1/blog"} 1`,
|
||||
} {
|
||||
if !strings.Contains(metrics, "\n"+series+"\n") {
|
||||
t.Errorf("no %q in the metrics:\n%s", series, metrics)
|
||||
@@ -1068,8 +1068,12 @@ func TestBanIsAlertedAndAnAlertNotSentIsKeptAcrossARestart(t *testing.T) {
|
||||
metrics := metricsWith(t, url+"_sww/metrics", token,
|
||||
"\nsww_alerts_sent_total"+ofWebhook+" 1\n")
|
||||
|
||||
for _, series := range []string{"failed", "suppressed", "dropped"} {
|
||||
zero := "\nsww_alerts_" + series + "_total" + ofWebhook + " 0\n"
|
||||
for _, series := range []string{
|
||||
"sww_alert_send_failures_total",
|
||||
"sww_alerts_suppressed_total",
|
||||
"sww_alerts_dropped_total",
|
||||
} {
|
||||
zero := "\n" + series + ofWebhook + " 0\n"
|
||||
if !strings.Contains(metrics, zero) {
|
||||
t.Errorf("no %q in the metrics:\n%s", zero, metrics)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user