diff --git a/go.mod b/go.mod index 7eb7fe65..ceac257c 100644 --- a/go.mod +++ b/go.mod @@ -5,15 +5,15 @@ go 1.25.0 require ( github.com/PuerkitoBio/goquery v1.12.0 github.com/go-pkgz/lgr v0.12.3 - github.com/go-pkgz/rest v1.21.0 + github.com/go-pkgz/rest v1.23.1 github.com/go-pkgz/routegroup v1.6.0 github.com/go-pkgz/testutils v0.6.0 github.com/jessevdk/go-flags v1.6.1 github.com/kennygrant/sanitize v1.2.4 github.com/mauidude/go-readability v0.0.0-20220221173116-a9b3620098b7 github.com/stretchr/testify v1.11.1 - go.mongodb.org/mongo-driver/v2 v2.7.0 - golang.org/x/net v0.56.0 + go.mongodb.org/mongo-driver/v2 v2.8.0 + golang.org/x/net v0.57.0 ) require ( @@ -95,9 +95,9 @@ require ( go.opentelemetry.io/otel v1.43.0 // indirect go.opentelemetry.io/otel/metric v1.43.0 // indirect go.opentelemetry.io/otel/trace v1.43.0 // indirect - golang.org/x/crypto v0.53.0 // indirect - golang.org/x/sync v0.21.0 // indirect - golang.org/x/sys v0.46.0 // indirect - golang.org/x/text v0.38.0 // indirect + golang.org/x/crypto v0.54.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/text v0.40.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c239b2dd..c59e74f0 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-pkgz/lgr v0.12.3 h1:QDug7kRkEsuQtruT9fNF5PVT2kZUqCDPc4GmsgS3fP8= github.com/go-pkgz/lgr v0.12.3/go.mod h1:lpCDgVvCIxBHZp8+sGCj9MPctIzKZyZ3QdE19ddqd54= -github.com/go-pkgz/rest v1.21.0 h1:Y/C4d/TpclJJDxqnH1RAcS6Hmox0RIReAlkwMcUWXK4= -github.com/go-pkgz/rest v1.21.0/go.mod h1:+AHzjHazq7Z3Tk/kRWOhbbAz/YZlUV40feC1Hf4NtbE= +github.com/go-pkgz/rest v1.23.1 h1:Vp+znk3wC7NcISKdlcMiBSnDb1R0akx3V7sztBzvAeQ= +github.com/go-pkgz/rest v1.23.1/go.mod h1:+AHzjHazq7Z3Tk/kRWOhbbAz/YZlUV40feC1Hf4NtbE= github.com/go-pkgz/routegroup v1.6.0 h1:44XHZgF6JIIldRlv+zjg6SygULASmjifnfIQjwCT0e4= github.com/go-pkgz/routegroup v1.6.0/go.mod h1:Pmu04fhgWhRtBMIJ8HXppnnzOPjnL/IEPBIdO2zmeqg= github.com/go-pkgz/testutils v0.6.0 h1:+hHdikZAZm7EISWrbJ0Od42eQIAUSwoFFsTBtq3ZRKI= @@ -347,8 +347,8 @@ github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU= go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ= -go.mongodb.org/mongo-driver/v2 v2.7.0 h1:RO+zqavD2/GCL3cxOMyZhx6R9Irzr8/6gsoqx5tcY/c= -go.mongodb.org/mongo-driver/v2 v2.7.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= +go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= +go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= @@ -375,8 +375,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= -golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= +golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= +golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -415,8 +415,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= -golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= +golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= +golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -426,8 +426,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -450,20 +450,20 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= -golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= -golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= -golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= +golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= +golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/go-pkgz/rest/CLAUDE.md b/vendor/github.com/go-pkgz/rest/CLAUDE.md new file mode 100644 index 00000000..cb942c24 --- /dev/null +++ b/vendor/github.com/go-pkgz/rest/CLAUDE.md @@ -0,0 +1,54 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## What this is + +`github.com/go-pkgz/rest` is a library of HTTP middlewares and small helpers for REST services. It is not an application — there is no `main`, no server, no CLI. It is consumed by other projects (remark42, etc.). Keep the public API stable and minimal. + +Dependencies are deliberately tiny: only `stretchr/testify` (tests) and `golang.org/x/crypto` (Argon2/bcrypt for BasicAuth). Do not add a routing framework or logging library dependency — middlewares are plain stdlib and must stay router-agnostic. + +## Commands + +- Test everything: `go test ./...` +- Single test: `go test -run TestName ./...` (e.g. `go test -run TestPing ./...`) +- Race + coverage (mirrors CI): `TZ="America/Chicago" go test -timeout=60s -race -covermode=atomic ./...` +- Lint (run from repo root): `golangci-lint run --max-issues-per-linter=0 --max-same-issues=0` + +Time-parsing tests (`ParseFromTo`) are timezone-sensitive; CI runs with `TZ=America/Chicago`. Set it locally if a from/to test behaves oddly. + +## Architecture + +Three packages: +- **`rest`** (root) — all middlewares plus JSON/error/file-server helpers. +- **`logger`** — request-logging middleware, split out so it can be wired to any backend via the `logger.Backend` interface (`Logf(format, args...)`). Configured with functional options (`logger.New(logger.Prefix(...), logger.WithBody, ...)`). +- **`realip`** — `realip.Get(r)` extracts the client IP from proxy headers. Used by both `rest.RealIP` and the `logger` package. Only public IPs are accepted from headers. + +### Middleware conventions + +Every middleware is a `func(http.Handler) http.Handler` (or a `func(...) func(http.Handler) http.Handler` when it takes config). This is the chi/stdlib-compatible shape — match it for any new middleware. Some middlewares short-circuit the chain (`Ping`, `Health`, metrics) by writing a response and returning without calling the next handler. + +Configurable middlewares use the **functional-options pattern**, not option structs: +- `CORS(CorsAllowedOrigins(...), CorsAllowCredentials(true), ...)` — options named `CorsXxx`. +- `Secure(SecFrameOptions(...), SecHSTS(...), ...)` — options named `SecXxx`, plus `SecAllHeaders()` convenience. +- `logger.New(logger.Prefix(...), ...)` — options in `logger/options.go`. + +When adding an option to one of these, follow the existing prefix/naming and keep defaults sensible so calling the constructor with no options is safe. + +### CSRF build-tag split (important) + +CSRF protection has **two implementations behind one identical public API**, selected by Go version: +- `csrf_go125.go` (`//go:build go1.25`) — thin wrapper over stdlib `http.CrossOriginProtection`. +- `csrf.go` (`//go:build !go1.25`) — self-contained equivalent for older Go. + +`NewCrossOriginProtection`, `AddTrustedOrigin`, `AddBypassPattern`, `SetDenyHandler`, `Check`, `Handler` must exist with the **same signatures and behavior in both files**. When you change the CSRF API or behavior, edit both files and keep `csrf_test.go` passing under both build tags. go.mod targets go 1.24, so by default the `!go1.25` path compiles unless building with a 1.25 toolchain. + +### Helpers + +`rest.go` holds the JSON render/encode/decode helpers (`RenderJSON`, `EncodeJSON`/`DecodeJSON` generics, `RenderJSONWithHTML`) and `ParseFromTo`. `httperrors.go` has `SendErrorJSON`/`NewErrorLogger`. `file_server.go` has `FileServer` (directory listing disabled by design). `benchmarks.go` keeps an in-memory ring of up to 900 per-second data points (15 min) queried via `Stats(duration)`. + +## Conventions + +- **One test file per source file**: `foo.go` → `foo_test.go` only. Table-driven with testify. Note `depricattion.go`/`depricattion_test.go` is misspelled but is the real filename — don't "fix" it without intent, it's the established path. +- After changing or adding a middleware/helper, update `README.md` — it documents every middleware and helper and is the primary user-facing doc. +- Lint config (`.golangci.yml`) is strict (`govet enable-all`, revive, gocritic with performance/style/experimental). `modernize` is enabled — prefer `any` over `interface{}`, `slices`/`maps` stdlib, etc. diff --git a/vendor/github.com/go-pkgz/rest/README.md b/vendor/github.com/go-pkgz/rest/README.md index 749e0dac..c263f6ed 100644 --- a/vendor/github.com/go-pkgz/rest/README.md +++ b/vendor/github.com/go-pkgz/rest/README.md @@ -92,6 +92,8 @@ Logs request, request handling time and response. Log record fields in order of _remote IP can be masked with user defined function_ +_request body can be transformed before logging with a user-defined function (`BodyFn`), e.g. to mask credentials. It only runs when body logging is on (`WithBody`), and receives the body along with a `truncated` flag that is set when the body exceeded `MaxBodySize` - the function can use it to emit a marker instead of logging a partial body it can't safely process_ + example: `019/03/05 17:26:12.976 [INFO] GET - /api/v1/find?site=remark - 8e228e9cfece - 200 (115) - 4.47784618s` ### Recoverer middleware @@ -182,6 +184,14 @@ RealIP is a middleware that sets a http.Request's RemoteAddr to the results of p Only public IPs are accepted from headers; private/loopback/link-local IPs are skipped. This makes the middleware compatible with CDN setups like Cloudflare where the leftmost IP in `X-Forwarded-For` is the actual client. +### Timeout middleware + +Timeout bounds a request to the given duration and responds with `StatusGatewayTimeout` (504) at the deadline if the handler has not finished — even for a handler that does not observe the context. The handler runs with a context deadline and its output is buffered; on success the buffered response is written through unchanged, and if the deadline fires first the buffered output is discarded, a 504 is sent, and further writes by the still-running handler return `http.ErrHandlerTimeout`. Because the response is buffered, `http.Flusher` and `http.Hijacker` are not available under `Timeout` (as with `net/http.TimeoutHandler`), so it is not suitable for streaming or connection-hijacking handlers. A non-positive duration disables the middleware (the handler is called directly). + +```go +router.Use(rest.Timeout(5 * time.Second)) +``` + ### CORS middleware Handles Cross-Origin Resource Sharing, allowing controlled access from different origins. @@ -213,6 +223,7 @@ Features: - Origin validation with case-insensitive matching - Credentials support (reflects origin instead of `*`) - Configurable cache duration for preflight results +- Cache-correct `Vary` headers (adds `Access-Control-Request-Method` and `Access-Control-Request-Headers` on preflight) Available options: - `CorsAllowedOrigins(origins...)` - allowed origins (default: `*`) diff --git a/vendor/github.com/go-pkgz/rest/cors.go b/vendor/github.com/go-pkgz/rest/cors.go index df7d8f9c..f8d7edd3 100644 --- a/vendor/github.com/go-pkgz/rest/cors.go +++ b/vendor/github.com/go-pkgz/rest/cors.go @@ -158,6 +158,9 @@ func CORS(opts ...CorsOpt) func(http.Handler) http.Handler { // handle preflight request if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" { // preflight request + // the response varies by the requested method and headers, so caches must key on them + w.Header().Add("Vary", "Access-Control-Request-Method") + w.Header().Add("Vary", "Access-Control-Request-Headers") w.Header().Set("Access-Control-Allow-Methods", methodsStr) w.Header().Set("Access-Control-Allow-Headers", headersStr) diff --git a/vendor/github.com/go-pkgz/rest/logger/logger.go b/vendor/github.com/go-pkgz/rest/logger/logger.go index df409320..7a9cdef0 100644 --- a/vendor/github.com/go-pkgz/rest/logger/logger.go +++ b/vendor/github.com/go-pkgz/rest/logger/logger.go @@ -26,6 +26,7 @@ type Middleware struct { ipFn func(ip string) string userFn func(r *http.Request) (string, error) subjFn func(r *http.Request) (string, error) + bodyFn func(body string, truncated bool) string log Backend apacheCombined bool } @@ -104,6 +105,9 @@ func (l *Middleware) Handler(next http.Handler) http.Handler { if unescURL, err := url.QueryUnescape(rawurl); err == nil { rawurl = unescURL } + // unescaping can surface line breaks the encoded url hid, collapse them the same way + // the body is collapsed so an embedded break can't forge additional log records + rawurl = lineBreaks.Replace(rawurl) remoteIP, err := realip.Get(r) if err != nil { @@ -131,7 +135,7 @@ func (l *Middleware) Handler(next http.Handler) http.Handler { body: body, } - l.log.Logf(formater(r, p)) + l.log.Logf("%s", formater(r, p)) }() next.ServeHTTP(ww, r) @@ -146,8 +150,8 @@ func (l *Middleware) formatDefault(r *http.Request, p *logParts) string { _, _ = bld.WriteString(" ") } - _, _ = bld.WriteString(fmt.Sprintf("%s - %s - %s - %s - %d (%d) - %v", - p.method, p.rawURL, p.host, p.remoteIP, p.statusCode, p.respSize, p.duration)) + _, _ = fmt.Fprintf(&bld, "%s - %s - %s - %s - %d (%d) - %v", + p.method, p.rawURL, p.host, p.remoteIP, p.statusCode, p.respSize, p.duration) if p.user != "" { _, _ = bld.WriteString(" - ") @@ -191,7 +195,7 @@ func (l *Middleware) formatApacheCombined(r *http.Request, p *logParts) string { bld.WriteString(p.method) bld.WriteString(" ") bld.WriteString(p.rawURL) - bld.WriteString(`" `) + bld.WriteString(" ") bld.WriteString(r.Proto) bld.WriteString(`" `) bld.WriteString(strconv.Itoa(p.statusCode)) @@ -208,6 +212,19 @@ func (l *Middleware) formatApacheCombined(r *http.Request, p *logParts) string { var reMultWhtsp = regexp.MustCompile(`[\s\p{Zs}]{2,}`) +// lineBreaks maps every character that can start a new line to a space, so a body +// can't forge extra log records. reMultWhtsp only collapses runs of two or more, so +// a lone CR or a Unicode line separator would otherwise slip through. +var lineBreaks = strings.NewReplacer( + "\n", " ", // LF + "\r", " ", // CR + "\v", " ", // vertical tab + "\f", " ", // form feed + "\u0085", " ", // NEL + "\u2028", " ", // line separator + "\u2029", " ", // paragraph separator +) + func (l *Middleware) getBody(r *http.Request) string { if !l.logBody { return "" @@ -226,13 +243,24 @@ func (l *Middleware) getBody(r *http.Request) string { // https://golang.org/pkg/net/http/#Handler r.Body = io.NopCloser(reader) - if body != "" { - body = strings.ReplaceAll(body, "\n", " ") - body = reMultWhtsp.ReplaceAllString(body, " ") + // the transform owns the logged body: it receives the body (capped at + // maxBodySize) and a flag telling it whether more was dropped, and decides + // how to render it - mask values, summarize, or emit a marker for a + // truncated body. an empty body has nothing to transform, so it is left + // alone. without a transform the body is logged as read, with the "..." + // marker appended when it was truncated. + switch { + case l.bodyFn != nil && body != "": + body = l.bodyFn(body, hasMore) + case hasMore: + body += "..." } - if hasMore { - body += "..." + // always collapse to a single line, regardless of the transform, so an + // embedded line break in the body can't forge additional log lines. + if body != "" { + body = lineBreaks.Replace(body) + body = reMultWhtsp.ReplaceAllString(body, " ") } return body diff --git a/vendor/github.com/go-pkgz/rest/logger/options.go b/vendor/github.com/go-pkgz/rest/logger/options.go index b0e41994..8156e0da 100644 --- a/vendor/github.com/go-pkgz/rest/logger/options.go +++ b/vendor/github.com/go-pkgz/rest/logger/options.go @@ -49,6 +49,20 @@ func SubjFn(subjFn func(r *http.Request) (string, error)) Option { } } +// BodyFn sets a transform applied to the request body before it is logged, e.g. to +// mask secrets. It only runs when body logging is enabled (see WithBody) and the +// body is non-empty; if bodyFn is nil the body is logged unchanged. bodyFn receives +// the body (capped at MaxBodySize) and a truncated flag that is true when the body was longer than +// MaxBodySize and got cut short - a masker can use it to emit a marker instead of +// risking a pass-through of a partial body it cannot parse. The returned string is +// what gets logged, so bodyFn owns the content; the logger still collapses it to a +// single line to keep one log record per request. +func BodyFn(bodyFn func(body string, truncated bool) string) Option { + return func(l *Middleware) { + l.bodyFn = bodyFn + } +} + // ApacheCombined sets format to Apache Combined Log. // See http://httpd.apache.org/docs/2.2/logs.html#combined func ApacheCombined(l *Middleware) { diff --git a/vendor/github.com/go-pkgz/rest/middleware.go b/vendor/github.com/go-pkgz/rest/middleware.go index 59e9f069..30505073 100644 --- a/vendor/github.com/go-pkgz/rest/middleware.go +++ b/vendor/github.com/go-pkgz/rest/middleware.go @@ -5,6 +5,7 @@ import ( "net/http" "os" "runtime/debug" + "slices" "strings" "github.com/go-pkgz/rest/logger" @@ -13,8 +14,8 @@ import ( // Wrap converts a list of middlewares to nested calls (in reverse order) func Wrap(handler http.Handler, mws ...func(http.Handler) http.Handler) http.Handler { - for i := len(mws) - 1; i >= 0; i-- { - handler = mws[i](handler) + for _, mw := range slices.Backward(mws) { + handler = mw(handler) } return handler } diff --git a/vendor/github.com/go-pkgz/rest/timeout.go b/vendor/github.com/go-pkgz/rest/timeout.go new file mode 100644 index 00000000..883b0a11 --- /dev/null +++ b/vendor/github.com/go-pkgz/rest/timeout.go @@ -0,0 +1,133 @@ +package rest + +import ( + "bytes" + "context" + "maps" + "net/http" + "sync" + "time" +) + +// Timeout is a middleware that enforces a maximum duration for handling a request. +// It runs the next handler with a context deadline and, if the handler has not finished +// by the time the deadline is reached, responds with StatusGatewayTimeout (504) at the +// deadline — regardless of whether the handler observes the context. +// +// The handler's output is buffered until it completes: on success the buffered response +// (status, headers and body) is written through unchanged; if the deadline fires first, +// the buffered output is discarded, a 504 is sent, and any further writes by the still +// running handler return http.ErrHandlerTimeout. If the parent request context is +// canceled (rather than the deadline being exceeded) the handler is stopped without a +// 504, since the request is being abandoned, and its later writes return the context's +// error (e.g. context.Canceled). +// +// Because the response is buffered, the wrapped ResponseWriter does not support +// http.Flusher or http.Hijacker (matching net/http.TimeoutHandler); streaming and +// connection hijacking are not available under Timeout. +// +// A non-positive timeout disables the middleware: the handler is called directly, with +// no deadline, buffering or 504. +func Timeout(timeout time.Duration) func(http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + if timeout <= 0 { + return next + } + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx, cancel := context.WithTimeout(r.Context(), timeout) + defer cancel() + r = r.WithContext(ctx) + + done := make(chan struct{}) + panicChan := make(chan any, 1) + tw := &timeoutWriter{w: w, h: make(http.Header)} + + go func() { + defer func() { + if p := recover(); p != nil { + panicChan <- p + } + }() + next.ServeHTTP(tw, r) + close(done) + }() + + select { + case p := <-panicChan: + panic(p) + case <-done: + tw.mu.Lock() + defer tw.mu.Unlock() + maps.Copy(w.Header(), tw.h) + code := http.StatusOK + if tw.wroteHeader { + code = tw.code + } + w.WriteHeader(code) + _, _ = w.Write(tw.wbuf.Bytes()) + case <-ctx.Done(): + tw.mu.Lock() + defer tw.mu.Unlock() + // discard the buffer and stop further handler writes, recording the cause so a + // late write returns the real error. Only the deadline yields a 504; a canceled + // parent means the request is being abandoned, so there is nobody to send it to. + switch err := ctx.Err(); err { + case context.DeadlineExceeded: + tw.err = http.ErrHandlerTimeout + w.WriteHeader(http.StatusGatewayTimeout) + default: + tw.err = err + } + } + }) + } +} + +// timeoutWriter buffers a handler's response so the Timeout middleware can either flush +// it on success or discard it and send a 504 once the deadline is reached. All fields +// after mu are guarded by mu, which is also held by the middleware while it drains the +// buffer, so it is safe against a handler goroutine that keeps writing after the timeout. +type timeoutWriter struct { + w http.ResponseWriter + h http.Header + + mu sync.Mutex + wbuf bytes.Buffer + code int + wroteHeader bool + err error // set once the response is timed out or canceled; returned by Write +} + +// Header implements http.ResponseWriter and returns the buffered header map. +func (tw *timeoutWriter) Header() http.Header { return tw.h } + +// Write implements http.ResponseWriter, buffering the response body. Once the response has +// timed out or been canceled it buffers nothing and returns the recorded error +// (http.ErrHandlerTimeout on deadline, or the context error on cancellation). +func (tw *timeoutWriter) Write(p []byte) (int, error) { + tw.mu.Lock() + defer tw.mu.Unlock() + if tw.err != nil { + return 0, tw.err + } + if !tw.wroteHeader { + tw.setHeaderLocked(http.StatusOK) + } + return tw.wbuf.Write(p) +} + +// WriteHeader implements http.ResponseWriter, recording the status for the buffered +// response. It is a no-op after the timeout has fired or after the first call. +func (tw *timeoutWriter) WriteHeader(code int) { + tw.mu.Lock() + defer tw.mu.Unlock() + tw.setHeaderLocked(code) +} + +func (tw *timeoutWriter) setHeaderLocked(code int) { + if tw.err != nil || tw.wroteHeader { + return + } + tw.wroteHeader = true + tw.code = code +} diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/bulk_write.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/bulk_write.go index 1065cdfd..df9d4eb4 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/bulk_write.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/bulk_write.go @@ -186,7 +186,7 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (inser maxAdaptiveRetries := bw.collection.client.effectiveAdaptiveRetries(bw.collection.client.retryWrites) - op := insert{ + op := insertOp{ documents: docs, session: bw.session, writeConcern: bw.writeConcern, @@ -360,7 +360,7 @@ func createDeleteDoc( return doc, nil } -func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (operation.UpdateResult, error) { +func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (updateResult, error) { docs := make([]bsoncore.Document, len(batch.models)) var hasHint bool var hasArrayFilters bool @@ -407,7 +407,7 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera hasArrayFilters = hasArrayFilters || (converted.ArrayFilters != nil) } if err != nil { - return operation.UpdateResult{}, err + return updateResult{}, err } docs[i] = doc @@ -420,42 +420,52 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera maxAdaptiveRetries := bw.collection.client.effectiveAdaptiveRetries(bw.collection.client.retryWrites) - op := operation.NewUpdate(docs...). - Session(bw.session).WriteConcern(bw.writeConcern).CommandMonitor(bw.collection.client.monitor). - ServerSelector(bw.selector).ClusterClock(bw.collection.client.clock). - Database(bw.collection.db.name).Collection(bw.collection.name). - Retry(retry).MaxAdaptiveRetries(maxAdaptiveRetries). - EnableOverloadRetargeting(bw.collection.client.enableOverloadRetargeting). - Deployment(bw.collection.client.deployment).Crypt(bw.collection.client.cryptFLE).Hint(hasHint). - ArrayFilters(hasArrayFilters).ServerAPI(bw.collection.client.serverAPI). - Timeout(bw.collection.client.timeout).Logger(bw.collection.client.logger). - Authenticator(bw.collection.client.authenticator) + op := updateOp{ + updates: docs, + session: bw.session, + writeConcern: bw.writeConcern, + monitor: bw.collection.client.monitor, + selector: bw.selector, + clock: bw.collection.client.clock, + database: bw.collection.db.name, + collection: bw.collection.name, + deployment: bw.collection.client.deployment, + crypt: bw.collection.client.cryptFLE, + serverAPI: bw.collection.client.serverAPI, + timeout: bw.collection.client.timeout, + logger: bw.collection.client.logger, + authenticator: bw.collection.client.authenticator, + retry: &retry, + maxAdaptiveRetries: maxAdaptiveRetries, + enableOverloadRetargeting: bw.collection.client.enableOverloadRetargeting, + hint: &hasHint, + arrayFilters: &hasArrayFilters, + } if bw.comment != nil { comment, err := marshalValue(bw.comment, bw.collection.bsonOpts, bw.collection.registry) if err != nil { return op.Result(), err } - op.Comment(comment) + op.comment = comment } if bw.let != nil { let, err := marshal(bw.let, bw.collection.bsonOpts, bw.collection.registry) if err != nil { - return operation.UpdateResult{}, err + return updateResult{}, err } - op = op.Let(let) + op.let = let } if bw.ordered != nil { - op = op.Ordered(*bw.ordered) + op.ordered = bw.ordered } if bw.bypassDocumentValidation != nil && *bw.bypassDocumentValidation { - op = op.BypassDocumentValidation(*bw.bypassDocumentValidation) + op.bypassDocumentValidation = bw.bypassDocumentValidation } - if bw.rawData != nil { - op.RawData(*bw.rawData) + op.rawData = bw.rawData } if len(bw.additionalCmd) > 0 { - op.AdditionalCmd(bw.additionalCmd) + op.additionalCmd = bw.additionalCmd } err := op.Execute(ctx) diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/client_encryption.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/client_encryption.go index d5538f02..67b01547 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/client_encryption.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/client_encryption.go @@ -245,29 +245,29 @@ func transformExplicitEncryptionOptions(opts ...options.Lister[options.EncryptOp } transformed.RangeOptions = &transformedRange } - if args.TextOptions != nil { - textArgs, err := mongoutil.NewOptions[options.TextOptions](args.TextOptions) + if args.StringOptions != nil { + stringArgs, err := mongoutil.NewOptions[options.StringOptions](args.StringOptions) if err != nil { return nil, err } - transformedText := mcopts.ExplicitTextOptions{ - CaseSensitive: textArgs.CaseSensitive, - DiacriticSensitive: textArgs.DiacriticSensitive, + transformedString := mcopts.ExplicitStringOptions{ + CaseSensitive: stringArgs.CaseSensitive, + DiacriticSensitive: stringArgs.DiacriticSensitive, } - if textArgs.Substring != nil { - substringOpts := mcopts.SubstringOptions(*textArgs.Substring) - transformedText.Substring = &substringOpts + if stringArgs.Substring != nil { + substringOpts := mcopts.SubstringOptions(*stringArgs.Substring) + transformedString.Substring = &substringOpts } - if textArgs.Prefix != nil { - prefixOpts := mcopts.PrefixOptions(*textArgs.Prefix) - transformedText.Prefix = &prefixOpts + if stringArgs.Prefix != nil { + prefixOpts := mcopts.PrefixOptions(*stringArgs.Prefix) + transformedString.Prefix = &prefixOpts } - if textArgs.Suffix != nil { - suffixOpts := mcopts.SuffixOptions(*textArgs.Suffix) - transformedText.Suffix = &suffixOpts + if stringArgs.Suffix != nil { + suffixOpts := mcopts.SuffixOptions(*stringArgs.Suffix) + transformedString.Suffix = &suffixOpts } - transformed.SetTextOptions(transformedText) + transformed.SetStringOptions(transformedString) } return transformed, nil } diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/collection.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/collection.go index 11c649ce..3f1df6db 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/collection.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/collection.go @@ -312,7 +312,7 @@ func (coll *Collection) insert( selector := makePinnedSelector(sess, coll.writeSelector) - op := insert{ + op := insertOp{ documents: docs, session: sess, writeConcern: wc, @@ -715,38 +715,53 @@ func (coll *Collection) updateOrReplace( selector := makePinnedSelector(sess, coll.writeSelector) - op := operation.NewUpdate(updateDoc). - Session(sess).WriteConcern(wc).CommandMonitor(coll.client.monitor). - Retry(retry).MaxAdaptiveRetries(maxAdaptiveRetries). - EnableOverloadRetargeting(coll.client.enableOverloadRetargeting). - ServerSelector(selector).ClusterClock(coll.client.clock). - Database(coll.db.name).Collection(coll.name). - Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).Hint(args.Hint != nil). - ArrayFilters(args.ArrayFilters != nil).Ordered(true).ServerAPI(coll.client.serverAPI). - Timeout(coll.client.timeout).Logger(coll.client.logger).Authenticator(coll.client.authenticator) + ordered := true + hint := args.Hint != nil + arrayFilters := args.ArrayFilters != nil + op := updateOp{ + updates: []bsoncore.Document{updateDoc}, + session: sess, + writeConcern: wc, + monitor: coll.client.monitor, + retry: &retry, + maxAdaptiveRetries: maxAdaptiveRetries, + enableOverloadRetargeting: coll.client.enableOverloadRetargeting, + selector: selector, + clock: coll.client.clock, + database: coll.db.name, + collection: coll.name, + deployment: coll.client.deployment, + crypt: coll.client.cryptFLE, + serverAPI: coll.client.serverAPI, + timeout: coll.client.timeout, + logger: coll.client.logger, + authenticator: coll.client.authenticator, + ordered: &ordered, + hint: &hint, + arrayFilters: &arrayFilters, + } if args.Let != nil { let, err := marshal(args.Let, coll.bsonOpts, coll.registry) if err != nil { return nil, err } - op = op.Let(let) + op.let = let } - if args.BypassDocumentValidation != nil && *args.BypassDocumentValidation { - op = op.BypassDocumentValidation(*args.BypassDocumentValidation) + op.bypassDocumentValidation = args.BypassDocumentValidation } if args.Comment != nil { comment, err := marshalValue(args.Comment, coll.bsonOpts, coll.registry) if err != nil { return nil, err } - op = op.Comment(comment) + op.comment = comment } if rawData, ok := optionsutil.Value(args.Internal, "rawData").(bool); ok { - op = op.RawData(rawData) + op.rawData = &rawData } if additionalCmd, ok := optionsutil.Value(args.Internal, "addCommandFields").(bson.D); ok { - op = op.AdditionalCmd(additionalCmd) + op.additionalCmd = additionalCmd } err = op.Execute(ctx) diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/insert.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/op_insert.go similarity index 92% rename from vendor/go.mongodb.org/mongo-driver/v2/mongo/insert.go rename to vendor/go.mongodb.org/mongo-driver/v2/mongo/op_insert.go index ba05b161..260d9e57 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/insert.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/op_insert.go @@ -23,8 +23,8 @@ import ( "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) -// insert performs an insert operation. -type insert struct { +// insertOp performs an insert operation. +type insertOp struct { authenticator driver.Authenticator bypassDocumentValidation *bool comment bsoncore.Value @@ -75,16 +75,16 @@ func buildInsertResult(response bsoncore.Document) (insertResult, error) { } // Result returns the result of executing this operation. -func (i *insert) Result() insertResult { return i.result } +func (i *insertOp) Result() insertResult { return i.result } -func (i *insert) processResponse(_ context.Context, resp bsoncore.Document, _ driver.ResponseInfo) error { +func (i *insertOp) processResponse(_ context.Context, resp bsoncore.Document, _ driver.ResponseInfo) error { ir, err := buildInsertResult(resp) i.result.N += ir.N return err } // Execute runs this operations and returns an error if the operation did not execute successfully. -func (i *insert) Execute(ctx context.Context) error { +func (i *insertOp) Execute(ctx context.Context) error { if i.deployment == nil { return errors.New("the Insert operation must have a Deployment set before Execute can be called") } @@ -119,7 +119,7 @@ func (i *insert) Execute(ctx context.Context) error { }.Execute(ctx) } -func (i *insert) command(dst []byte, desc description.SelectedServer) ([]byte, error) { +func (i *insertOp) command(dst []byte, desc description.SelectedServer) ([]byte, error) { dst = bsoncore.AppendStringElement(dst, "insert", i.collection) if i.bypassDocumentValidation != nil && (desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 4)) { diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/op_update.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/op_update.go new file mode 100644 index 00000000..ad64b09a --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/op_update.go @@ -0,0 +1,213 @@ +// Copyright (C) MongoDB, Inc. 2019-present. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + +package mongo + +import ( + "context" + "errors" + "fmt" + "time" + + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/driverutil" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/description" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" +) + +var errUnacknowledgedHint = errors.New("the 'hint' command parameter cannot be used with unacknowledged writes") + +// updateOp performs an update operation. +type updateOp struct { + authenticator driver.Authenticator + bypassDocumentValidation *bool + comment bsoncore.Value + ordered *bool + updates []bsoncore.Document + session *session.Client + clock *session.ClusterClock + collection string + monitor *event.CommandMonitor + database string + deployment driver.Deployment + hint *bool + arrayFilters *bool + selector description.ServerSelector + writeConcern *writeconcern.WriteConcern + retry *driver.RetryMode + maxAdaptiveRetries uint + enableOverloadRetargeting bool + result updateResult + crypt driver.Crypt + serverAPI *driver.ServerAPIOptions + let bsoncore.Document + timeout *time.Duration + rawData *bool + additionalCmd bson.D + logger *logger.Logger +} + +// upsert contains the information for an upsert in an update operation. +type upsert struct { + Index int64 + ID any `bson:"_id"` +} + +// updateResult represents an update result returned by the server. +type updateResult struct { + N int64 + NModified int64 + Upserted []upsert +} + +func buildUpdateResult(response bsoncore.Document) (updateResult, error) { + elements, err := response.Elements() + if err != nil { + return updateResult{}, err + } + ur := updateResult{} + for _, element := range elements { + switch element.Key() { + case "nModified": + var ok bool + ur.NModified, ok = element.Value().AsInt64OK() + if !ok { + return ur, fmt.Errorf("response field 'nModified' is type int32 or int64, but received BSON type %s", element.Value().Type) + } + case "n": + var ok bool + ur.N, ok = element.Value().AsInt64OK() + if !ok { + return ur, fmt.Errorf("response field 'n' is type int32 or int64, but received BSON type %s", element.Value().Type) + } + case "upserted": + arr, ok := element.Value().ArrayOK() + if !ok { + return ur, fmt.Errorf("response field 'upserted' is type array, but received BSON type %s", element.Value().Type) + } + + values, err := arr.Values() + if err != nil { + return ur, err + } + + for _, val := range values { + valDoc, ok := val.DocumentOK() + if !ok { + return ur, fmt.Errorf("upserted value is type document, but received BSON type %s", val.Type) + } + var u upsert + if err = bson.Unmarshal(valDoc, &u); err != nil { + return ur, err + } + ur.Upserted = append(ur.Upserted, u) + } + } + } + return ur, nil +} + +// Result returns the result of executing this operation. +func (u *updateOp) Result() updateResult { return u.result } + +func (u *updateOp) processResponse(_ context.Context, resp bsoncore.Document, info driver.ResponseInfo) error { + ur, err := buildUpdateResult(resp) + + u.result.N += ur.N + u.result.NModified += ur.NModified + if info.CurrentIndex > 0 { + for ind := range ur.Upserted { + ur.Upserted[ind].Index += int64(info.CurrentIndex) + } + } + u.result.Upserted = append(u.result.Upserted, ur.Upserted...) + return err +} + +// Execute runs this operation and returns an error if the operation did not execute successfully. +func (u *updateOp) Execute(ctx context.Context) error { + if u.deployment == nil { + return errors.New("the update operation must have a Deployment set before Execute can be called") + } + batches := &driver.Batches{ + Identifier: "updates", + Documents: u.updates, + Ordered: u.ordered, + } + + return driver.Operation{ + CommandFn: u.command, + ProcessResponseFn: u.processResponse, + Batches: batches, + RetryMode: u.retry, + MaxAdaptiveRetries: u.maxAdaptiveRetries, + EnableOverloadRetargeting: u.enableOverloadRetargeting, + Type: driver.Write, + Client: u.session, + Clock: u.clock, + CommandMonitor: u.monitor, + Database: u.database, + Deployment: u.deployment, + Selector: u.selector, + WriteConcern: u.writeConcern, + Crypt: u.crypt, + ServerAPI: u.serverAPI, + Timeout: u.timeout, + Logger: u.logger, + Name: driverutil.UpdateOp, + Authenticator: u.authenticator, + SendAfterClusterTime: true, + }.Execute(ctx) +} + +func (u *updateOp) command(dst []byte, desc description.SelectedServer) ([]byte, error) { + dst = bsoncore.AppendStringElement(dst, "update", u.collection) + if u.bypassDocumentValidation != nil && + (desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 4)) { + + dst = bsoncore.AppendBooleanElement(dst, "bypassDocumentValidation", *u.bypassDocumentValidation) + } + if u.comment.Type != bsoncore.Type(0) { + dst = bsoncore.AppendValueElement(dst, "comment", u.comment) + } + if u.ordered != nil { + dst = bsoncore.AppendBooleanElement(dst, "ordered", *u.ordered) + } + if u.hint != nil && *u.hint { + if desc.WireVersion == nil || !driverutil.VersionRangeIncludes(*desc.WireVersion, 5) { + return nil, errors.New("the 'hint' command parameter requires a minimum server wire version of 5") + } + if !u.writeConcern.Acknowledged() { + return nil, errUnacknowledgedHint + } + } + if u.arrayFilters != nil && *u.arrayFilters { + if desc.WireVersion == nil || !driverutil.VersionRangeIncludes(*desc.WireVersion, 6) { + return nil, errors.New("the 'arrayFilters' command parameter requires a minimum server wire version of 6") + } + } + if u.let != nil { + dst = bsoncore.AppendDocumentElement(dst, "let", u.let) + } + // Set rawData for 8.2+ servers. + if u.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { + dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawData) + } + if len(u.additionalCmd) > 0 { + doc, err := bson.Marshal(u.additionalCmd) + if err != nil { + return nil, err + } + dst = append(dst, doc[4:len(doc)-1]...) + } + + return dst, nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/clientoptions.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/clientoptions.go index 6a69b2e9..882d1162 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/clientoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/clientoptions.go @@ -970,6 +970,8 @@ func (c *ClientOptions) SetRetryReads(b bool) *ClientOptions { // SetMaxAdaptiveRetries specifies the maximum number of times the driver should retry operations that fail with a // server side overload error. MaxAdaptiveRetries can also be set through the "maxAdaptiveRetries" URI option // (e.g. "maxAdaptiveRetries=5"). +// +// This option works with MongoDB Atlas Server Version 9.0 and above. func (c *ClientOptions) SetMaxAdaptiveRetries(n uint) *ClientOptions { c.MaxAdaptiveRetries = &n @@ -979,6 +981,8 @@ func (c *ClientOptions) SetMaxAdaptiveRetries(n uint) *ClientOptions { // SetEnableOverloadRetargeting specifies whether the driver should enable overload retargeting for operations that fail // with a server side overload error. EnableOverloadRetargeting can also be set through the "enableOverloadRetargeting" // URI option (e.g. "enableOverloadRetargeting=true"). +// +// This option works with MongoDB Atlas Server Version 9.0 and above. func (c *ClientOptions) SetEnableOverloadRetargeting(b bool) *ClientOptions { c.EnableOverloadRetargeting = &b diff --git a/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/encryptoptions.go b/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/encryptoptions.go index 2817fb99..05061031 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/encryptoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/mongo/options/encryptoptions.go @@ -99,14 +99,14 @@ func (ro *RangeOptionsBuilder) SetPrecision(precision int32) *RangeOptionsBuilde return ro } -// TextOptions specifies index options for a Queryable Encryption field supporting "text" queries. +// StringOptions specifies index options for a Queryable Encryption field +// supporting prefix, suffix, and substring queries. // // See corresponding setter methods for documentation. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -type TextOptions struct { - Substring *SubstringOptions +type StringOptions struct { + // Substring specifies options to support substring queries. + Substring *SubstringOptions + Prefix *PrefixOptions Suffix *SuffixOptions CaseSensitive bool @@ -114,9 +114,6 @@ type TextOptions struct { } // SubstringOptions specifies options to support substring queries. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. type SubstringOptions struct { StrMaxLength int32 StrMinQueryLength int32 @@ -124,114 +121,87 @@ type SubstringOptions struct { } // PrefixOptions specifies options to support prefix queries. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. type PrefixOptions struct { StrMinQueryLength int32 StrMaxQueryLength int32 } // SuffixOptions specifies options to support suffix queries. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. type SuffixOptions struct { StrMinQueryLength int32 StrMaxQueryLength int32 } -// TextOptionsBuilder contains options to configure TextOptions for queryable -// encryption. Each option can be set through setter functions. See +// StringOptionsBuilder contains options to configure StringOptions for +// queryable encryption. Each option can be set through setter functions. See // documentation for each setter function for an explanation of the option. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -type TextOptionsBuilder struct { - Opts []func(*TextOptions) error +type StringOptionsBuilder struct { + Opts []func(*StringOptions) error } -// Text creates a new TextOptions instance. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func Text() *TextOptionsBuilder { - return &TextOptionsBuilder{} +// String creates a new StringOptions instance. +func String() *StringOptionsBuilder { + return &StringOptionsBuilder{} } -// List returns a list of TextOptions setter functions. -func (to *TextOptionsBuilder) List() []func(*TextOptions) error { - return to.Opts +// List returns a list of StringOptions setter functions. +func (so *StringOptionsBuilder) List() []func(*StringOptions) error { + return so.Opts } -// SetSubstring sets the text index substring value. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (to *TextOptionsBuilder) SetSubstring(substring SubstringOptions) *TextOptionsBuilder { - to.Opts = append(to.Opts, func(opts *TextOptions) error { +// SetSubstring sets the string index substring value. +func (so *StringOptionsBuilder) SetSubstring(substring SubstringOptions) *StringOptionsBuilder { + so.Opts = append(so.Opts, func(opts *StringOptions) error { opts.Substring = &substring return nil }) - return to + return so } -// SetPrefix sets the text index prefix value. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (to *TextOptionsBuilder) SetPrefix(prefix PrefixOptions) *TextOptionsBuilder { - to.Opts = append(to.Opts, func(opts *TextOptions) error { +// SetPrefix sets the string index prefix value. +func (so *StringOptionsBuilder) SetPrefix(prefix PrefixOptions) *StringOptionsBuilder { + so.Opts = append(so.Opts, func(opts *StringOptions) error { opts.Prefix = &prefix return nil }) - return to + return so } -// SetSuffix sets the text index suffix value. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (to *TextOptionsBuilder) SetSuffix(suffix SuffixOptions) *TextOptionsBuilder { - to.Opts = append(to.Opts, func(opts *TextOptions) error { +// SetSuffix sets the string index suffix value. +func (so *StringOptionsBuilder) SetSuffix(suffix SuffixOptions) *StringOptionsBuilder { + so.Opts = append(so.Opts, func(opts *StringOptions) error { opts.Suffix = &suffix return nil }) - return to + return so } -// SetCaseSensitive sets the text index caseSensitive value. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (to *TextOptionsBuilder) SetCaseSensitive(caseSensitive bool) *TextOptionsBuilder { - to.Opts = append(to.Opts, func(opts *TextOptions) error { +// SetCaseSensitive sets the string index caseSensitive value. +func (so *StringOptionsBuilder) SetCaseSensitive(caseSensitive bool) *StringOptionsBuilder { + so.Opts = append(so.Opts, func(opts *StringOptions) error { opts.CaseSensitive = caseSensitive return nil }) - return to + return so } -// SetDiacriticSensitive sets the text index diacriticSensitive value. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (to *TextOptionsBuilder) SetDiacriticSensitive(diacriticSensitive bool) *TextOptionsBuilder { - to.Opts = append(to.Opts, func(opts *TextOptions) error { +// SetDiacriticSensitive sets the string index diacriticSensitive value. +func (so *StringOptionsBuilder) SetDiacriticSensitive(diacriticSensitive bool) *StringOptionsBuilder { + so.Opts = append(so.Opts, func(opts *StringOptions) error { opts.DiacriticSensitive = diacriticSensitive return nil }) - return to + return so } // EncryptOptions represents arguments to explicitly encrypt a value. @@ -244,7 +214,7 @@ type EncryptOptions struct { QueryType string ContentionFactor *int64 RangeOptions *RangeOptionsBuilder - TextOptions *TextOptionsBuilder + StringOptions *StringOptionsBuilder } // EncryptOptionsBuilder contains options to configure Encryptopts for @@ -285,14 +255,19 @@ func (e *EncryptOptionsBuilder) SetKeyAltName(keyAltName string) *EncryptOptions return e } -// SetAlgorithm specifies an algorithm to use for encryption. This should be one of the following: -// - AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic -// - AEAD_AES_256_CBC_HMAC_SHA_512-Random -// - Indexed -// - Unindexed -// - Range +// SetAlgorithm specifies an algorithm to use for encryption. This should be one +// of the following: +// +// - AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic +// - AEAD_AES_256_CBC_HMAC_SHA_512-Random +// - Indexed +// - Unindexed +// - Range +// - String +// // This is required. -// Indexed and Unindexed are used for Queryable Encryption. +// +// Indexed, Range, and String are used for Queryable Encryption. func (e *EncryptOptionsBuilder) SetAlgorithm(algorithm string) *EncryptOptionsBuilder { e.Opts = append(e.Opts, func(opts *EncryptOptions) error { opts.Algorithm = algorithm @@ -303,10 +278,21 @@ func (e *EncryptOptionsBuilder) SetAlgorithm(algorithm string) *EncryptOptionsBu return e } -// SetQueryType specifies the intended query type. It is only valid to set if algorithm is "Indexed". -// This should be one of the following: -// - equality +// SetQueryType specifies the intended query type. It is only valid to set when +// algorithm is "Indexed", "Range", or "String". This should be one of the +// following: +// +// - equality +// - range +// - prefix / prefixPreview (used for the $encStrStartsWith operator) +// - suffix / suffixPreview (used for the $encStrEndsWith operator) +// - substring / substringPreview (used for the $encStrContains operator) +// // QueryType is used for Queryable Encryption. +// +// Beta: "prefixPreview", "suffixPreview", and "substringPreview" are preview +// features and should only be used for experimental workloads. They are not +// intended for public use and are subject to breaking changes. func (e *EncryptOptionsBuilder) SetQueryType(queryType string) *EncryptOptionsBuilder { e.Opts = append(e.Opts, func(opts *EncryptOptions) error { opts.QueryType = queryType @@ -340,13 +326,10 @@ func (e *EncryptOptionsBuilder) SetRangeOptions(ro *RangeOptionsBuilder) *Encryp return e } -// SetTextOptions specifies the options to use for text queries. -// -// Beta: This is a preview feature and should only be used for experimental workloads. -// It is not intended for public use. It is subject to breaking changes. -func (e *EncryptOptionsBuilder) SetTextOptions(to *TextOptionsBuilder) *EncryptOptionsBuilder { +// SetStringOptions specifies the options to use for string queries. +func (e *EncryptOptionsBuilder) SetStringOptions(so *StringOptionsBuilder) *EncryptOptionsBuilder { e.Opts = append(e.Opts, func(opts *EncryptOptions) error { - opts.TextOptions = to + opts.StringOptions = so return nil }) diff --git a/vendor/go.mongodb.org/mongo-driver/v2/version/version.go b/vendor/go.mongodb.org/mongo-driver/v2/version/version.go index e9a94b7e..91dab285 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/version/version.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/version/version.go @@ -11,4 +11,4 @@ package version // Driver is the current version of the driver. -var Driver = "2.7.0" +var Driver = "2.8.0" diff --git a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/mongocrypt.go b/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/mongocrypt.go index 0f003143..506d92be 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/mongocrypt.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/mongocrypt.go @@ -311,52 +311,52 @@ func (m *MongoCrypt) createExplicitEncryptionContext(opts *options.ExplicitEncry } } - if opts.TextOptions != nil { + if opts.StringOptions != nil { idx, mongocryptDoc := bsoncore.AppendDocumentStart(nil) - if opts.TextOptions.Substring != nil { + if opts.StringOptions.Substring != nil { substringIdx, substringDoc := bsoncore.AppendDocumentStart(nil) - substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMaxLength", opts.TextOptions.Substring.StrMaxLength) - substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMinQueryLength", opts.TextOptions.Substring.StrMinQueryLength) - substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMaxQueryLength", opts.TextOptions.Substring.StrMaxQueryLength) + substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMaxLength", opts.StringOptions.Substring.StrMaxLength) + substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMinQueryLength", opts.StringOptions.Substring.StrMinQueryLength) + substringDoc = bsoncore.AppendInt32Element(substringDoc, "strMaxQueryLength", opts.StringOptions.Substring.StrMaxQueryLength) substringDoc, err := bsoncore.AppendDocumentEnd(substringDoc, substringIdx) if err != nil { return nil, fmt.Errorf("error building substring doc: %w", err) } mongocryptDoc = bsoncore.AppendDocumentElement(mongocryptDoc, "substring", substringDoc) } - if opts.TextOptions.Prefix != nil { + if opts.StringOptions.Prefix != nil { prefixIdx, prefixDoc := bsoncore.AppendDocumentStart(nil) - prefixDoc = bsoncore.AppendInt32Element(prefixDoc, "strMinQueryLength", opts.TextOptions.Prefix.StrMinQueryLength) - prefixDoc = bsoncore.AppendInt32Element(prefixDoc, "strMaxQueryLength", opts.TextOptions.Prefix.StrMaxQueryLength) + prefixDoc = bsoncore.AppendInt32Element(prefixDoc, "strMinQueryLength", opts.StringOptions.Prefix.StrMinQueryLength) + prefixDoc = bsoncore.AppendInt32Element(prefixDoc, "strMaxQueryLength", opts.StringOptions.Prefix.StrMaxQueryLength) prefixDoc, err := bsoncore.AppendDocumentEnd(prefixDoc, prefixIdx) if err != nil { return nil, fmt.Errorf("error building prefix doc: %w", err) } mongocryptDoc = bsoncore.AppendDocumentElement(mongocryptDoc, "prefix", prefixDoc) } - if opts.TextOptions.Suffix != nil { + if opts.StringOptions.Suffix != nil { suffixIdx, suffixDoc := bsoncore.AppendDocumentStart(nil) - suffixDoc = bsoncore.AppendInt32Element(suffixDoc, "strMinQueryLength", opts.TextOptions.Suffix.StrMinQueryLength) - suffixDoc = bsoncore.AppendInt32Element(suffixDoc, "strMaxQueryLength", opts.TextOptions.Suffix.StrMaxQueryLength) + suffixDoc = bsoncore.AppendInt32Element(suffixDoc, "strMinQueryLength", opts.StringOptions.Suffix.StrMinQueryLength) + suffixDoc = bsoncore.AppendInt32Element(suffixDoc, "strMaxQueryLength", opts.StringOptions.Suffix.StrMaxQueryLength) suffixDoc, err := bsoncore.AppendDocumentEnd(suffixDoc, suffixIdx) if err != nil { return nil, fmt.Errorf("error building suffix doc: %w", err) } mongocryptDoc = bsoncore.AppendDocumentElement(mongocryptDoc, "suffix", suffixDoc) } - mongocryptDoc = bsoncore.AppendBooleanElement(mongocryptDoc, "caseSensitive", opts.TextOptions.CaseSensitive) - mongocryptDoc = bsoncore.AppendBooleanElement(mongocryptDoc, "diacriticSensitive", opts.TextOptions.DiacriticSensitive) + mongocryptDoc = bsoncore.AppendBooleanElement(mongocryptDoc, "caseSensitive", opts.StringOptions.CaseSensitive) + mongocryptDoc = bsoncore.AppendBooleanElement(mongocryptDoc, "diacriticSensitive", opts.StringOptions.DiacriticSensitive) mongocryptDoc, err := bsoncore.AppendDocumentEnd(mongocryptDoc, idx) if err != nil { - return nil, fmt.Errorf("error building text options doc: %w", err) + return nil, fmt.Errorf("error building string options doc: %w", err) } mongocryptBinary := newBinaryFromBytes(mongocryptDoc) defer mongocryptBinary.close() if ok := C.mongocrypt_ctx_setopt_algorithm_text(ctx.wrapped, mongocryptBinary.wrapped); !ok { - return nil, fmt.Errorf("error setting text algorithm option: %w", ctx.createErrorFromStatus()) + return nil, fmt.Errorf("error setting string algorithm option: %w", ctx.createErrorFromStatus()) } } diff --git a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options/mongocrypt_context_options.go b/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options/mongocrypt_context_options.go index 2c3673da..8832b5fb 100644 --- a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options/mongocrypt_context_options.go +++ b/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options/mongocrypt_context_options.go @@ -34,7 +34,7 @@ type ExplicitEncryptionOptions struct { QueryType string ContentionFactor *int64 RangeOptions *ExplicitRangeOptions - TextOptions *ExplicitTextOptions + StringOptions *ExplicitStringOptions } // ExplicitRangeOptions specifies options for the range index. @@ -46,8 +46,8 @@ type ExplicitRangeOptions struct { Precision *int32 } -// ExplicitTextOptions specifies options for the text query. -type ExplicitTextOptions struct { +// ExplicitStringOptions specifies options for the string query. +type ExplicitStringOptions struct { Substring *SubstringOptions Prefix *PrefixOptions Suffix *SuffixOptions @@ -115,9 +115,9 @@ func (eeo *ExplicitEncryptionOptions) SetRangeOptions(ro ExplicitRangeOptions) * return eeo } -// SetTextOptions specifies the text options. -func (eeo *ExplicitEncryptionOptions) SetTextOptions(to ExplicitTextOptions) *ExplicitEncryptionOptions { - eeo.TextOptions = &to +// SetStringOptions specifies the string options. +func (eeo *ExplicitEncryptionOptions) SetStringOptions(to ExplicitStringOptions) *ExplicitEncryptionOptions { + eeo.StringOptions = &to return eeo } diff --git a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation/update.go b/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation/update.go deleted file mode 100644 index f06f729e..00000000 --- a/vendor/go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation/update.go +++ /dev/null @@ -1,481 +0,0 @@ -// Copyright (C) MongoDB, Inc. 2019-present. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - -package operation - -import ( - "context" - "errors" - "fmt" - "time" - - "go.mongodb.org/mongo-driver/v2/bson" - "go.mongodb.org/mongo-driver/v2/event" - "go.mongodb.org/mongo-driver/v2/internal/driverutil" - "go.mongodb.org/mongo-driver/v2/internal/logger" - "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" - "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/v2/x/mongo/driver" - "go.mongodb.org/mongo-driver/v2/x/mongo/driver/description" - "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" -) - -// Update performs an update operation. -type Update struct { - authenticator driver.Authenticator - bypassDocumentValidation *bool - comment bsoncore.Value - ordered *bool - updates []bsoncore.Document - session *session.Client - clock *session.ClusterClock - collection string - monitor *event.CommandMonitor - database string - deployment driver.Deployment - hint *bool - arrayFilters *bool - selector description.ServerSelector - writeConcern *writeconcern.WriteConcern - retry *driver.RetryMode - maxAdaptiveRetries uint - enableOverloadRetargeting bool - result UpdateResult - crypt driver.Crypt - serverAPI *driver.ServerAPIOptions - let bsoncore.Document - timeout *time.Duration - rawData *bool - additionalCmd bson.D - logger *logger.Logger -} - -// Upsert contains the information for an upsert in an Update operation. -type Upsert struct { - Index int64 - ID any `bson:"_id"` -} - -// UpdateResult contains information for the result of an Update operation. -type UpdateResult struct { - // Number of documents matched. - N int64 - // Number of documents modified. - NModified int64 - // Information about upserted documents. - Upserted []Upsert -} - -func buildUpdateResult(response bsoncore.Document) (UpdateResult, error) { - elements, err := response.Elements() - if err != nil { - return UpdateResult{}, err - } - ur := UpdateResult{} - for _, element := range elements { - switch element.Key() { - case "nModified": - var ok bool - ur.NModified, ok = element.Value().AsInt64OK() - if !ok { - return ur, fmt.Errorf("response field 'nModified' is type int32 or int64, but received BSON type %s", element.Value().Type) - } - case "n": - var ok bool - ur.N, ok = element.Value().AsInt64OK() - if !ok { - return ur, fmt.Errorf("response field 'n' is type int32 or int64, but received BSON type %s", element.Value().Type) - } - case "upserted": - arr, ok := element.Value().ArrayOK() - if !ok { - return ur, fmt.Errorf("response field 'upserted' is type array, but received BSON type %s", element.Value().Type) - } - - var values []bsoncore.Value - values, err = arr.Values() - if err != nil { - break - } - - for _, val := range values { - valDoc, ok := val.DocumentOK() - if !ok { - return ur, fmt.Errorf("upserted value is type document, but received BSON type %s", val.Type) - } - var upsert Upsert - if err = bson.Unmarshal(valDoc, &upsert); err != nil { - return ur, err - } - ur.Upserted = append(ur.Upserted, upsert) - } - } - } - return ur, nil -} - -// NewUpdate constructs and returns a new Update. -func NewUpdate(updates ...bsoncore.Document) *Update { - return &Update{ - updates: updates, - } -} - -// Result returns the result of executing this operation. -func (u *Update) Result() UpdateResult { return u.result } - -func (u *Update) processResponse(_ context.Context, resp bsoncore.Document, info driver.ResponseInfo) error { - ur, err := buildUpdateResult(resp) - - u.result.N += ur.N - u.result.NModified += ur.NModified - if info.CurrentIndex > 0 { - for ind := range ur.Upserted { - ur.Upserted[ind].Index += int64(info.CurrentIndex) - } - } - u.result.Upserted = append(u.result.Upserted, ur.Upserted...) - return err -} - -// Execute runs this operations and returns an error if the operation did not execute successfully. -func (u *Update) Execute(ctx context.Context) error { - if u.deployment == nil { - return errors.New("the Update operation must have a Deployment set before Execute can be called") - } - batches := &driver.Batches{ - Identifier: "updates", - Documents: u.updates, - Ordered: u.ordered, - } - - return driver.Operation{ - CommandFn: u.command, - ProcessResponseFn: u.processResponse, - Batches: batches, - RetryMode: u.retry, - MaxAdaptiveRetries: u.maxAdaptiveRetries, - EnableOverloadRetargeting: u.enableOverloadRetargeting, - Type: driver.Write, - Client: u.session, - Clock: u.clock, - CommandMonitor: u.monitor, - Database: u.database, - Deployment: u.deployment, - Selector: u.selector, - WriteConcern: u.writeConcern, - Crypt: u.crypt, - ServerAPI: u.serverAPI, - Timeout: u.timeout, - Logger: u.logger, - Name: driverutil.UpdateOp, - Authenticator: u.authenticator, - SendAfterClusterTime: true, - }.Execute(ctx) -} - -func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, error) { - dst = bsoncore.AppendStringElement(dst, "update", u.collection) - if u.bypassDocumentValidation != nil && - (desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 4)) { - - dst = bsoncore.AppendBooleanElement(dst, "bypassDocumentValidation", *u.bypassDocumentValidation) - } - if u.comment.Type != bsoncore.Type(0) { - dst = bsoncore.AppendValueElement(dst, "comment", u.comment) - } - if u.ordered != nil { - dst = bsoncore.AppendBooleanElement(dst, "ordered", *u.ordered) - } - if u.hint != nil && *u.hint { - - if desc.WireVersion == nil || !driverutil.VersionRangeIncludes(*desc.WireVersion, 5) { - return nil, errors.New("the 'hint' command parameter requires a minimum server wire version of 5") - } - if !u.writeConcern.Acknowledged() { - return nil, errUnacknowledgedHint - } - } - if u.arrayFilters != nil && *u.arrayFilters { - if desc.WireVersion == nil || !driverutil.VersionRangeIncludes(*desc.WireVersion, 6) { - return nil, errors.New("the 'arrayFilters' command parameter requires a minimum server wire version of 6") - } - } - if u.let != nil { - dst = bsoncore.AppendDocumentElement(dst, "let", u.let) - } - // Set rawData for 8.2+ servers. - if u.rawData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) { - dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawData) - } - if len(u.additionalCmd) > 0 { - doc, err := bson.Marshal(u.additionalCmd) - if err != nil { - return nil, err - } - dst = append(dst, doc[4:len(doc)-1]...) - } - - return dst, nil -} - -// BypassDocumentValidation allows the operation to opt-out of document level validation. -func (u *Update) BypassDocumentValidation(bypassDocumentValidation bool) *Update { - if u == nil { - u = new(Update) - } - - u.bypassDocumentValidation = &bypassDocumentValidation - return u -} - -// Hint is a flag to indicate that the update document contains a hint. Hint is only supported by -// servers >= 4.2. Older servers will report an error for using the hint option. -func (u *Update) Hint(hint bool) *Update { - if u == nil { - u = new(Update) - } - - u.hint = &hint - return u -} - -// ArrayFilters is a flag to indicate that the update document contains an arrayFilters field. -func (u *Update) ArrayFilters(arrayFilters bool) *Update { - if u == nil { - u = new(Update) - } - - u.arrayFilters = &arrayFilters - return u -} - -// Ordered sets ordered. If true, when a write fails, the operation will return the error, when -// false write failures do not stop execution of the operation. -func (u *Update) Ordered(ordered bool) *Update { - if u == nil { - u = new(Update) - } - - u.ordered = &ordered - return u -} - -// Updates specifies an array of update statements to perform when this operation is executed. -// Each update document must have the following structure: -// {q: , u: , multi: , collation: Optional, arrayFitlers: Optional, hint: Optional}. -func (u *Update) Updates(updates ...bsoncore.Document) *Update { - if u == nil { - u = new(Update) - } - - u.updates = updates - return u -} - -// Session sets the session for this operation. -func (u *Update) Session(session *session.Client) *Update { - if u == nil { - u = new(Update) - } - - u.session = session - return u -} - -// ClusterClock sets the cluster clock for this operation. -func (u *Update) ClusterClock(clock *session.ClusterClock) *Update { - if u == nil { - u = new(Update) - } - - u.clock = clock - return u -} - -// Collection sets the collection that this command will run against. -func (u *Update) Collection(collection string) *Update { - if u == nil { - u = new(Update) - } - - u.collection = collection - return u -} - -// CommandMonitor sets the monitor to use for APM events. -func (u *Update) CommandMonitor(monitor *event.CommandMonitor) *Update { - if u == nil { - u = new(Update) - } - - u.monitor = monitor - return u -} - -// Comment sets a value to help trace an operation. -func (u *Update) Comment(comment bsoncore.Value) *Update { - if u == nil { - u = new(Update) - } - - u.comment = comment - return u -} - -// Database sets the database to run this operation against. -func (u *Update) Database(database string) *Update { - if u == nil { - u = new(Update) - } - - u.database = database - return u -} - -// Deployment sets the deployment to use for this operation. -func (u *Update) Deployment(deployment driver.Deployment) *Update { - if u == nil { - u = new(Update) - } - - u.deployment = deployment - return u -} - -// ServerSelector sets the selector used to retrieve a server. -func (u *Update) ServerSelector(selector description.ServerSelector) *Update { - if u == nil { - u = new(Update) - } - - u.selector = selector - return u -} - -// WriteConcern sets the write concern for this operation. -func (u *Update) WriteConcern(writeConcern *writeconcern.WriteConcern) *Update { - if u == nil { - u = new(Update) - } - - u.writeConcern = writeConcern - return u -} - -// Retry enables retryable writes for this operation. Retries are not handled automatically, -// instead a boolean is returned from Execute and SelectAndExecute that indicates if the -// operation can be retried. Retrying is handled by calling RetryExecute. -func (u *Update) Retry(retry driver.RetryMode) *Update { - if u == nil { - u = new(Update) - } - - u.retry = &retry - return u -} - -// MaxAdaptiveRetries specifies the maximum number of times the driver should retry operations -// that fail with a server side overload error. -func (u *Update) MaxAdaptiveRetries(maxAdaptiveRetries uint) *Update { - if u == nil { - u = new(Update) - } - - u.maxAdaptiveRetries = maxAdaptiveRetries - return u -} - -// EnableOverloadRetargeting specifies whether the driver adds the previously failed server's address -// to the list of deprioritized server addresses -func (u *Update) EnableOverloadRetargeting(enabled bool) *Update { - if u == nil { - u = new(Update) - } - - u.enableOverloadRetargeting = enabled - return u -} - -// Crypt sets the Crypt object to use for automatic encryption and decryption. -func (u *Update) Crypt(crypt driver.Crypt) *Update { - if u == nil { - u = new(Update) - } - - u.crypt = crypt - return u -} - -// ServerAPI sets the server API version for this operation. -func (u *Update) ServerAPI(serverAPI *driver.ServerAPIOptions) *Update { - if u == nil { - u = new(Update) - } - - u.serverAPI = serverAPI - return u -} - -// Let specifies the let document to use. This option is only valid for server versions 5.0 and above. -func (u *Update) Let(let bsoncore.Document) *Update { - if u == nil { - u = new(Update) - } - - u.let = let - return u -} - -// Timeout sets the timeout for this operation. -func (u *Update) Timeout(timeout *time.Duration) *Update { - if u == nil { - u = new(Update) - } - - u.timeout = timeout - return u -} - -// Logger sets the logger for this operation. -func (u *Update) Logger(logger *logger.Logger) *Update { - if u == nil { - u = new(Update) - } - - u.logger = logger - return u -} - -// Authenticator sets the authenticator to use for this operation. -func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { - if u == nil { - u = new(Update) - } - - u.authenticator = authenticator - return u -} - -// RawData sets the rawData to access timeseries data in the compressed format. -func (u *Update) RawData(rawData bool) *Update { - if u == nil { - u = new(Update) - } - - u.rawData = &rawData - return u -} - -// AdditionalCmd sets additional command fields to be attached. -func (u *Update) AdditionalCmd(d bson.D) *Update { - if u == nil { - u = new(Update) - } - - u.additionalCmd = d - return u -} diff --git a/vendor/golang.org/x/crypto/argon2/argon2.go b/vendor/golang.org/x/crypto/argon2/argon2.go index 2b65ec91..57ab8371 100644 --- a/vendor/golang.org/x/crypto/argon2/argon2.go +++ b/vendor/golang.org/x/crypto/argon2/argon2.go @@ -17,8 +17,8 @@ // It uses data-independent memory access, which is preferred for password // hashing and password-based key derivation. Argon2i requires more passes over // memory than Argon2id to protect from trade-off attacks. The recommended -// parameters (taken from [RFC 9106 Section 7.3]) for non-interactive operations are time=3 and to -// use the maximum available memory. +// parameters (taken from [RFC 9106 Section 7.3]) for non-interactive +// operations are time=3 and to use the maximum available memory. // // # Argon2id // @@ -26,11 +26,14 @@ // Argon2i and Argon2d. It uses data-independent memory access for the first // half of the first iteration over the memory and data-dependent memory access // for the rest. Argon2id is side-channel resistant and provides better brute- -// force cost savings due to time-memory tradeoffs than Argon2i. The recommended -// parameters for non-interactive operations (taken from [RFC 9106 Section 7.3]) are time=1 and to -// use the maximum available memory. +// force cost savings due to time-memory tradeoffs than Argon2i. [RFC 9106 +// Section 4] recommends time=1, memory=2*1024*1024 KiB (2 GiB), and threads=4 +// as the first recommended option. If much less memory is available, it +// recommends time=3, memory=64*1024 KiB (64 MiB), and threads=4 as the second +// recommended option. // // [argon2-specs.pdf]: https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf +// [RFC 9106 Section 4]: https://www.rfc-editor.org/rfc/rfc9106.html#section-4 // [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3 package argon2 @@ -59,9 +62,9 @@ const ( // // key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 4, 32) // -// [RFC 9106 Section 7.3] recommends time=3, and memory=32*1024 as a sensible number. -// If using that amount of memory (32 MB) is not possible in some contexts then -// the time parameter can be increased to compensate. +// The example above uses time=3 and memory=32*1024. Argon2i generally +// requires more passes over memory than Argon2id. If in doubt, prefer IDKey +// and its Argon2id parameter recommendations. // // The time parameter specifies the number of passes over the memory and the // memory parameter specifies the size of the memory in KiB. For example @@ -69,8 +72,6 @@ const ( // adjusted to the number of available CPUs. The cost parameters should be // increased as memory latency and CPU parallelism increases. Remember to get a // good random salt. -// -// [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3 func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte { return deriveKey(argon2i, password, salt, nil, nil, time, memory, threads, keyLen) } @@ -83,20 +84,20 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3 // For example, you can get a derived key for e.g. AES-256 (which needs a // 32-byte key) by doing: // -// key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 4, 32) +// key := argon2.IDKey([]byte("some password"), salt, 1, 2*1024*1024, 4, 32) // -// [RFC 9106 Section 7.3] recommends time=1, and memory=64*1024 as a sensible number. -// If using that amount of memory (64 MB) is not possible in some contexts then -// the time parameter can be increased to compensate. +// The example above uses the first [RFC 9106 Section 4] recommended option. +// If much less memory is available, the second recommended option is time=3, +// memory=64*1024 KiB (64 MiB), and threads=4. // // The time parameter specifies the number of passes over the memory and the // memory parameter specifies the size of the memory in KiB. For example -// memory=64*1024 sets the memory cost to ~64 MB. The number of threads can be -// adjusted to the numbers of available CPUs. The cost parameters should be +// memory=2*1024*1024 sets the memory cost to ~2 GiB. The number of threads can +// be adjusted to the numbers of available CPUs. The cost parameters should be // increased as memory latency and CPU parallelism increases. Remember to get a // good random salt. // -// [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3 +// [RFC 9106 Section 4]: https://www.rfc-editor.org/rfc/rfc9106.html#section-4 func IDKey(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte { return deriveKey(argon2id, password, salt, nil, nil, time, memory, threads, keyLen) } diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index 334861b7..64377715 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -182,14 +182,19 @@ func ParseKnownHosts(in []byte) (marker string, hosts []string, pubKey PublicKey } hosts := string(keyFields[0]) - // keyFields[1] contains the key type (e.g. “ssh-rsa”). - // However, that information is duplicated inside the - // base64-encoded key and so is ignored here. + // keyFields[1] contains the key type (e.g. "ssh-rsa"). This information + // is duplicated within the base64-encoded key blob. As OpenSSH's + // sshkey_read does, we verify that the declared key type matches the + // type embedded in the key blob. + wantType := string(keyFields[1]) key := bytes.Join(keyFields[2:], []byte(" ")) if pubKey, comment, err = parseAuthorizedKey(key); err != nil { return "", nil, nil, "", nil, err } + if pubKey.Type() != wantType { + return "", nil, nil, "", nil, fmt.Errorf("ssh: known hosts key type mismatch: human-readable type %q, encoded type %q", wantType, pubKey.Type()) + } return marker, strings.Split(hosts, ","), pubKey, comment, rest, nil } @@ -228,10 +233,17 @@ func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []str } if out, comment, err = parseAuthorizedKey(in[i:]); err == nil { - return out, comment, options, rest, nil - } else { - lastErr = err + // The first field contains the declared key type. As OpenSSH's + // sshkey_read does, we verify that it matches the type embedded in + // the key blob. Without this check, a single-token option (e.g. + // "restrict") appearing in the key type position could be silently + // discarded along with its intended effect. + if string(in[:i]) == out.Type() { + return out, comment, options, rest, nil + } + err = fmt.Errorf("ssh: authorized keys key type mismatch: human-readable type %q, encoded type %q", in[:i], out.Type()) } + lastErr = err // No key type recognised. Maybe there's an options field at // the beginning. @@ -271,11 +283,15 @@ func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []str } if out, comment, err = parseAuthorizedKey(in[i:]); err == nil { - options = candidateOptions - return out, comment, options, rest, nil - } else { - lastErr = err + // As above, the declared key type (here following the options + // field) must match the type embedded in the key blob. + if string(in[:i]) == out.Type() { + options = candidateOptions + return out, comment, options, rest, nil + } + err = fmt.Errorf("ssh: authorized keys key type mismatch: human-readable type %q, encoded type %q", in[:i], out.Type()) } + lastErr = err in = rest continue diff --git a/vendor/golang.org/x/crypto/ssh/messages.go b/vendor/golang.org/x/crypto/ssh/messages.go index ab22c3d3..de86f71c 100644 --- a/vendor/golang.org/x/crypto/ssh/messages.go +++ b/vendor/golang.org/x/crypto/ssh/messages.go @@ -44,7 +44,16 @@ type disconnectMsg struct { } func (d *disconnectMsg) Error() string { - return fmt.Sprintf("ssh: disconnect, reason %d: %s", d.Reason, d.Message) + return fmt.Sprintf("ssh: disconnect, reason %d: %q", d.Reason, sanitizeString(d.Message)) +} + +func sanitizeString(s string) string { + return strings.Map(func(r rune) rune { + if r == '\t' || (r >= ' ' && r < 0x7f) { + return r + } + return -1 + }, s) } // See RFC 4253, section 7.1. diff --git a/vendor/golang.org/x/sys/cpu/parse.go b/vendor/golang.org/x/sys/cpu/parse.go index 56a7e1a1..12a99af5 100644 --- a/vendor/golang.org/x/sys/cpu/parse.go +++ b/vendor/golang.org/x/sys/cpu/parse.go @@ -6,38 +6,50 @@ package cpu import "strconv" -// parseRelease parses a dot-separated version number. It follows the semver -// syntax, but allows the minor and patch versions to be elided. +// parseRelease parses a dot-separated version number from the prefix +// of rel. It returns ok=true only if at least the major and minor +// components were successfully parsed; the patch component is +// best-effort. Trailing vendor or build suffixes such as +// "-generic", "+", "_hi3535", or "-rc1" are ignored. // // This is a copy of the Go runtime's parseRelease from -// https://golang.org/cl/209597. +// https://golang.org/cl/209597, updated in https://golang.org/cl/781800. func parseRelease(rel string) (major, minor, patch int, ok bool) { - // Strip anything after a dash or plus. - for i := range len(rel) { - if rel[i] == '-' || rel[i] == '+' { - rel = rel[:i] - break + // next consumes a run of decimal digits from the front of rel, + // returning the parsed value. If the digits are followed by a + // '.', it is consumed and more is set so the caller knows to + // parse another component; otherwise scanning terminates and + // the rest of rel is discarded. + next := func() (n int, more, ok bool) { + i := 0 + for i < len(rel) && rel[i] >= '0' && rel[i] <= '9' { + i++ } - } - - next := func() (int, bool) { - for i := range len(rel) { - if rel[i] == '.' { - ver, err := strconv.Atoi(rel[:i]) - rel = rel[i+1:] - return ver, err == nil - } + if i == 0 { + return 0, false, false + } + n, err := strconv.Atoi(rel[:i]) + if err != nil { + return 0, false, false + } + if i < len(rel) && rel[i] == '.' { + rel = rel[i+1:] + return n, true, true } - ver, err := strconv.Atoi(rel) rel = "" - return ver, err == nil + return n, false, true + } + + var more bool + if major, more, ok = next(); !ok || !more { + return 0, 0, 0, false } - if major, ok = next(); !ok || rel == "" { - return + if minor, more, ok = next(); !ok { + return 0, 0, 0, false } - if minor, ok = next(); !ok || rel == "" { - return + if !more { + return major, minor, 0, true } - patch, ok = next() - return + patch, _, _ = next() + return major, minor, patch, true } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index ce4d7ab1..21e2bfa3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1874,6 +1874,7 @@ func Dup2(oldfd, newfd int) error { //sys Dup3(oldfd int, newfd int, flags int) (err error) //sysnb EpollCreate1(flag int) (fd int, err error) //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Eventfd(initval uint, flags int) (fd int, err error) = SYS_EVENTFD2 //sys Exit(code int) = SYS_EXIT_GROUP //sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index 506dafa7..210d545c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -20,7 +20,6 @@ func setTimeval(sec, usec int64) Timeval { // 64-bit file system and 32-bit uid calls // (386 default is 32-bit file system and 16-bit uid). -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index d557cf8d..a9a52f23 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -6,7 +6,6 @@ package unix -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index ecf92bfa..54474c20 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -44,7 +44,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { // 64-bit file system and 32-bit uid calls // (16-bit uid calls are not always supported in newer kernels) -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index 17373807..e9f30db9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -8,7 +8,6 @@ package unix import "unsafe" -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go index a3fd1d0b..6f09ca20 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -8,7 +8,6 @@ package unix import "unsafe" -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 70963a95..ca3b5659 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -6,7 +6,6 @@ package unix -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstatfs(fd int, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index c218ebd2..54ba667b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -13,7 +13,6 @@ import ( func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index e6c48500..ce462859 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -11,7 +11,6 @@ import ( "unsafe" ) -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 7286a9aa..33f7af38 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -6,7 +6,6 @@ package unix -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index fc5543c5..c658871e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -8,7 +8,6 @@ package unix import "unsafe" -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 66f31210..2c858769 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -10,7 +10,6 @@ import ( "unsafe" ) -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index 11d1f169..4964119a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -6,7 +6,6 @@ package unix -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 9d72a6b7..5bb51d7a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1359,6 +1359,7 @@ const ( FAN_UNLIMITED_MARKS = 0x20 FAN_UNLIMITED_QUEUE = 0x10 FD_CLOEXEC = 0x1 + FD_PIDFS_ROOT = -0x2712 FD_SETSIZE = 0x400 FF0 = 0x0 FIB_RULE_DEV_DETACHED = 0x8 @@ -1970,6 +1971,8 @@ const ( MADV_DONTNEED = 0x4 MADV_DONTNEED_LOCKED = 0x18 MADV_FREE = 0x8 + MADV_GUARD_INSTALL = 0x66 + MADV_GUARD_REMOVE = 0x67 MADV_HUGEPAGE = 0xe MADV_HWPOISON = 0x64 MADV_KEEPONFORK = 0x13 @@ -2114,7 +2117,7 @@ const ( MS_NOSEC = 0x10000000 MS_NOSUID = 0x2 MS_NOSYMFOLLOW = 0x100 - MS_NOUSER = -0x80000000 + MS_NOUSER = 0x80000000 MS_POSIXACL = 0x10000 MS_PRIVATE = 0x40000 MS_RDONLY = 0x1 @@ -3786,6 +3789,9 @@ const ( TCPOPT_TIMESTAMP = 0x8 TCPOPT_TSTAMP_HDR = 0x101080a TCPOPT_WINDOW = 0x3 + TCP_AO_KEYF_EXCLUDE_OPT = 0x2 + TCP_AO_KEYF_IFINDEX = 0x1 + TCP_AO_MAXKEYLEN = 0x50 TCP_CC_INFO = 0x1a TCP_CM_INQ = 0x24 TCP_CONGESTION = 0xd diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 80f40e40..5788c2a5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -700,6 +700,23 @@ func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Eventfd(initval uint, flags int) (fd int, err error) { r0, _, e1 := Syscall(SYS_EVENTFD2, uintptr(initval), uintptr(flags), 0) fd = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 4def3e9f..254f3398 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64_64, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index fef2bc8b..27c05db1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index a9fd76a8..840d85bf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -213,23 +213,6 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index 46006502..fe414498 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go index c8987d26..eb358ce0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 921f4306..c437622f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall9(SYS_FADVISE64, uintptr(fd), 0, uintptr(offset>>32), uintptr(offset), uintptr(length>>32), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 44f06782..bc4ca255 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index e7fa0abf..5051435c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 8c512567..33aa5418 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall9(SYS_FADVISE64, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index 7392fd45..3bef8ef1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 41180434..fc1bd4e2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 40c6ce7a..d78fe7da 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index 2cfe34ad..76dcf87d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 61e6f070..2cf020f2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 834b8420..52763762 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -45,23 +45,6 @@ func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 6c955cea..78362156 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -1109,17 +1109,53 @@ const ( ) // This type is the union inside of TRUSTEE and must be created using one of the TrusteeValueFrom* functions. +// +// Go pointers stored in a TrusteeValue must be pinned using [runtime.Pinner] +// for the lifetime of the TrusteeValue. type TrusteeValue uintptr +// TrusteeValueFromString is unsafe and should not be used. +// +// It returns a uintptr containing a reference to newly-allocated memory +// which will be freed by the garbage collector. +// There is no way for the caller to safely reference this memory. +// +// To create a [TrusteeValue] from a string, use: +// +// p, err := windows.UTF16PtrFromString(s) +// if err != nil { +// // handle error +// } +// +// // Pin the string for as long as it is used. +// var pinner runtime.Pinner +// pinner.Pin(p) +// defer pinner.Unpin() +// +// tv := TrusteeValue(unsafe.Pointer(p)) +// +// Deprecated: TrusteeValueFromString is unsafe and should not be used. func TrusteeValueFromString(str string) TrusteeValue { return TrusteeValue(unsafe.Pointer(StringToUTF16Ptr(str))) } + +// TrusteeValueFromSID returns a [TrusteeValue] referencing sid. +// +// The caller must pin sid using a [runtime.Pinner] for the lifetime of the TrusteeValue. func TrusteeValueFromSID(sid *SID) TrusteeValue { return TrusteeValue(unsafe.Pointer(sid)) } + +// TrusteeValueFromObjectsAndSid returns a [TrusteeValue] referencing objectsAndSid. +// +// The caller must pin objectsAndSid using a [runtime.Pinner] for the lifetime of the TrusteeValue. func TrusteeValueFromObjectsAndSid(objectsAndSid *OBJECTS_AND_SID) TrusteeValue { return TrusteeValue(unsafe.Pointer(objectsAndSid)) } + +// TrusteeValueFromObjectsAndName returns a [TrusteeValue] referencing objectsAndName. +// +// The caller must pin objectsAndName using a [runtime.Pinner] for the lifetime of the TrusteeValue. func TrusteeValueFromObjectsAndName(objectsAndName *OBJECTS_AND_NAME) TrusteeValue { return TrusteeValue(unsafe.Pointer(objectsAndName)) } diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 9755bca9..e6966b4c 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -1728,11 +1728,15 @@ func (s *NTUnicodeString) String() string { // the more common *uint16 string type. func NewNTString(s string) (*NTString, error) { var nts NTString - s8, err := BytePtrFromString(s) + s8, err := ByteSliceFromString(s) if err != nil { return nil, err } - RtlInitString(&nts, s8) + // The source string plus its terminating NUL must fit within MAX_USHORT. + if len(s8) > MAX_USHORT { + return nil, syscall.EINVAL + } + RtlInitString(&nts, &s8[0]) return &nts, nil } diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index d2574a73..75a50b31 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -169,6 +169,7 @@ const ( FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192 FORMAT_MESSAGE_MAX_WIDTH_MASK = 255 + MAX_USHORT = 0xffff MAX_PATH = 260 MAX_LONG_PATH = 32768 diff --git a/vendor/golang.org/x/text/unicode/norm/forminfo.go b/vendor/golang.org/x/text/unicode/norm/forminfo.go index f3a234e5..b3cf5d9b 100644 --- a/vendor/golang.org/x/text/unicode/norm/forminfo.go +++ b/vendor/golang.org/x/text/unicode/norm/forminfo.go @@ -121,8 +121,12 @@ func (p Properties) BoundaryAfter() bool { // // When all 6 bits are zero, the character is inert, meaning it is never // influenced by normalization. +// +// We set flags to 0x80 (high bit 7 unused in quick check data) to indicate an invalid rune. type qcInfo uint8 +func (p Properties) isInvalid() bool { return p.flags == 0x80 } + func (p Properties) isYesC() bool { return p.flags&0x10 == 0 } func (p Properties) isYesD() bool { return p.flags&0x4 == 0 } @@ -247,6 +251,9 @@ func (f Form) PropertiesString(s string) Properties { // to a Properties. See the comment at the top of the file // for more information on the format. func compInfo(v uint16, sz int) Properties { + if sz == 0 { + return Properties{flags: 0x80, size: 1} + } if v == 0 { return Properties{size: uint8(sz)} } else if v >= 0x8000 { @@ -254,7 +261,7 @@ func compInfo(v uint16, sz int) Properties { size: uint8(sz), ccc: uint8(v), tccc: uint8(v), - flags: qcInfo(v >> 8), + flags: qcInfo(v>>8) & 0x3f, } if p.ccc > 0 || p.combinesBackward() { p.nLead = uint8(p.flags & 0x3) diff --git a/vendor/golang.org/x/text/unicode/norm/iter.go b/vendor/golang.org/x/text/unicode/norm/iter.go index 417c6b26..3cc05922 100644 --- a/vendor/golang.org/x/text/unicode/norm/iter.go +++ b/vendor/golang.org/x/text/unicode/norm/iter.go @@ -376,16 +376,12 @@ func nextComposed(i *Iter) []byte { goto doNorm } prevCC = i.info.tccc - sz := int(i.info.size) - if sz == 0 { - sz = 1 // illegal rune: copy byte-by-byte - } - p := outp + sz + p := outp + int(i.info.size) if p > len(i.buf) { break } outp = p - i.p += sz + i.p += int(i.info.size) if i.p >= i.rb.nsrc { i.setDone() break diff --git a/vendor/golang.org/x/text/unicode/norm/normalize.go b/vendor/golang.org/x/text/unicode/norm/normalize.go index 4747ad07..60b1511c 100644 --- a/vendor/golang.org/x/text/unicode/norm/normalize.go +++ b/vendor/golang.org/x/text/unicode/norm/normalize.go @@ -148,7 +148,7 @@ func (f Form) IsNormalString(s string) bool { // patched buffer and whether the decomposition is still in progress. func patchTail(rb *reorderBuffer) bool { info, p := lastRuneStart(&rb.f, rb.out) - if p == -1 || info.size == 0 { + if p == -1 || info.isInvalid() { return true } end := p + int(info.size) @@ -225,7 +225,7 @@ func doAppend(rb *reorderBuffer, out []byte, p int) []byte { } fd := &rb.f if doMerge { - var info Properties + info := Properties{flags: 0x80, size: 1} // invalid rune if p < n { info = fd.info(src, p) if !info.BoundaryBefore() || info.nLeadingNonStarters() > 0 { @@ -235,7 +235,7 @@ func doAppend(rb *reorderBuffer, out []byte, p int) []byte { p = decomposeSegment(rb, p, true) } } - if info.size == 0 { + if info.isInvalid() { rb.doFlush() // Append incomplete UTF-8 encoding. return src.appendSlice(rb.out, p, n) @@ -314,7 +314,7 @@ func (f *formInfo) quickSpan(src input, i, end int, atEOF bool) (n int, ok bool) continue } info := f.info(src, i) - if info.size == 0 { + if info.isInvalid() { if atEOF { // include incomplete runes return n, true @@ -379,7 +379,7 @@ func (f Form) firstBoundary(src input, nsrc int) int { // CGJ insertion points correctly. Luckily it doesn't have to. for { info := fd.info(src, i) - if info.size == 0 { + if info.isInvalid() { return -1 } if s := ss.next(info); s != ssSuccess { @@ -424,7 +424,7 @@ func (f Form) nextBoundary(src input, nsrc int, atEOF bool) int { } fd := formTable[f] info := fd.info(src, 0) - if info.size == 0 { + if info.isInvalid() { if atEOF { return 1 } @@ -435,7 +435,7 @@ func (f Form) nextBoundary(src input, nsrc int, atEOF bool) int { for i := int(info.size); i < nsrc; i += int(info.size) { info = fd.info(src, i) - if info.size == 0 { + if info.isInvalid() { if atEOF { return i } @@ -465,7 +465,7 @@ func lastBoundary(fd *formInfo, b []byte) int { if p == -1 { return -1 } - if info.size == 0 { // ends with incomplete rune + if info.isInvalid() { // ends with incomplete rune if p == 0 { // starts with incomplete rune return -1 } @@ -504,7 +504,7 @@ func lastBoundary(fd *formInfo, b []byte) int { func decomposeSegment(rb *reorderBuffer, sp int, atEOF bool) int { // Force one character to be consumed. info := rb.f.info(rb.src, sp) - if info.size == 0 { + if info.isInvalid() { return 0 } if s := rb.ss.next(info); s == ssStarter { @@ -528,7 +528,7 @@ func decomposeSegment(rb *reorderBuffer, sp int, atEOF bool) int { break } info = rb.f.info(rb.src, sp) - if info.size == 0 { + if info.isInvalid() { if !atEOF { return int(iShortSrc) } diff --git a/vendor/modules.txt b/vendor/modules.txt index f0e980c7..ba9b7805 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -207,7 +207,7 @@ github.com/go-ole/go-ole/oleutil # github.com/go-pkgz/lgr v0.12.3 ## explicit; go 1.21 github.com/go-pkgz/lgr -# github.com/go-pkgz/rest v1.21.0 +# github.com/go-pkgz/rest v1.23.1 ## explicit; go 1.24.0 github.com/go-pkgz/rest github.com/go-pkgz/rest/logger @@ -435,7 +435,7 @@ go.mongodb.org/mongo-driver/x/mongo/driver/operation go.mongodb.org/mongo-driver/x/mongo/driver/session go.mongodb.org/mongo-driver/x/mongo/driver/topology go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage -# go.mongodb.org/mongo-driver/v2 v2.7.0 +# go.mongodb.org/mongo-driver/v2 v2.8.0 ## explicit; go 1.19 go.mongodb.org/mongo-driver/v2/bson go.mongodb.org/mongo-driver/v2/event @@ -521,7 +521,7 @@ go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded go.opentelemetry.io/otel/trace/internal/telemetry go.opentelemetry.io/otel/trace/noop -# golang.org/x/crypto v0.53.0 +# golang.org/x/crypto v0.54.0 ## explicit; go 1.25.0 golang.org/x/crypto/argon2 golang.org/x/crypto/bcrypt @@ -538,22 +538,22 @@ golang.org/x/crypto/pbkdf2 golang.org/x/crypto/scrypt golang.org/x/crypto/ssh golang.org/x/crypto/ssh/internal/bcrypt_pbkdf -# golang.org/x/net v0.56.0 +# golang.org/x/net v0.57.0 ## explicit; go 1.25.0 golang.org/x/net/html golang.org/x/net/html/atom golang.org/x/net/html/charset -# golang.org/x/sync v0.21.0 +# golang.org/x/sync v0.22.0 ## explicit; go 1.25.0 golang.org/x/sync/errgroup golang.org/x/sync/singleflight -# golang.org/x/sys v0.46.0 +# golang.org/x/sys v0.47.0 ## explicit; go 1.25.0 golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/windows/registry -# golang.org/x/text v0.38.0 +# golang.org/x/text v0.40.0 ## explicit; go 1.25.0 golang.org/x/text/encoding golang.org/x/text/encoding/charmap