Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2b214a0f5 |
No files matched your search
@@ -1198,8 +1198,7 @@ two lines a line is. `docs/request-log.md` gives the fields.
|
|||||||
### `servewaf`'s own endpoints
|
### `servewaf`'s own endpoints
|
||||||
|
|
||||||
A request without `X-Smallwebwaf-Client` is for `servewaf` itself, at its own
|
A request without `X-Smallwebwaf-Client` is for `servewaf` itself, at its own
|
||||||
address on the private network. The internet must not be able to reach that
|
address on the private network. Nothing routes the internet there. These are:
|
||||||
address. Its endpoints are:
|
|
||||||
|
|
||||||
- the health check, the metrics, and the ban and client endpoints, as
|
- the health check, the metrics, and the ban and client endpoints, as
|
||||||
`docs/admin-endpoints.md` lists them, with the same tokens;
|
`docs/admin-endpoints.md` lists them, with the same tokens;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Command smallwebwaf is a web application firewall for one app: it runs
|
// Command smallwebwaf is a web application firewall for one app: it runs
|
||||||
// between traefik and the app and passes requests through within its limits,
|
// between traefik and the app, and passes requests through within its
|
||||||
// or, as `smallwebwaf servewaf`, answers rproxy's questions about them.
|
// limits. Everything it does is in internal/smallwebwaf.
|
||||||
// Everything it does is in internal/smallwebwaf.
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
+3
-4
@@ -153,8 +153,7 @@ It has the fields above, with these meanings where they differ:
|
|||||||
- `action`: `forward` for `allow`, and `admin` for the `404` for a path under
|
- `action`: `forward` for `allow`, and `admin` for the `404` for a path under
|
||||||
`/_smallwebwaf/`.
|
`/_smallwebwaf/`.
|
||||||
- `aborted`: true when `rproxy` went away before the answer.
|
- `aborted`: true when `rproxy` went away before the answer.
|
||||||
- `duration_total`: from `servewaf` having read the question's body to the line.
|
- `duration_total`: from the question's headers being read to the line.
|
||||||
- `time`: when `servewaf` had read the question's body.
|
|
||||||
|
|
||||||
The line leaves out `upstream_status`, `websocket` and the
|
The line leaves out `upstream_status`, `websocket` and the
|
||||||
`duration_upstream_...` fields, since `servewaf` passes nothing to the app.
|
`duration_upstream_...` fields, since `servewaf` passes nothing to the app.
|
||||||
@@ -164,8 +163,8 @@ holds the client's bytes without this request's.
|
|||||||
|
|
||||||
### The `report` line
|
### The `report` line
|
||||||
|
|
||||||
It has every field of the `decision` line, and `time` stays as the `decision`
|
It has every field of the `decision` line, and `time` stays when the request
|
||||||
line gives it. These fields say what the report says:
|
arrived. These fields say what the report says:
|
||||||
|
|
||||||
- `status`: what the visitor got, `0` if nothing;
|
- `status`: what the visitor got, `0` if nothing;
|
||||||
- `request_bytes` and `response_bytes`: the body bytes each way, with what a
|
- `request_bytes` and `response_bytes`: the body bytes each way, with what a
|
||||||
|
|||||||
@@ -954,17 +954,6 @@ func TestMetricsCountAnAllowedRequestFromItsReport(t *testing.T) {
|
|||||||
wantMetric(t, metrics, "smallwebwaf_response_bytes_total"+series, answerBytes)
|
wantMetric(t, metrics, "smallwebwaf_response_bytes_total"+series, answerBytes)
|
||||||
wantMetric(t, metrics, `smallwebwaf_upstream_duration_seconds_sum{instance="`+
|
wantMetric(t, metrics, `smallwebwaf_upstream_duration_seconds_sum{instance="`+
|
||||||
alertInstance+`"}`, 0.004)
|
alertInstance+`"}`, 0.004)
|
||||||
|
|
||||||
// A scrape adds its own time to the request duration when it ends, so this
|
|
||||||
// check needs a server that has not been scraped yet.
|
|
||||||
unscraped := startServeWAF(t, "", map[string]string{metricsToken: token})
|
|
||||||
|
|
||||||
got = unscraped.report(proxy.Report{
|
|
||||||
RequestID: unscraped.allowed(client), Status: http.StatusBadGateway, DurationTotal: 5,
|
|
||||||
})
|
|
||||||
wantStatus(t, got, http.StatusNoContent)
|
|
||||||
wantMetric(t, unscraped.metrics(),
|
|
||||||
`smallwebwaf_request_duration_seconds_sum{instance="`+alertInstance+`"}`, 0.005)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReportForARequestNotHeldIsIgnored(t *testing.T) {
|
func TestReportForARequestNotHeldIsIgnored(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user