diff --git a/backend/_example/memory_store/go.mod b/backend/_example/memory_store/go.mod
index 12c6ae506a..33d6740645 100644
--- a/backend/_example/memory_store/go.mod
+++ b/backend/_example/memory_store/go.mod
@@ -6,21 +6,21 @@ require (
github.com/go-pkgz/jrpc v0.3.0
github.com/go-pkgz/lgr v0.11.1
github.com/jessevdk/go-flags v1.5.0
- github.com/stretchr/testify v1.8.4
+ github.com/stretchr/testify v1.9.0
github.com/umputun/remark42/backend v1.1000.0
)
require (
github.com/Depado/bfchroma/v2 v2.0.0 // indirect
- github.com/PuerkitoBio/goquery v1.8.1 // indirect
+ github.com/PuerkitoBio/goquery v1.9.1 // indirect
github.com/ajg/form v1.5.1 // indirect
- github.com/alecthomas/chroma/v2 v2.12.0 // indirect
+ github.com/alecthomas/chroma/v2 v2.13.0 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/didip/tollbooth/v7 v7.0.1 // indirect
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f // indirect
- github.com/dlclark/regexp2 v1.10.0 // indirect
+ github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/go-chi/chi/v5 v5.0.12 // indirect
github.com/go-chi/render v1.0.3 // indirect
github.com/go-pkgz/expirable-cache v1.0.0 // indirect
@@ -32,10 +32,10 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
- go.etcd.io/bbolt v1.3.8 // indirect
+ go.etcd.io/bbolt v1.3.9 // indirect
golang.org/x/image v0.15.0 // indirect
- golang.org/x/net v0.21.0 // indirect
- golang.org/x/sys v0.17.0 // indirect
+ golang.org/x/net v0.24.0 // indirect
+ golang.org/x/sys v0.19.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/backend/_example/memory_store/go.sum b/backend/_example/memory_store/go.sum
index a7588ea701..9d685b7fc6 100644
--- a/backend/_example/memory_store/go.sum
+++ b/backend/_example/memory_store/go.sum
@@ -1,16 +1,15 @@
github.com/Depado/bfchroma/v2 v2.0.0 h1:IRpN9BPkNwEpR6w1ectIcNWOuhDSLx+8f1pn83fzxx8=
github.com/Depado/bfchroma/v2 v2.0.0/go.mod h1:wFwW/Pw8Tnd0irzgO9Zxtxgzp3aPS8qBWlyadxujxmw=
-github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
-github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
+github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI=
+github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
-github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
-github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
-github.com/alecthomas/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF7cmWgw=
-github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
-github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
-github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
-github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
+github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
+github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
+github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
+github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
+github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
+github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
@@ -23,8 +22,8 @@ github.com/didip/tollbooth/v7 v7.0.1 h1:TkT4sBKoQoHQFPf7blQ54iHrZiTDnr8TceU+MulV
github.com/didip/tollbooth/v7 v7.0.1/go.mod h1:VZhDSGl5bDSPj4wPsih3PFa4Uh9Ghv8hgacaTm5PRT4=
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f h1:jtKwihcLmUC9BAhoJ9adCUqdSSZcOdH2KL7mPTUm2aw=
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f/go.mod h1:q9C80dnsuVRP2dAskjnXRNWdUJqtGgwG9wNrzt0019s=
-github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
-github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
+github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
+github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
@@ -71,11 +70,11 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
-github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
-go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
-go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
+go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
+go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
@@ -84,34 +83,32 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
-golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
-golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
+golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
+golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
+golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
-golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
+golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
diff --git a/backend/go.mod b/backend/go.mod
index 1596fd4f2c..696baf83de 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -4,14 +4,14 @@ go 1.21
require (
github.com/Depado/bfchroma/v2 v2.0.0
- github.com/PuerkitoBio/goquery v1.8.1
- github.com/alecthomas/chroma/v2 v2.12.0
+ github.com/PuerkitoBio/goquery v1.9.1
+ github.com/alecthomas/chroma/v2 v2.13.0
github.com/didip/tollbooth/v7 v7.0.1
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f
github.com/go-chi/chi/v5 v5.0.12
github.com/go-chi/cors v1.2.1
github.com/go-chi/render v1.0.3
- github.com/go-pkgz/auth v1.22.2-0.20240117071454-f721b8c33b05
+ github.com/go-pkgz/auth v1.23.0
github.com/go-pkgz/jrpc v0.3.0
github.com/go-pkgz/lcw/v2 v2.0.0
github.com/go-pkgz/lgr v0.11.1
@@ -29,35 +29,35 @@ require (
github.com/rs/xid v1.5.0
github.com/russross/blackfriday/v2 v2.1.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
- github.com/stretchr/testify v1.8.4
- go.etcd.io/bbolt v1.3.8
+ github.com/stretchr/testify v1.9.0
+ go.etcd.io/bbolt v1.3.9
go.uber.org/goleak v1.3.0
- golang.org/x/crypto v0.19.0
+ golang.org/x/crypto v0.22.0
golang.org/x/image v0.15.0
- golang.org/x/net v0.21.0
+ golang.org/x/net v0.24.0
)
require (
- cloud.google.com/go/compute v1.23.3 // indirect
+ cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/dghubble/oauth1 v0.7.2 // indirect
+ github.com/dghubble/oauth1 v0.7.3 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
- github.com/dlclark/regexp2 v1.10.0 // indirect
+ github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/go-oauth2/oauth2/v4 v4.5.2 // indirect
github.com/go-pkgz/email v0.5.0 // indirect
github.com/go-pkgz/expirable-cache v1.0.0 // indirect
- github.com/golang/protobuf v1.5.3 // indirect
+ github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
- github.com/klauspost/compress v1.17.4 // indirect
+ github.com/klauspost/compress v1.17.7 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/redis/go-redis/v9 v9.4.0 // indirect
@@ -67,10 +67,10 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
- go.mongodb.org/mongo-driver v1.13.1 // indirect
- golang.org/x/oauth2 v0.17.0 // indirect
+ go.mongodb.org/mongo-driver v1.14.0 // indirect
+ golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.6.0 // indirect
- golang.org/x/sys v0.17.0 // indirect
+ golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index 6a7b9078b2..3b24a1786f 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -1,27 +1,26 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk=
-cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
+cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU=
+cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls=
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/Depado/bfchroma/v2 v2.0.0 h1:IRpN9BPkNwEpR6w1ectIcNWOuhDSLx+8f1pn83fzxx8=
github.com/Depado/bfchroma/v2 v2.0.0/go.mod h1:wFwW/Pw8Tnd0irzgO9Zxtxgzp3aPS8qBWlyadxujxmw=
-github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
-github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
+github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI=
+github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
-github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
-github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
-github.com/alecthomas/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF7cmWgw=
-github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
-github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
-github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
+github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
+github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
+github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
+github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
+github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
+github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.31.1 h1:7XAt0uUg3DtwEKW5ZAGa+K7FZV2DdKQo5K/6TTnfX8Y=
github.com/alicebob/miniredis/v2 v2.31.1/go.mod h1:UB/T2Uztp7MlFSDakaX1sTXUv5CASoprx0wulRT6HBg=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
-github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
@@ -35,8 +34,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dghubble/oauth1 v0.7.2 h1:pwcinOZy8z6XkNxvPmUDY52M7RDPxt0Xw1zgZ6Cl5JA=
-github.com/dghubble/oauth1 v0.7.2/go.mod h1:9erQdIhqhOHG/7K9s/tgh9Ks/AfoyrO5mW/43Lu2+kE=
+github.com/dghubble/oauth1 v0.7.3 h1:EkEM/zMDMp3zOsX2DC/ZQ2vnEX3ELK0/l9kb+vs4ptE=
+github.com/dghubble/oauth1 v0.7.3/go.mod h1:oxTe+az9NSMIucDPDCCtzJGsPhciJV33xocHfcR2sVY=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/didip/tollbooth/v7 v7.0.0/go.mod h1:VZhDSGl5bDSPj4wPsih3PFa4Uh9Ghv8hgacaTm5PRT4=
@@ -44,8 +43,8 @@ github.com/didip/tollbooth/v7 v7.0.1 h1:TkT4sBKoQoHQFPf7blQ54iHrZiTDnr8TceU+MulV
github.com/didip/tollbooth/v7 v7.0.1/go.mod h1:VZhDSGl5bDSPj4wPsih3PFa4Uh9Ghv8hgacaTm5PRT4=
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f h1:jtKwihcLmUC9BAhoJ9adCUqdSSZcOdH2KL7mPTUm2aw=
github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f/go.mod h1:q9C80dnsuVRP2dAskjnXRNWdUJqtGgwG9wNrzt0019s=
-github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
-github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
+github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
+github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
@@ -63,8 +62,8 @@ github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
github.com/go-oauth2/oauth2/v4 v4.5.2 h1:CuZhD3lhGuI6aNLyUbRHXsgG2RwGRBOuCBfd4WQKqBQ=
github.com/go-oauth2/oauth2/v4 v4.5.2/go.mod h1:wk/2uLImWIa9VVQDgxz99H2GDbhmfi/9/Xr+GvkSUSQ=
-github.com/go-pkgz/auth v1.22.2-0.20240117071454-f721b8c33b05 h1:oe9D1WzmKgG27i9PtDhxpDm+2n7KR431XHBGKLaQDLs=
-github.com/go-pkgz/auth v1.22.2-0.20240117071454-f721b8c33b05/go.mod h1:/ceyBqZEjBsjP8evrd25LnNM2zMNqj0vc5PIKYJmi0U=
+github.com/go-pkgz/auth v1.23.0 h1:jv/HaXKPL31p+SpEXYaGmROAEUWl5nWt/mQ31DCs7Y4=
+github.com/go-pkgz/auth v1.23.0/go.mod h1:2j8ln0c2TbCuhVCvcqh8mZC7ap5r1brNXkbF/VHi0F4=
github.com/go-pkgz/email v0.5.0 h1:fdtMDGJ8NwyBACLR0LYHaCIK/OeUwZHMhH7Q0+oty9U=
github.com/go-pkgz/email v0.5.0/go.mod h1:BdxglsQnymzhfdbnncEE72a6DrucZHy6I+42LK2jLEc=
github.com/go-pkgz/expirable-cache v0.1.0/go.mod h1:GTrEl0X+q0mPNqN6dtcQXksACnzCBQ5k/k1SwXJsZKs=
@@ -101,15 +100,13 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
-github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
@@ -143,10 +140,9 @@ github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LF
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
-github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
-github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
-github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
+github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
+github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -160,7 +156,6 @@ github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
-github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
@@ -202,27 +197,34 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
-github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/tidwall/btree v0.0.0-20191029221954-400434d76274 h1:G6Z6HvJuPjG6XfNGi/feOATzeJrfgTNJY+rGrHbA04E=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/btree v0.0.0-20191029221954-400434d76274/go.mod h1:huei1BkDWJ3/sLXmO+bsCNELL+Bp2Kks9OLyQFkzvA8=
-github.com/tidwall/buntdb v1.1.2 h1:noCrqQXL9EKMtcdwJcmuVKSEjqu1ua99RHHgbLTEHRo=
+github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
+github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/tidwall/buntdb v1.1.2/go.mod h1:xAzi36Hir4FarpSHyfuZ6JzPJdjRZ8QlLZSntE2mqlI=
+github.com/tidwall/buntdb v1.3.0 h1:gdhWO+/YwoB2qZMeAU9JcWWsHSYU3OvcieYgFRS0zwA=
+github.com/tidwall/buntdb v1.3.0/go.mod h1:lZZrZUWzlyDJKlLQ6DKAy53LnG7m5kHyrEHvvcDmBpU=
github.com/tidwall/gjson v1.3.4/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
-github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo=
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb h1:5NSYaAdrnblKByzd7XByQEJVT8+9v0W/tIY0Oo4OwrE=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb/go.mod h1:lKYYLFIr9OIgdgrtgkZ9zgRxRdvPYsExnYBsEAd8W5M=
+github.com/tidwall/grect v0.1.4 h1:dA3oIgNgWdSspFzn1kS4S/RDpZFLrIxAZOdJKjYapOg=
+github.com/tidwall/grect v0.1.4/go.mod h1:9FBsaYRaR0Tcy4UwefBX/UDcDcDy9V5jUcxHzv2jd5Q=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
-github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
-github.com/tidwall/rtree v0.0.0-20180113144539-6cd427091e0e h1:+NL1GDIUOKxVfbp2KoJQD9cTQ6dyP2co9q4yzmT9FZo=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/rtred v0.1.2 h1:exmoQtOLvDoO8ud++6LwVsAMTu0KPzLTUrMln8u1yu8=
+github.com/tidwall/rtred v0.1.2/go.mod h1:hd69WNXQ5RP9vHd7dqekAz+RIdtfBogmglkZSRxCHFQ=
github.com/tidwall/rtree v0.0.0-20180113144539-6cd427091e0e/go.mod h1:/h+UnNGt0IhNNJLkGikcdcJqm66zGD/uJGMRxK/9+Ao=
-github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ3KKDyCkxapfufrqDqwmGjcHfAyXRrE=
github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ=
+github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE=
+github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4=
@@ -242,7 +244,6 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
-github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
@@ -253,19 +254,18 @@ github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZ
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
-go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
-go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
-go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk=
-go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo=
+go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
+go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
+go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
+go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
-golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
+golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
+golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -279,18 +279,16 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
-golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
-golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
+golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
+golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
-golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
+golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI=
+golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -318,8 +316,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
-golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
+golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
diff --git a/backend/vendor/cloud.google.com/go/compute/internal/version.go b/backend/vendor/cloud.google.com/go/compute/internal/version.go
index 540ad16ac4..40d1a89160 100644
--- a/backend/vendor/cloud.google.com/go/compute/internal/version.go
+++ b/backend/vendor/cloud.google.com/go/compute/internal/version.go
@@ -15,4 +15,4 @@
package internal
// Version is the current tagged release of the library.
-const Version = "1.23.3"
+const Version = "1.25.1"
diff --git a/backend/vendor/github.com/PuerkitoBio/goquery/README.md b/backend/vendor/github.com/PuerkitoBio/goquery/README.md
index 582ccac90f..96a8d48be0 100644
--- a/backend/vendor/github.com/PuerkitoBio/goquery/README.md
+++ b/backend/vendor/github.com/PuerkitoBio/goquery/README.md
@@ -22,7 +22,7 @@ Syntax-wise, it is as close as possible to jQuery, with the same function names
## Installation
-Please note that because of the net/html dependency, goquery requires Go1.1+ and is tested on Go1.7+.
+Please note that starting with version `v1.9.0` of goquery, Go 1.18+ is required due to the use of generics. For previous goquery versions, a Go version of 1.1+ was required because of the `net/html` dependency. Ongoing goquery development is tested on the latest 2 versions of Go.
$ go get github.com/PuerkitoBio/goquery
@@ -40,6 +40,8 @@ Please note that because of the net/html dependency, goquery requires Go1.1+ and
**Note that goquery's API is now stable, and will not break.**
+* **2024-02-29 (v1.9.1)** : Improve allocation and performance of the `Map` function and `Selection.Map` method, better document the cascadia differences (thanks [@jwilsson](https://github.com/jwilsson)).
+* **2024-02-22 (v1.9.0)** : Add a generic `Map` function, **goquery now requires Go version 1.18+** (thanks [@Fesaa](https://github.com/Fesaa)).
* **2023-02-18 (v1.8.1)** : Update `go.mod` dependencies, update CI workflow.
* **2021-10-25 (v1.8.0)** : Add `Render` function to render a `Selection` to an `io.Writer` (thanks [@anthonygedeon](https://github.com/anthonygedeon)).
* **2021-07-11 (v1.7.1)** : Update go.mod dependencies and add dependabot config (thanks [@jauderho](https://github.com/jauderho)).
@@ -88,7 +90,7 @@ Utility functions that are not in jQuery but are useful in Go are implemented as
The complete [package reference documentation can be found here][doc].
-Please note that Cascadia's selectors do not necessarily match all supported selectors of jQuery (Sizzle). See the [cascadia project][cascadia] for details. Invalid selector strings compile to a `Matcher` that fails to match any node. Behaviour of the various functions that take a selector string as argument follows from that fact, e.g. (where `~` is an invalid selector string):
+Please note that Cascadia's selectors do not necessarily match all supported selectors of jQuery (Sizzle). See the [cascadia project][cascadia] for details. Also, the selectors work more like the DOM's `querySelectorAll`, than jQuery's matchers - they have no concept of contextual matching (for some concrete examples of what that means, see [this ticket](https://github.com/andybalholm/cascadia/issues/61)). In practice, it doesn't matter very often but it's something worth mentioning. Invalid selector strings compile to a `Matcher` that fails to match any node. Behaviour of the various functions that take a selector string as argument follows from that fact, e.g. (where `~` is an invalid selector string):
* `Find("~")` returns an empty selection because the selector string doesn't match anything.
* `Add("~")` returns a new selection that holds the same nodes as the original selection, because it didn't add any node (selector string didn't match anything).
@@ -157,6 +159,7 @@ func main() {
- [stitcherd](https://github.com/vhodges/stitcherd), A server for doing server side includes using css selectors and DOM updates.
- [goskyr](https://github.com/jakopako/goskyr), an easily configurable command-line scraper written in Go.
- [goGetJS](https://github.com/davemolk/goGetJS), a tool for extracting, searching, and saving JavaScript files (with optional headless browser).
+- [fitter](https://github.com/PxyUp/fitter), a tool for selecting values from JSON, XML, HTML and XPath formatted pages.
## Support
@@ -165,7 +168,7 @@ There are a number of ways you can support the project:
* Use it, star it, build something with it, spread the word!
- If you do build something open-source or otherwise publicly-visible, let me know so I can add it to the [Related Projects](#related-projects) section!
* Raise issues to improve the project (note: doc typos and clarifications are issues too!)
- - Please search existing issues before opening a new one - it may have already been adressed.
+ - Please search existing issues before opening a new one - it may have already been addressed.
* Pull requests: please discuss new code in an issue first, unless the fix is really trivial.
- Make sure new code is tested.
- Be mindful of existing code - PRs that break existing code have a high probability of being declined, unless it fixes a serious issue.
diff --git a/backend/vendor/github.com/PuerkitoBio/goquery/iteration.go b/backend/vendor/github.com/PuerkitoBio/goquery/iteration.go
index e246f2e0e6..1c98158bff 100644
--- a/backend/vendor/github.com/PuerkitoBio/goquery/iteration.go
+++ b/backend/vendor/github.com/PuerkitoBio/goquery/iteration.go
@@ -31,8 +31,16 @@ func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection {
// element in that selection starting at 0, and a *Selection that contains
// only that element.
func (s *Selection) Map(f func(int, *Selection) string) (result []string) {
+ return Map(s, f)
+}
+
+// Map is the generic version of Selection.Map, allowing any type to be
+// returned.
+func Map[E any](s *Selection, f func(int, *Selection) E) (result []E) {
+ result = make([]E, len(s.Nodes))
+
for i, n := range s.Nodes {
- result = append(result, f(i, newSingleSelection(n, s.document)))
+ result[i] = f(i, newSingleSelection(n, s.document))
}
return result
diff --git a/backend/vendor/github.com/PuerkitoBio/goquery/traversal.go b/backend/vendor/github.com/PuerkitoBio/goquery/traversal.go
index 5fa5315ac5..c45fa5db78 100644
--- a/backend/vendor/github.com/PuerkitoBio/goquery/traversal.go
+++ b/backend/vendor/github.com/PuerkitoBio/goquery/traversal.go
@@ -20,6 +20,12 @@ const (
// Find gets the descendants of each element in the current set of matched
// elements, filtered by a selector. It returns a new Selection object
// containing these matched elements.
+//
+// Note that as for all methods accepting a selector string, the selector is
+// compiled and applied by the cascadia package and inherits its behavior and
+// constraints regarding supported selectors. See the note on cascadia in
+// the goquery documentation here:
+// https://github.com/PuerkitoBio/goquery?tab=readme-ov-file#api
func (s *Selection) Find(selector string) *Selection {
return pushStack(s, findWithMatcher(s.Nodes, compileMatcher(selector)))
}
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/.editorconfig b/backend/vendor/github.com/alecthomas/chroma/v2/.editorconfig
index d80374e07f..cfb2c669e7 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/.editorconfig
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/.editorconfig
@@ -11,3 +11,7 @@ insert_final_newline = true
indent_style = space
indent_size = 2
insert_final_newline = false
+
+[*.yml]
+indent_style = space
+indent_size = 2
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml b/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
index 120ea7158c..668be374ab 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
@@ -49,6 +49,8 @@ linters:
- nosnakecase
- testableexamples
- musttag
+ - depguard
+ - goconst
linters-settings:
govet:
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/README.md b/backend/vendor/github.com/alecthomas/chroma/v2/README.md
index 6c347a0be3..775d3af2f8 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/README.md
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/README.md
@@ -8,75 +8,72 @@ highlighted HTML, ANSI-coloured text, etc.
Chroma is based heavily on [Pygments](http://pygments.org/), and includes
translators for Pygments lexers and styles.
-
-
## Table of Contents
-1. [Table of Contents](#table-of-contents)
-2. [Supported languages](#supported-languages)
-3. [Try it](#try-it)
-4. [Using the library](#using-the-library)
+1. [Supported languages](#supported-languages)
+2. [Try it](#try-it)
+3. [Using the library](#using-the-library)
1. [Quick start](#quick-start)
2. [Identifying the language](#identifying-the-language)
3. [Formatting the output](#formatting-the-output)
4. [The HTML formatter](#the-html-formatter)
-5. [More detail](#more-detail)
+4. [More detail](#more-detail)
1. [Lexers](#lexers)
2. [Formatters](#formatters)
3. [Styles](#styles)
-6. [Command-line interface](#command-line-interface)
-7. [Testing lexers](#testing-lexers)
-8. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
+5. [Command-line interface](#command-line-interface)
+6. [Testing lexers](#testing-lexers)
+7. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
-
-
## Supported languages
-| Prefix | Language |
-| :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, AutoHotkey, AutoIt, Awk |
-| B | Ballerina, Bash, Bash Session, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck |
-| C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython |
-| D | D, Dart, Dax, Diff, Django/Jinja, dns, Docker, DTD, Dylan |
-| E | EBNF, Elixir, Elm, EmacsLisp, Erlang |
-| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp |
-| G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy |
-| H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy |
-| I | Idris, Igor, INI, Io, ISCdhcpd |
-| J | J, Java, JavaScript, JSON, Julia, Jungle |
-| K | Kotlin |
-| L | Lighttpd configuration file, LLVM, Lua |
-| M | Makefile, Mako, markdown, Mason, Mathematica, Matlab, mcfunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL |
-| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix |
-| O | Objective-C, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode |
-| P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, PromQL, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 |
-| Q | QBasic, QML |
-| R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust |
-| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, Snobol, Solidity, SourcePawn, SPARQL, SQL, SquidConf, Standard ML, stas, Stylus, Svelte, Swift, SYSTEMD, systemverilog |
-| T | TableGen, Tal, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData |
-| V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue |
-| W | WDTE, WebGPU Shading Language, Whiley |
-| X | XML, Xorg |
-| Y | YAML, YANG |
-| Z | Z80 Assembly, Zed, Zig |
+| Prefix | Language |
+| :----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, AutoHotkey, AutoIt, Awk |
+| B | Ballerina, Bash, Bash Session, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck |
+| C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython |
+| D | D, Dart, Dax, Desktop Entry, Diff, Django/Jinja, dns, Docker, DTD, Dylan |
+| E | EBNF, Elixir, Elm, EmacsLisp, Erlang |
+| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp |
+| G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy |
+| H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy |
+| I | Idris, Igor, INI, Io, ISCdhcpd |
+| J | J, Java, JavaScript, JSON, Julia, Jungle |
+| K | Kotlin |
+| L | Lighttpd configuration file, LLVM, Lua |
+| M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, mcfunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL |
+| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix |
+| O | Objective-C, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode |
+| P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, PromQL, Promela, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 |
+| Q | QBasic, QML |
+| R | R, Racket, Ragel, Raku, react, ReasonML, reg, Rego, reStructuredText, Rexx, RPMSpec, Ruby, Rust |
+| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, Snobol, Solidity, SourcePawn, SPARQL, SQL, SquidConf, Standard ML, stas, Stylus, Svelte, Swift, SYSTEMD, systemverilog |
+| T | TableGen, Tal, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData |
+| V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue |
+| W | WDTE, WebGPU Shading Language, Whiley |
+| X | XML, Xorg |
+| Y | YAML, YANG |
+| Z | Z80 Assembly, Zed, Zig |
_I will attempt to keep this section up to date, but an authoritative list can be
displayed with `chroma --list`._
-
-
## Try it
Try out various languages and styles on the [Chroma Playground](https://swapoff.org/chroma/playground/).
-
-
## Using the library
+This is version 2 of Chroma, use the import path:
+
+```go
+import "github.com/alecthomas/chroma/v2"
+```
+
Chroma, like Pygments, has the concepts of
[lexers](https://github.com/alecthomas/chroma/tree/master/lexers),
[formatters](https://github.com/alecthomas/chroma/tree/master/formatters) and
@@ -95,8 +92,6 @@ In all cases, if a lexer, formatter or style can not be determined, `nil` will
be returned. In this situation you may want to default to the `Fallback`
value in each respective package, which provides sane defaults.
-
-
### Quick start
A convenience function exists that can be used to simply format some source
@@ -106,8 +101,6 @@ text, without any effort:
err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai")
```
-
-
### Identifying the language
To highlight code, you'll first have to identify what language the code is
@@ -147,8 +140,6 @@ token types into a single token:
lexer = chroma.Coalesce(lexer)
```
-
-
### Formatting the output
Once a language is identified you will need to pick a formatter and a style (theme).
@@ -177,8 +168,6 @@ And finally, format the tokens from the iterator:
err := formatter.Format(w, style, iterator)
```
-
-
### The HTML formatter
By default the `html` registered formatter generates standalone HTML with
@@ -203,12 +192,8 @@ formatter := html.New(html.WithClasses(true))
err := formatter.WriteCSS(w, style)
```
-
-
## More detail
-
-
### Lexers
See the [Pygments documentation](http://pygments.org/docs/lexerdevelopment/)
@@ -228,8 +213,6 @@ python3 _tools/pygments2chroma_xml.py \
See notes in [pygments-lexers.txt](https://github.com/alecthomas/chroma/blob/master/pygments-lexers.txt)
for a list of lexers, and notes on some of the issues importing them.
-
-
### Formatters
Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour, and true-colour.
@@ -237,8 +220,6 @@ Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour,
A `noop` formatter is included that outputs the token text only, and a `tokens`
formatter outputs raw tokens. The latter is useful for debugging lexers.
-
-
### Styles
Chroma styles are defined in XML. The style entries use the
@@ -262,8 +243,6 @@ Also, token types in a style file are hierarchical. For instance, when `CommentS
For a quick overview of the available styles and how they look, check out the [Chroma Style Gallery](https://xyproto.github.io/splash/docs/).
-
-
## Command-line interface
A command-line interface to Chroma is included.
@@ -288,10 +267,6 @@ on under the hood for easy integration with [lesspipe shipping with
Debian and derivatives](https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS);
for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`.
-
-
-
-
## Testing lexers
If you edit some lexers and want to try it, open a shell in `cmd/chromad` and run:
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go b/backend/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
index 0ad6b31ce2..92d784c245 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
@@ -5,7 +5,9 @@ import (
"html"
"io"
"sort"
+ "strconv"
"strings"
+ "sync"
"github.com/alecthomas/chroma/v2"
)
@@ -132,6 +134,7 @@ func New(options ...Option) *Formatter {
baseLineNumber: 1,
preWrapper: defaultPreWrapper,
}
+ f.styleCache = newStyleCache(f)
for _, option := range options {
option(f)
}
@@ -188,6 +191,7 @@ var (
// Formatter that generates HTML.
type Formatter struct {
+ styleCache *styleCache
standalone bool
prefix string
Classes bool // Exported field to detect when classes are being used
@@ -220,12 +224,7 @@ func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Ite
//
// OTOH we need to be super careful about correct escaping...
func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.Token) (err error) { // nolint: gocyclo
- css := f.styleToCSS(style)
- if !f.Classes {
- for t, style := range css {
- css[t] = compressStyle(style)
- }
- }
+ css := f.styleCache.get(style, true)
if f.standalone {
fmt.Fprint(w, "\n")
if f.Classes {
@@ -243,7 +242,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
wrapInTable := f.lineNumbers && f.lineNumbersInTable
lines := chroma.SplitTokensIntoLines(tokens)
- lineDigits := len(fmt.Sprintf("%d", f.baseLineNumber+len(lines)-1))
+ lineDigits := len(strconv.Itoa(f.baseLineNumber + len(lines) - 1))
highlightIndex := 0
if wrapInTable {
@@ -251,7 +250,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
fmt.Fprintf(w, "
\n", f.styleAttr(css, chroma.PreWrapper))
fmt.Fprintf(w, "
", f.styleAttr(css, chroma.LineTable))
fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.LineTableTD))
- fmt.Fprintf(w, f.preWrapper.Start(false, f.styleAttr(css, chroma.PreWrapper)))
+ fmt.Fprintf(w, "%s", f.preWrapper.Start(false, f.styleAttr(css, chroma.PreWrapper)))
for index := range lines {
line := f.baseLineNumber + index
highlight, next := f.shouldHighlight(highlightIndex, line)
@@ -273,7 +272,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
fmt.Fprintf(w, " | \n", f.styleAttr(css, chroma.LineTableTD, "width:100%"))
}
- fmt.Fprintf(w, f.preWrapper.Start(true, f.styleAttr(css, chroma.PreWrapper)))
+ fmt.Fprintf(w, "%s", f.preWrapper.Start(true, f.styleAttr(css, chroma.PreWrapper)))
highlightIndex = 0
for index, tokens := range lines {
@@ -323,7 +322,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
fmt.Fprint(w, ``) // End of Line
}
}
- fmt.Fprintf(w, f.preWrapper.End(true))
+ fmt.Fprintf(w, "%s", f.preWrapper.End(true))
if wrapInTable {
fmt.Fprint(w, " |
\n")
@@ -419,7 +418,7 @@ func (f *Formatter) tabWidthStyle() string {
// WriteCSS writes CSS style definitions (without any surrounding HTML).
func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error {
- css := f.styleToCSS(style)
+ css := f.styleCache.get(style, false)
// Special-case background as it is mapped to the outer ".chroma" class.
if _, err := fmt.Fprintf(w, "/* %s */ .%sbg { %s }\n", chroma.Background, f.prefix, css[chroma.Background]); err != nil {
return err
@@ -562,3 +561,63 @@ func compressStyle(s string) string {
}
return strings.Join(out, ";")
}
+
+const styleCacheLimit = 32
+
+type styleCacheEntry struct {
+ style *chroma.Style
+ compressed bool
+ cache map[chroma.TokenType]string
+}
+
+type styleCache struct {
+ mu sync.Mutex
+ // LRU cache of compiled (and possibly compressed) styles. This is a slice
+ // because the cache size is small, and a slice is sufficiently fast for
+ // small N.
+ cache []styleCacheEntry
+ f *Formatter
+}
+
+func newStyleCache(f *Formatter) *styleCache {
+ return &styleCache{f: f}
+}
+
+func (l *styleCache) get(style *chroma.Style, compress bool) map[chroma.TokenType]string {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+
+ // Look for an existing entry.
+ for i := len(l.cache) - 1; i >= 0; i-- {
+ entry := l.cache[i]
+ if entry.style == style && entry.compressed == compress {
+ // Top of the cache, no need to adjust the order.
+ if i == len(l.cache)-1 {
+ return entry.cache
+ }
+ // Move this entry to the end of the LRU
+ copy(l.cache[i:], l.cache[i+1:])
+ l.cache[len(l.cache)-1] = entry
+ return entry.cache
+ }
+ }
+
+ // No entry, create one.
+ cached := l.f.styleToCSS(style)
+ if !l.f.Classes {
+ for t, style := range cached {
+ cached[t] = compressStyle(style)
+ }
+ }
+ if compress {
+ for t, style := range cached {
+ cached[t] = compressStyle(style)
+ }
+ }
+ // Evict the oldest entry.
+ if len(l.cache) >= styleCacheLimit {
+ l.cache = l.cache[0:copy(l.cache, l.cache[1:])]
+ }
+ l.cache = append(l.cache, styleCacheEntry{style: style, cache: cached, compressed: compress})
+ return cached
+}
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
index 9100efa82d..82a7efa487 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
@@ -4,52 +4,82 @@ import (
. "github.com/alecthomas/chroma/v2" // nolint
)
+// Matcher token stub for docs, or
+// Named matcher: @name, or
+// Path matcher: /foo, or
+// Wildcard path matcher: *
+// nolint: gosec
+var caddyfileMatcherTokenRegexp = `(\[\
\]|@[^\s]+|/[^\s]+|\*)`
+
+// Comment at start of line, or
+// Comment preceded by whitespace
+var caddyfileCommentRegexp = `(^|\s+)#.*\n`
+
// caddyfileCommon are the rules common to both of the lexer variants
func caddyfileCommonRules() Rules {
return Rules{
"site_block_common": {
+ Include("site_body"),
+ // Any other directive
+ {`[^\s#]+`, Keyword, Push("directive")},
+ Include("base"),
+ },
+ "site_body": {
// Import keyword
- {`(import)(\s+)([^\s]+)`, ByGroups(Keyword, Text, NameVariableMagic), nil},
+ {`\b(import|invoke)\b( [^\s#]+)`, ByGroups(Keyword, Text), Push("subdirective")},
// Matcher definition
{`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
// Matcher token stub for docs
{`\[\\]`, NameDecorator, Push("matcher")},
// These cannot have matchers but may have things that look like
// matchers in their arguments, so we just parse as a subdirective.
- {`try_files`, Keyword, Push("subdirective")},
+ {`\b(try_files|tls|log|bind)\b`, Keyword, Push("subdirective")},
// These are special, they can nest more directives
- {`handle_errors|handle|route|handle_path|not`, Keyword, Push("nested_directive")},
- // Any other directive
- {`[^\s#]+`, Keyword, Push("directive")},
- Include("base"),
+ {`\b(handle_errors|handle_path|handle_response|replace_status|handle|route)\b`, Keyword, Push("nested_directive")},
+ // uri directive has special syntax
+ {`\b(uri)\b`, Keyword, Push("uri_directive")},
},
"matcher": {
{`\{`, Punctuation, Push("block")},
// Not can be one-liner
{`not`, Keyword, Push("deep_not_matcher")},
+ // Heredoc for CEL expression
+ Include("heredoc"),
+ // Backtick for CEL expression
+ {"`", StringBacktick, Push("backticks")},
// Any other same-line matcher
{`[^\s#]+`, Keyword, Push("arguments")},
// Terminators
- {`\n`, Text, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
{`\}`, Punctuation, Pop(1)},
Include("base"),
},
"block": {
{`\}`, Punctuation, Pop(2)},
+ // Using double quotes doesn't stop at spaces
+ {`"`, StringDouble, Push("double_quotes")},
+ // Using backticks doesn't stop at spaces
+ {"`", StringBacktick, Push("backticks")},
// Not can be one-liner
{`not`, Keyword, Push("not_matcher")},
- // Any other subdirective
+ // Directives & matcher definitions
+ Include("site_body"),
+ // Any directive
{`[^\s#]+`, Keyword, Push("subdirective")},
Include("base"),
},
"nested_block": {
{`\}`, Punctuation, Pop(2)},
- // Matcher definition
- {`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
- // Something that starts with literally < is probably a docs stub
- {`\<[^#]+\>`, Keyword, Push("nested_directive")},
- // Any other directive
- {`[^\s#]+`, Keyword, Push("nested_directive")},
+ // Using double quotes doesn't stop at spaces
+ {`"`, StringDouble, Push("double_quotes")},
+ // Using backticks doesn't stop at spaces
+ {"`", StringBacktick, Push("backticks")},
+ // Not can be one-liner
+ {`not`, Keyword, Push("not_matcher")},
+ // Directives & matcher definitions
+ Include("site_body"),
+ // Any other subdirective
+ {`[^\s#]+`, Keyword, Push("directive")},
Include("base"),
},
"not_matcher": {
@@ -66,69 +96,97 @@ func caddyfileCommonRules() Rules {
},
"directive": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("matcher_token"),
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileMatcherTokenRegexp, NameDecorator, Push("arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"nested_directive": {
{`\{(?=\s)`, Punctuation, Push("nested_block")},
- Include("matcher_token"),
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileMatcherTokenRegexp, NameDecorator, Push("nested_arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"subdirective": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"arguments": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_2"),
+ {caddyfileCommentRegexp, CommentSingle, Pop(2)},
{`\\\n`, Text, nil}, // Skip escaped newlines
- {`\n`, Text, Pop(2)},
+ {`\s*\n`, Text, Pop(2)},
+ Include("base"),
+ },
+ "nested_arguments": {
+ {`\{(?=\s)`, Punctuation, Push("nested_block")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(2)},
+ {`\\\n`, Text, nil}, // Skip escaped newlines
+ {`\s*\n`, Text, Pop(2)},
Include("base"),
},
"deep_subdirective": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_3"),
- {`\n`, Text, Pop(3)},
+ {caddyfileCommentRegexp, CommentSingle, Pop(3)},
+ {`\s*\n`, Text, Pop(3)},
+ Include("base"),
+ },
+ "uri_directive": {
+ {`\{(?=\s)`, Punctuation, Push("block")},
+ {caddyfileMatcherTokenRegexp, NameDecorator, nil},
+ {`(strip_prefix|strip_suffix|replace|path_regexp)`, NameConstant, Push("arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
- "matcher_token": {
- {`@[^\s]+`, NameDecorator, Push("arguments")}, // Named matcher
- {`/[^\s]+`, NameDecorator, Push("arguments")}, // Path matcher
- {`\*`, NameDecorator, Push("arguments")}, // Wildcard path matcher
- {`\[\\]`, NameDecorator, Push("arguments")}, // Matcher token stub for docs
+ "double_quotes": {
+ Include("placeholder"),
+ {`\\"`, StringDouble, nil},
+ {`[^"]`, StringDouble, nil},
+ {`"`, StringDouble, Pop(1)},
},
- "comments": {
- {`^#.*\n`, CommentSingle, nil}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, nil}, // Comment preceded by whitespace
+ "backticks": {
+ Include("placeholder"),
+ {"\\\\`", StringBacktick, nil},
+ {"[^`]", StringBacktick, nil},
+ {"`", StringBacktick, Pop(1)},
},
- "comments_pop_1": {
- {`^#.*\n`, CommentSingle, Pop(1)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(1)}, // Comment preceded by whitespace
+ "optional": {
+ // Docs syntax for showing optional parts with [ ]
+ {`\[`, Punctuation, Push("optional")},
+ Include("name_constants"),
+ {`\|`, Punctuation, nil},
+ {`[^\[\]\|]+`, String, nil},
+ {`\]`, Punctuation, Pop(1)},
},
- "comments_pop_2": {
- {`^#.*\n`, CommentSingle, Pop(2)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(2)}, // Comment preceded by whitespace
+ "heredoc": {
+ {`(<<([a-zA-Z0-9_-]+))(\n(.*|\n)*)(\s*)(\2)`, ByGroups(StringHeredoc, nil, String, String, String, StringHeredoc), nil},
},
- "comments_pop_3": {
- {`^#.*\n`, CommentSingle, Pop(3)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(3)}, // Comment preceded by whitespace
+ "name_constants": {
+ {`\b(most_recently_modified|largest_size|smallest_size|first_exist|internal|disable_redirects|ignore_loaded_certs|disable_certs|private_ranges|first|last|before|after|on|off)\b(\||(?=\]|\s|$))`, ByGroups(NameConstant, Punctuation), nil},
+ },
+ "placeholder": {
+ // Placeholder with dots, colon for default value, brackets for args[0:]
+ {`\{[\w+.\[\]\:\$-]+\}`, StringEscape, nil},
+ // Handle opening brackets with no matching closing one
+ {`\{[^\}\s]*\b`, String, nil},
},
"base": {
- Include("comments"),
- {`(on|off|first|last|before|after|internal|strip_prefix|strip_suffix|replace)\b`, NameConstant, nil},
- {`(https?://)?([a-z0-9.-]+)(:)([0-9]+)`, ByGroups(Name, Name, Punctuation, LiteralNumberInteger), nil},
- {`[a-z-]+/[a-z-+]+`, LiteralString, nil},
- {`[0-9]+[km]?\b`, LiteralNumberInteger, nil},
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, nil}, // Placeholder
- {`\[(?=[^#{}$]+\])`, Punctuation, nil},
- {`\]|\|`, Punctuation, nil},
- {`[^\s#{}$\]]+`, LiteralString, nil},
+ {caddyfileCommentRegexp, CommentSingle, nil},
+ {`\[\\]`, NameDecorator, nil},
+ Include("name_constants"),
+ Include("heredoc"),
+ {`(https?://)?([a-z0-9.-]+)(:)([0-9]+)([^\s]*)`, ByGroups(Name, Name, Punctuation, NumberInteger, Name), nil},
+ {`\[`, Punctuation, Push("optional")},
+ {"`", StringBacktick, Push("backticks")},
+ {`"`, StringDouble, Push("double_quotes")},
+ Include("placeholder"),
+ {`[a-z-]+/[a-z-+]+`, String, nil},
+ {`[0-9]+([smhdk]|ns|us|µs|ms)?\b`, NumberInteger, nil},
+ {`[^\s\n#\{]+`, String, nil},
{`/[^\s#]*`, Name, nil},
{`\s+`, Text, nil},
},
@@ -149,27 +207,29 @@ var Caddyfile = Register(MustNewLexer(
func caddyfileRules() Rules {
return Rules{
"root": {
- Include("comments"),
+ {caddyfileCommentRegexp, CommentSingle, nil},
// Global options block
{`^\s*(\{)\s*$`, ByGroups(Punctuation), Push("globals")},
+ // Top level import
+ {`(import)(\s+)([^\s]+)`, ByGroups(Keyword, Text, NameVariableMagic), nil},
// Snippets
- {`(\([^\s#]+\))(\s*)(\{)`, ByGroups(NameVariableAnonymous, Text, Punctuation), Push("snippet")},
+ {`(&?\([^\s#]+\))(\s*)(\{)`, ByGroups(NameVariableAnonymous, Text, Punctuation), Push("snippet")},
// Site label
{`[^#{(\s,]+`, GenericHeading, Push("label")},
// Site label with placeholder
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, Push("label")},
+ {`\{[\w+.\[\]\:\$-]+\}`, StringEscape, Push("label")},
{`\s+`, Text, nil},
},
"globals": {
{`\}`, Punctuation, Pop(1)},
- {`[^\s#]+`, Keyword, Push("directive")},
+ // Global options are parsed as subdirectives (no matcher)
+ {`[^\s#]+`, Keyword, Push("subdirective")},
Include("base"),
},
"snippet": {
{`\}`, Punctuation, Pop(1)},
- // Matcher definition
- {`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
- // Any directive
+ Include("site_body"),
+ // Any other directive
{`[^\s#]+`, Keyword, Push("directive")},
Include("base"),
},
@@ -179,7 +239,7 @@ func caddyfileRules() Rules {
{`,\s*\n?`, Text, nil},
{` `, Text, nil},
// Site label with placeholder
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, nil},
+ Include("placeholder"),
// Site label
{`[^#{(\s,]+`, GenericHeading, nil},
// Comment after non-block label (hack because comments end in \n)
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
index 801a9543b9..f1e21db03f 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
@@ -19,10 +19,10 @@
-
+
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
index 16d7387267..d6c3ea71bf 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
@@ -49,7 +49,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml
new file mode 100644
index 0000000000..ad71ad4715
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml
@@ -0,0 +1,17 @@
+
+
+ Desktop file
+ desktop
+ desktop_entry
+ *.desktop
+ application/x-desktop
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
index 6dc6912efb..5f805d6da0 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
@@ -86,7 +86,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
index bbe10b1ba6..3473cfd14f 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
@@ -3,6 +3,7 @@
JSON
json
*.json
+ *.avsc
application/json
true
true
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml
new file mode 100644
index 0000000000..7b22a46c60
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml
@@ -0,0 +1,155 @@
+
+
+ Materialize SQL dialect
+ materialize
+ mzsql
+ text/x-materializesql
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+ 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml
new file mode 100644
index 0000000000..74d443b649
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml
@@ -0,0 +1,123 @@
+
+
+ NDISASM
+ ndisasm
+ text/x-disasm
+ true
+ 0.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml
new file mode 100644
index 0000000000..84558c3b65
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml
@@ -0,0 +1,119 @@
+
+
+
+ Promela
+ promela
+ *.pml
+ *.prom
+ *.prm
+ *.promela
+ *.pr
+ *.pm
+ text/x-promela
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml
new file mode 100644
index 0000000000..517b7133b0
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml
@@ -0,0 +1,94 @@
+
+
+ Rego
+ rego
+ *.rego
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml
new file mode 100644
index 0000000000..8362772a6f
--- /dev/null
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml
@@ -0,0 +1,58 @@
+
+
+
+ RPMSpec
+ spec
+ *.spec
+ text/x-rpm-spec
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
index 77bc2259c6..266289b7c7 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
@@ -55,7 +55,7 @@ func goRules() Rules {
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])`, Operator, nil},
{`([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(NameFunction, UsingSelf("root"), Punctuation), nil},
- {`[|^<>=!()\[\]{}.,;:]`, Punctuation, nil},
+ {`[|^<>=!()\[\]{}.,;:~]`, Punctuation, nil},
{`[^\W\d]\w*`, NameOther, nil},
},
}
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/renovate.json5 b/backend/vendor/github.com/alecthomas/chroma/v2/renovate.json5
index 897864b852..77c7b016cc 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/renovate.json5
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/renovate.json5
@@ -1,11 +1,18 @@
{
- $schema: "https://docs.renovatebot.com/renovate-schema.json",
- extends: [
- "config:recommended",
- ":semanticCommits",
- ":semanticCommitTypeAll(chore)",
- ":semanticCommitScope(deps)",
- "group:allNonMajor",
- "schedule:earlyMondays", // Run once a week.
- ],
+ $schema: "https://docs.renovatebot.com/renovate-schema.json",
+ extends: [
+ "config:recommended",
+ ":semanticCommits",
+ ":semanticCommitTypeAll(chore)",
+ ":semanticCommitScope(deps)",
+ "group:allNonMajor",
+ "schedule:earlyMondays", // Run once a week.
+ ],
+ packageRules: [
+ {
+ matchPackageNames: ["golangci-lint"],
+ matchManagers: ["hermit"],
+ enabled: false,
+ },
+ ],
}
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml
index 08eb42a630..0adf1ba9e3 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml
index 3d510743c0..3ea767fd4a 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml
index 5d96f59966..6b50028487 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml
index e17866dd2c..9a401912f3 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
index 0adb775610..711aeafc4a 100644
--- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
+++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
@@ -1,6 +1,6 @@
+
\ No newline at end of file
diff --git a/backend/vendor/github.com/dghubble/oauth1/CHANGES.md b/backend/vendor/github.com/dghubble/oauth1/CHANGES.md
index 1abf12c83c..75bd3f5ce0 100644
--- a/backend/vendor/github.com/dghubble/oauth1/CHANGES.md
+++ b/backend/vendor/github.com/dghubble/oauth1/CHANGES.md
@@ -4,6 +4,12 @@ Notable changes between releases.
## Latest
+## v0.7.3
+
+* Percent encode special characters in HMAC-SHA1 secrets ([#72](https://github.com/dghubble/oauth1/pull/72))
+* Strip whitespace from request token body ([#56](https://github.com/dghubble/oauth1/pull/56))
+* Update Go module dependencies
+
## v0.7.2
* Update minimum Go version from v1.17 to v1.18 ([#66](https://github.com/dghubble/oauth1/pull/66))
diff --git a/backend/vendor/github.com/dghubble/oauth1/README.md b/backend/vendor/github.com/dghubble/oauth1/README.md
index c54803c410..c4badbf99f 100644
--- a/backend/vendor/github.com/dghubble/oauth1/README.md
+++ b/backend/vendor/github.com/dghubble/oauth1/README.md
@@ -1,4 +1,8 @@
-# OAuth1 [![GoDoc](https://pkg.go.dev/badge/github.com/dghubble/oauth1.svg)](https://pkg.go.dev/github.com/dghubble/oauth1) [![Workflow](https://github.com/dghubble/oauth1/actions/workflows/test.yaml/badge.svg)](https://github.com/dghubble/oauth1/actions/workflows/test.yaml?query=branch%3Amain) [![Sponsors](https://img.shields.io/github/sponsors/dghubble?logo=github)](https://github.com/sponsors/dghubble) [![Mastodon](https://img.shields.io/badge/follow-news-6364ff?logo=mastodon)](https://fosstodon.org/@typhoon)
+# OAuth1
+[![GoDoc](https://pkg.go.dev/badge/github.com/dghubble/oauth1.svg)](https://pkg.go.dev/github.com/dghubble/oauth1)
+[![Workflow](https://github.com/dghubble/oauth1/actions/workflows/test.yaml/badge.svg)](https://github.com/dghubble/oauth1/actions/workflows/test.yaml?query=branch%3Amain)
+[![Sponsors](https://img.shields.io/github/sponsors/dghubble?logo=github)](https://github.com/sponsors/dghubble)
+[![Mastodon](https://img.shields.io/badge/follow-news-6364ff?logo=mastodon)](https://fosstodon.org/@typhoon)
diff --git a/backend/vendor/github.com/dghubble/oauth1/config.go b/backend/vendor/github.com/dghubble/oauth1/config.go
index c539a00b33..e47de195d5 100644
--- a/backend/vendor/github.com/dghubble/oauth1/config.go
+++ b/backend/vendor/github.com/dghubble/oauth1/config.go
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
+ "strings"
)
const (
@@ -89,7 +90,7 @@ func (c *Config) RequestToken() (requestToken, requestSecret string, err error)
}
// ParseQuery to decode URL-encoded application/x-www-form-urlencoded body
- values, err := url.ParseQuery(string(body))
+ values, err := url.ParseQuery(strings.TrimSpace(string(body)))
if err != nil {
return "", "", err
}
diff --git a/backend/vendor/github.com/dghubble/oauth1/signer.go b/backend/vendor/github.com/dghubble/oauth1/signer.go
index 2f8ac5e609..963aa5a96d 100644
--- a/backend/vendor/github.com/dghubble/oauth1/signer.go
+++ b/backend/vendor/github.com/dghubble/oauth1/signer.go
@@ -32,7 +32,7 @@ func (s *HMACSigner) Name() string {
}
func hmacSign(consumerSecret, tokenSecret, message string, algo func() hash.Hash) (string, error) {
- signingKey := strings.Join([]string{consumerSecret, tokenSecret}, "&")
+ signingKey := strings.Join([]string{PercentEncode(consumerSecret), PercentEncode(tokenSecret)}, "&")
mac := hmac.New(algo, []byte(signingKey))
mac.Write([]byte(message))
signatureBytes := mac.Sum(nil)
diff --git a/backend/vendor/github.com/dlclark/regexp2/regexp.go b/backend/vendor/github.com/dlclark/regexp2/regexp.go
index c8f9e6b000..a7ddbaf358 100644
--- a/backend/vendor/github.com/dlclark/regexp2/regexp.go
+++ b/backend/vendor/github.com/dlclark/regexp2/regexp.go
@@ -18,8 +18,12 @@ import (
"github.com/dlclark/regexp2/syntax"
)
-// Default timeout used when running regexp matches -- "forever"
-var DefaultMatchTimeout = time.Duration(math.MaxInt64)
+var (
+ // DefaultMatchTimeout used when running regexp matches -- "forever"
+ DefaultMatchTimeout = time.Duration(math.MaxInt64)
+ // DefaultUnmarshalOptions used when unmarshaling a regex from text
+ DefaultUnmarshalOptions = None
+)
// Regexp is the representation of a compiled regular expression.
// A Regexp is safe for concurrent use by multiple goroutines.
@@ -43,7 +47,7 @@ type Regexp struct {
code *syntax.Code // compiled program
// cache of machines for running regexp
- muRun sync.Mutex
+ muRun *sync.Mutex
runner []*runner
}
@@ -72,6 +76,7 @@ func Compile(expr string, opt RegexOptions) (*Regexp, error) {
capsize: code.Capsize,
code: code,
MatchTimeout: DefaultMatchTimeout,
+ muRun: &sync.Mutex{},
}, nil
}
@@ -371,3 +376,20 @@ func (re *Regexp) GroupNumberFromName(name string) int {
return -1
}
+
+// MarshalText implements [encoding.TextMarshaler]. The output
+// matches that of calling the [Regexp.String] method.
+func (re *Regexp) MarshalText() ([]byte, error) {
+ return []byte(re.String()), nil
+}
+
+// UnmarshalText implements [encoding.TextUnmarshaler] by calling
+// [Compile] on the encoded value.
+func (re *Regexp) UnmarshalText(text []byte) error {
+ newRE, err := Compile(string(text), DefaultUnmarshalOptions)
+ if err != nil {
+ return err
+ }
+ *re = *newRE
+ return nil
+}
diff --git a/backend/vendor/github.com/go-pkgz/auth/.golangci.yml b/backend/vendor/github.com/go-pkgz/auth/.golangci.yml
index 192d484a2b..eab781a1a3 100644
--- a/backend/vendor/github.com/go-pkgz/auth/.golangci.yml
+++ b/backend/vendor/github.com/go-pkgz/auth/.golangci.yml
@@ -80,4 +80,10 @@ issues:
- text: 'Deferring unsafe method "Close" on type "io.ReadCloser"'
linters:
- gosec
+ - linters:
+ - unparam
+ - unused
+ - revive
+ path: _test\.go$
+ text: "unused-parameter"
exclude-use-default: false
diff --git a/backend/vendor/github.com/go-pkgz/auth/avatar/localfs.go b/backend/vendor/github.com/go-pkgz/auth/avatar/localfs.go
index f387d2f7d4..ee4828c0c0 100644
--- a/backend/vendor/github.com/go-pkgz/auth/avatar/localfs.go
+++ b/backend/vendor/github.com/go-pkgz/auth/avatar/localfs.go
@@ -89,7 +89,7 @@ func (fs *LocalFS) Remove(avatar string) error {
// note: id includes .image suffix
func (fs *LocalFS) List() (ids []string, err error) {
err = filepath.Walk(fs.storePath,
- func(path string, info os.FileInfo, err error) error {
+ func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
diff --git a/backend/vendor/github.com/go-pkgz/auth/logger/interface.go b/backend/vendor/github.com/go-pkgz/auth/logger/interface.go
index ac43b009fc..857243184e 100644
--- a/backend/vendor/github.com/go-pkgz/auth/logger/interface.go
+++ b/backend/vendor/github.com/go-pkgz/auth/logger/interface.go
@@ -16,7 +16,7 @@ type Func func(format string, args ...interface{})
func (f Func) Logf(format string, args ...interface{}) { f(format, args...) }
// NoOp logger
-var NoOp = Func(func(format string, args ...interface{}) {})
+var NoOp = Func(func(string, ...interface{}) {})
// Std logger sends to std default logger directly
var Std = Func(func(format string, args ...interface{}) { log.Printf(format, args...) })
diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/providers.go b/backend/vendor/github.com/go-pkgz/auth/provider/providers.go
index 186f498ffb..4487b4cb03 100644
--- a/backend/vendor/github.com/go-pkgz/auth/provider/providers.go
+++ b/backend/vendor/github.com/go-pkgz/auth/provider/providers.go
@@ -199,7 +199,7 @@ func NewMicrosoft(p Params) Oauth2Handler {
infoURL: "https://graph.microsoft.com/v1.0/me",
// non-beta doesn't provide photo for consumers yet
// see https://github.com/microsoftgraph/microsoft-graph-docs/issues/3990
- mapUser: func(data UserData, b []byte) token.User {
+ mapUser: func(data UserData, _ []byte) token.User {
userInfo := token.User{
ID: "microsoft_" + token.HashID(sha1.New(), data.Value("id")),
Name: data.Value("displayName"),
diff --git a/backend/vendor/github.com/klauspost/compress/.goreleaser.yml b/backend/vendor/github.com/klauspost/compress/.goreleaser.yml
index 4c28dff465..a22953805c 100644
--- a/backend/vendor/github.com/klauspost/compress/.goreleaser.yml
+++ b/backend/vendor/github.com/klauspost/compress/.goreleaser.yml
@@ -3,7 +3,6 @@
before:
hooks:
- ./gen.sh
- - go install mvdan.cc/garble@v0.10.1
builds:
-
@@ -32,7 +31,6 @@ builds:
- mips64le
goarm:
- 7
- gobinary: garble
-
id: "s2d"
binary: s2d
@@ -59,7 +57,6 @@ builds:
- mips64le
goarm:
- 7
- gobinary: garble
-
id: "s2sx"
binary: s2sx
@@ -87,7 +84,6 @@ builds:
- mips64le
goarm:
- 7
- gobinary: garble
archives:
-
diff --git a/backend/vendor/github.com/klauspost/compress/README.md b/backend/vendor/github.com/klauspost/compress/README.md
index 7e83f583c0..1f72cdde18 100644
--- a/backend/vendor/github.com/klauspost/compress/README.md
+++ b/backend/vendor/github.com/klauspost/compress/README.md
@@ -16,6 +16,30 @@ This package provides various compression algorithms.
# changelog
+* Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6)
+ * zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
+ * s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
+
+* Jan 26th, 2024 - [v1.17.5](https://github.com/klauspost/compress/releases/tag/v1.17.5)
+ * flate: Fix reset with dictionary on custom window encodes https://github.com/klauspost/compress/pull/912
+ * zstd: Add Frame header encoding and stripping https://github.com/klauspost/compress/pull/908
+ * zstd: Limit better/best default window to 8MB https://github.com/klauspost/compress/pull/913
+ * zstd: Speed improvements by @greatroar in https://github.com/klauspost/compress/pull/896 https://github.com/klauspost/compress/pull/910
+ * s2: Fix callbacks for skippable blocks and disallow 0xfe (Padding) by @Jille in https://github.com/klauspost/compress/pull/916 https://github.com/klauspost/compress/pull/917
+https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/compress/pull/918
+
+* Dec 1st, 2023 - [v1.17.4](https://github.com/klauspost/compress/releases/tag/v1.17.4)
+ * huff0: Speed up symbol counting by @greatroar in https://github.com/klauspost/compress/pull/887
+ * huff0: Remove byteReader by @greatroar in https://github.com/klauspost/compress/pull/886
+ * gzhttp: Allow overriding decompression on transport https://github.com/klauspost/compress/pull/892
+ * gzhttp: Clamp compression level https://github.com/klauspost/compress/pull/890
+ * gzip: Error out if reserved bits are set https://github.com/klauspost/compress/pull/891
+
+* Nov 15th, 2023 - [v1.17.3](https://github.com/klauspost/compress/releases/tag/v1.17.3)
+ * fse: Fix max header size https://github.com/klauspost/compress/pull/881
+ * zstd: Improve better/best compression https://github.com/klauspost/compress/pull/877
+ * gzhttp: Fix missing content type on Close https://github.com/klauspost/compress/pull/883
+
* Oct 22nd, 2023 - [v1.17.2](https://github.com/klauspost/compress/releases/tag/v1.17.2)
* zstd: Fix rare *CORRUPTION* output in "best" mode. See https://github.com/klauspost/compress/pull/876
@@ -554,7 +578,7 @@ For direct deflate use, NewStatelessWriter and StatelessDeflate are available. S
A `bufio.Writer` can of course be used to control write sizes. For example, to use a 4KB buffer:
-```
+```go
// replace 'ioutil.Discard' with your output.
gzw, err := gzip.NewWriterLevel(ioutil.Discard, gzip.StatelessCompression)
if err != nil {
diff --git a/backend/vendor/github.com/klauspost/compress/s2sx.mod b/backend/vendor/github.com/klauspost/compress/s2sx.mod
index 2263853fca..5a4412f907 100644
--- a/backend/vendor/github.com/klauspost/compress/s2sx.mod
+++ b/backend/vendor/github.com/klauspost/compress/s2sx.mod
@@ -1,4 +1,4 @@
module github.com/klauspost/compress
-go 1.16
+go 1.19
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/decodeheader.go b/backend/vendor/github.com/klauspost/compress/zstd/decodeheader.go
index f6a240970d..6a5a2988b6 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/decodeheader.go
+++ b/backend/vendor/github.com/klauspost/compress/zstd/decodeheader.go
@@ -95,42 +95,54 @@ type Header struct {
// If there isn't enough input, io.ErrUnexpectedEOF is returned.
// The FirstBlock.OK will indicate if enough information was available to decode the first block header.
func (h *Header) Decode(in []byte) error {
+ _, err := h.DecodeAndStrip(in)
+ return err
+}
+
+// DecodeAndStrip will decode the header from the beginning of the stream
+// and on success return the remaining bytes.
+// This will decode the frame header and the first block header if enough bytes are provided.
+// It is recommended to provide at least HeaderMaxSize bytes.
+// If the frame header cannot be read an error will be returned.
+// If there isn't enough input, io.ErrUnexpectedEOF is returned.
+// The FirstBlock.OK will indicate if enough information was available to decode the first block header.
+func (h *Header) DecodeAndStrip(in []byte) (remain []byte, err error) {
*h = Header{}
if len(in) < 4 {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
h.HeaderSize += 4
b, in := in[:4], in[4:]
if string(b) != frameMagic {
if string(b[1:4]) != skippableFrameMagic || b[0]&0xf0 != 0x50 {
- return ErrMagicMismatch
+ return nil, ErrMagicMismatch
}
if len(in) < 4 {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
h.HeaderSize += 4
h.Skippable = true
h.SkippableID = int(b[0] & 0xf)
h.SkippableSize = binary.LittleEndian.Uint32(in)
- return nil
+ return in[4:], nil
}
// Read Window_Descriptor
// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#window_descriptor
if len(in) < 1 {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
fhd, in := in[0], in[1:]
h.HeaderSize++
h.SingleSegment = fhd&(1<<5) != 0
h.HasCheckSum = fhd&(1<<2) != 0
if fhd&(1<<3) != 0 {
- return errors.New("reserved bit set on frame header")
+ return nil, errors.New("reserved bit set on frame header")
}
if !h.SingleSegment {
if len(in) < 1 {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
var wd byte
wd, in = in[0], in[1:]
@@ -148,7 +160,7 @@ func (h *Header) Decode(in []byte) error {
size = 4
}
if len(in) < int(size) {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
b, in = in[:size], in[size:]
h.HeaderSize += int(size)
@@ -178,7 +190,7 @@ func (h *Header) Decode(in []byte) error {
if fcsSize > 0 {
h.HasFCS = true
if len(in) < fcsSize {
- return io.ErrUnexpectedEOF
+ return nil, io.ErrUnexpectedEOF
}
b, in = in[:fcsSize], in[fcsSize:]
h.HeaderSize += int(fcsSize)
@@ -199,7 +211,7 @@ func (h *Header) Decode(in []byte) error {
// Frame Header done, we will not fail from now on.
if len(in) < 3 {
- return nil
+ return in, nil
}
tmp := in[:3]
bh := uint32(tmp[0]) | (uint32(tmp[1]) << 8) | (uint32(tmp[2]) << 16)
@@ -209,7 +221,7 @@ func (h *Header) Decode(in []byte) error {
cSize := int(bh >> 3)
switch blockType {
case blockTypeReserved:
- return nil
+ return in, nil
case blockTypeRLE:
h.FirstBlock.Compressed = true
h.FirstBlock.DecompressedSize = cSize
@@ -225,5 +237,25 @@ func (h *Header) Decode(in []byte) error {
}
h.FirstBlock.OK = true
- return nil
+ return in, nil
+}
+
+// AppendTo will append the encoded header to the dst slice.
+// There is no error checking performed on the header values.
+func (h *Header) AppendTo(dst []byte) ([]byte, error) {
+ if h.Skippable {
+ magic := [4]byte{0x50, 0x2a, 0x4d, 0x18}
+ magic[0] |= byte(h.SkippableID & 0xf)
+ dst = append(dst, magic[:]...)
+ f := h.SkippableSize
+ return append(dst, uint8(f), uint8(f>>8), uint8(f>>16), uint8(f>>24)), nil
+ }
+ f := frameHeader{
+ ContentSize: h.FrameContentSize,
+ WindowSize: uint32(h.WindowSize),
+ SingleSegment: h.SingleSegment,
+ Checksum: h.HasCheckSum,
+ DictID: h.DictionaryID,
+ }
+ return f.appendTo(dst), nil
}
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/enc_best.go b/backend/vendor/github.com/klauspost/compress/zstd/enc_best.go
index c81a15357a..87f42879a8 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/enc_best.go
+++ b/backend/vendor/github.com/klauspost/compress/zstd/enc_best.go
@@ -201,14 +201,6 @@ encodeLoop:
if delta >= e.maxMatchOff || delta <= 0 || load3232(src, offset) != first {
return
}
- if debugAsserts {
- if offset >= s {
- panic(fmt.Sprintf("offset: %d - s:%d - rep: %d - cur :%d - max: %d", offset, s, rep, e.cur, e.maxMatchOff))
- }
- if !bytes.Equal(src[s:s+4], src[offset:offset+4]) {
- panic(fmt.Sprintf("first match mismatch: %v != %v, first: %08x", src[s:s+4], src[offset:offset+4], first))
- }
- }
// Try to quick reject if we already have a long match.
if m.length > 16 {
left := len(src) - int(m.s+m.length)
@@ -227,8 +219,10 @@ encodeLoop:
}
}
l := 4 + e.matchlen(s+4, offset+4, src)
- if true {
+ if m.rep <= 0 {
// Extend candidate match backwards as far as possible.
+ // Do not extend repeats as we can assume they are optimal
+ // and offsets change if s == nextEmit.
tMin := s - e.maxMatchOff
if tMin < 0 {
tMin = 0
@@ -239,7 +233,14 @@ encodeLoop:
l++
}
}
-
+ if debugAsserts {
+ if offset >= s {
+ panic(fmt.Sprintf("offset: %d - s:%d - rep: %d - cur :%d - max: %d", offset, s, rep, e.cur, e.maxMatchOff))
+ }
+ if !bytes.Equal(src[s:s+l], src[offset:offset+l]) {
+ panic(fmt.Sprintf("second match mismatch: %v != %v, first: %08x", src[s:s+4], src[offset:offset+4], first))
+ }
+ }
cand := match{offset: offset, s: s, length: l, rep: rep}
cand.estBits(bitsPerByte)
if m.est >= highScore || cand.est-m.est+(cand.s-m.s)*bitsPerByte>>10 < 0 {
@@ -336,24 +337,31 @@ encodeLoop:
}
if debugAsserts {
+ if best.offset >= best.s {
+ panic(fmt.Sprintf("best.offset > s: %d >= %d", best.offset, best.s))
+ }
+ if best.s < nextEmit {
+ panic(fmt.Sprintf("s %d < nextEmit %d", best.s, nextEmit))
+ }
+ if best.offset < s-e.maxMatchOff {
+ panic(fmt.Sprintf("best.offset < s-e.maxMatchOff: %d < %d", best.offset, s-e.maxMatchOff))
+ }
if !bytes.Equal(src[best.s:best.s+best.length], src[best.offset:best.offset+best.length]) {
panic(fmt.Sprintf("match mismatch: %v != %v", src[best.s:best.s+best.length], src[best.offset:best.offset+best.length]))
}
}
// We have a match, we can store the forward value
+ s = best.s
if best.rep > 0 {
var seq seq
seq.matchLen = uint32(best.length - zstdMinMatch)
- if debugAsserts && s < nextEmit {
- panic("s < nextEmit")
- }
addLiterals(&seq, best.s)
// Repeat. If bit 4 is set, this is a non-lit repeat.
seq.offset = uint32(best.rep & 3)
if debugSequences {
- println("repeat sequence", seq, "next s:", s)
+ println("repeat sequence", seq, "next s:", best.s, "off:", best.s-best.offset)
}
blk.sequences = append(blk.sequences, seq)
@@ -396,7 +404,6 @@ encodeLoop:
// A 4-byte match has been found. Update recent offsets.
// We'll later see if more than 4 bytes.
- s = best.s
t := best.offset
offset1, offset2, offset3 = s-t, offset1, offset2
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/encoder_options.go b/backend/vendor/github.com/klauspost/compress/zstd/encoder_options.go
index faaf81921c..20671dcb91 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/encoder_options.go
+++ b/backend/vendor/github.com/klauspost/compress/zstd/encoder_options.go
@@ -94,7 +94,7 @@ func WithEncoderConcurrency(n int) EOption {
// The value must be a power of two between MinWindowSize and MaxWindowSize.
// A larger value will enable better compression but allocate more memory and,
// for above-default values, take considerably longer.
-// The default value is determined by the compression level.
+// The default value is determined by the compression level and max 8MB.
func WithWindowSize(n int) EOption {
return func(o *encoderOptions) error {
switch {
@@ -232,9 +232,9 @@ func WithEncoderLevel(l EncoderLevel) EOption {
case SpeedDefault:
o.windowSize = 8 << 20
case SpeedBetterCompression:
- o.windowSize = 16 << 20
+ o.windowSize = 8 << 20
case SpeedBestCompression:
- o.windowSize = 32 << 20
+ o.windowSize = 8 << 20
}
}
if !o.customALEntropy {
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/frameenc.go b/backend/vendor/github.com/klauspost/compress/zstd/frameenc.go
index 2f5d5ed454..667ca06794 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/frameenc.go
+++ b/backend/vendor/github.com/klauspost/compress/zstd/frameenc.go
@@ -76,7 +76,7 @@ func (f frameHeader) appendTo(dst []byte) []byte {
if f.SingleSegment {
dst = append(dst, uint8(f.ContentSize))
}
- // Unless SingleSegment is set, framessizes < 256 are nto stored.
+ // Unless SingleSegment is set, framessizes < 256 are not stored.
case 1:
f.ContentSize -= 256
dst = append(dst, uint8(f.ContentSize), uint8(f.ContentSize>>8))
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go b/backend/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go
index 332e51fe44..8adfebb029 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go
+++ b/backend/vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go
@@ -20,10 +20,9 @@ func (s *fseDecoder) buildDtable() error {
if v == -1 {
s.dt[highThreshold].setAddBits(uint8(i))
highThreshold--
- symbolNext[i] = 1
- } else {
- symbolNext[i] = uint16(v)
+ v = 1
}
+ symbolNext[i] = uint16(v)
}
}
@@ -35,10 +34,12 @@ func (s *fseDecoder) buildDtable() error {
for ss, v := range s.norm[:s.symbolLen] {
for i := 0; i < int(v); i++ {
s.dt[position].setAddBits(uint8(ss))
- position = (position + step) & tableMask
- for position > highThreshold {
+ for {
// lowprob area
position = (position + step) & tableMask
+ if position <= highThreshold {
+ break
+ }
}
}
}
diff --git a/backend/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s b/backend/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
index 974b99725f..5b06174b89 100644
--- a/backend/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
+++ b/backend/vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
@@ -157,8 +157,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
// Update Literal Length State
MOVBQZX DI, R14
- SHRQ $0x10, DI
- MOVWQZX DI, DI
+ SHRL $0x10, DI
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -177,8 +176,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
// Update Match Length State
MOVBQZX R8, R14
- SHRQ $0x10, R8
- MOVWQZX R8, R8
+ SHRL $0x10, R8
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -197,8 +195,7 @@ sequenceDecs_decode_amd64_ll_update_zero:
// Update Offset State
MOVBQZX R9, R14
- SHRQ $0x10, R9
- MOVWQZX R9, R9
+ SHRL $0x10, R9
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -459,8 +456,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
// Update Literal Length State
MOVBQZX DI, R14
- SHRQ $0x10, DI
- MOVWQZX DI, DI
+ SHRL $0x10, DI
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -479,8 +475,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
// Update Match Length State
MOVBQZX R8, R14
- SHRQ $0x10, R8
- MOVWQZX R8, R8
+ SHRL $0x10, R8
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -499,8 +494,7 @@ sequenceDecs_decode_56_amd64_ll_update_zero:
// Update Offset State
MOVBQZX R9, R14
- SHRQ $0x10, R9
- MOVWQZX R9, R9
+ SHRL $0x10, R9
LEAQ (BX)(R14*1), CX
MOVQ DX, R15
MOVQ CX, BX
@@ -772,11 +766,10 @@ sequenceDecs_decode_bmi2_fill_2_end:
BZHIQ R14, R15, R15
// Update Offset State
- BZHIQ R8, R15, CX
- SHRXQ R8, R15, R15
- MOVQ $0x00001010, R14
- BEXTRQ R14, R8, R8
- ADDQ CX, R8
+ BZHIQ R8, R15, CX
+ SHRXQ R8, R15, R15
+ SHRL $0x10, R8
+ ADDQ CX, R8
// Load ctx.ofTable
MOVQ ctx+16(FP), CX
@@ -784,11 +777,10 @@ sequenceDecs_decode_bmi2_fill_2_end:
MOVQ (CX)(R8*8), R8
// Update Match Length State
- BZHIQ DI, R15, CX
- SHRXQ DI, R15, R15
- MOVQ $0x00001010, R14
- BEXTRQ R14, DI, DI
- ADDQ CX, DI
+ BZHIQ DI, R15, CX
+ SHRXQ DI, R15, R15
+ SHRL $0x10, DI
+ ADDQ CX, DI
// Load ctx.mlTable
MOVQ ctx+16(FP), CX
@@ -796,10 +788,9 @@ sequenceDecs_decode_bmi2_fill_2_end:
MOVQ (CX)(DI*8), DI
// Update Literal Length State
- BZHIQ SI, R15, CX
- MOVQ $0x00001010, R14
- BEXTRQ R14, SI, SI
- ADDQ CX, SI
+ BZHIQ SI, R15, CX
+ SHRL $0x10, SI
+ ADDQ CX, SI
// Load ctx.llTable
MOVQ ctx+16(FP), CX
@@ -1032,11 +1023,10 @@ sequenceDecs_decode_56_bmi2_fill_end:
BZHIQ R14, R15, R15
// Update Offset State
- BZHIQ R8, R15, CX
- SHRXQ R8, R15, R15
- MOVQ $0x00001010, R14
- BEXTRQ R14, R8, R8
- ADDQ CX, R8
+ BZHIQ R8, R15, CX
+ SHRXQ R8, R15, R15
+ SHRL $0x10, R8
+ ADDQ CX, R8
// Load ctx.ofTable
MOVQ ctx+16(FP), CX
@@ -1044,11 +1034,10 @@ sequenceDecs_decode_56_bmi2_fill_end:
MOVQ (CX)(R8*8), R8
// Update Match Length State
- BZHIQ DI, R15, CX
- SHRXQ DI, R15, R15
- MOVQ $0x00001010, R14
- BEXTRQ R14, DI, DI
- ADDQ CX, DI
+ BZHIQ DI, R15, CX
+ SHRXQ DI, R15, R15
+ SHRL $0x10, DI
+ ADDQ CX, DI
// Load ctx.mlTable
MOVQ ctx+16(FP), CX
@@ -1056,10 +1045,9 @@ sequenceDecs_decode_56_bmi2_fill_end:
MOVQ (CX)(DI*8), DI
// Update Literal Length State
- BZHIQ SI, R15, CX
- MOVQ $0x00001010, R14
- BEXTRQ R14, SI, SI
- ADDQ CX, SI
+ BZHIQ SI, R15, CX
+ SHRL $0x10, SI
+ ADDQ CX, SI
// Load ctx.llTable
MOVQ ctx+16(FP), CX
@@ -1967,8 +1955,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
// Update Literal Length State
MOVBQZX DI, R13
- SHRQ $0x10, DI
- MOVWQZX DI, DI
+ SHRL $0x10, DI
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -1987,8 +1974,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
// Update Match Length State
MOVBQZX R8, R13
- SHRQ $0x10, R8
- MOVWQZX R8, R8
+ SHRL $0x10, R8
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -2007,8 +1993,7 @@ sequenceDecs_decodeSync_amd64_ll_update_zero:
// Update Offset State
MOVBQZX R9, R13
- SHRQ $0x10, R9
- MOVWQZX R9, R9
+ SHRL $0x10, R9
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -2514,11 +2499,10 @@ sequenceDecs_decodeSync_bmi2_fill_2_end:
BZHIQ R13, R14, R14
// Update Offset State
- BZHIQ R8, R14, CX
- SHRXQ R8, R14, R14
- MOVQ $0x00001010, R13
- BEXTRQ R13, R8, R8
- ADDQ CX, R8
+ BZHIQ R8, R14, CX
+ SHRXQ R8, R14, R14
+ SHRL $0x10, R8
+ ADDQ CX, R8
// Load ctx.ofTable
MOVQ ctx+16(FP), CX
@@ -2526,11 +2510,10 @@ sequenceDecs_decodeSync_bmi2_fill_2_end:
MOVQ (CX)(R8*8), R8
// Update Match Length State
- BZHIQ DI, R14, CX
- SHRXQ DI, R14, R14
- MOVQ $0x00001010, R13
- BEXTRQ R13, DI, DI
- ADDQ CX, DI
+ BZHIQ DI, R14, CX
+ SHRXQ DI, R14, R14
+ SHRL $0x10, DI
+ ADDQ CX, DI
// Load ctx.mlTable
MOVQ ctx+16(FP), CX
@@ -2538,10 +2521,9 @@ sequenceDecs_decodeSync_bmi2_fill_2_end:
MOVQ (CX)(DI*8), DI
// Update Literal Length State
- BZHIQ SI, R14, CX
- MOVQ $0x00001010, R13
- BEXTRQ R13, SI, SI
- ADDQ CX, SI
+ BZHIQ SI, R14, CX
+ SHRL $0x10, SI
+ ADDQ CX, SI
// Load ctx.llTable
MOVQ ctx+16(FP), CX
@@ -3055,8 +3037,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
// Update Literal Length State
MOVBQZX DI, R13
- SHRQ $0x10, DI
- MOVWQZX DI, DI
+ SHRL $0x10, DI
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -3075,8 +3056,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
// Update Match Length State
MOVBQZX R8, R13
- SHRQ $0x10, R8
- MOVWQZX R8, R8
+ SHRL $0x10, R8
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -3095,8 +3075,7 @@ sequenceDecs_decodeSync_safe_amd64_ll_update_zero:
// Update Offset State
MOVBQZX R9, R13
- SHRQ $0x10, R9
- MOVWQZX R9, R9
+ SHRL $0x10, R9
LEAQ (BX)(R13*1), CX
MOVQ DX, R14
MOVQ CX, BX
@@ -3704,11 +3683,10 @@ sequenceDecs_decodeSync_safe_bmi2_fill_2_end:
BZHIQ R13, R14, R14
// Update Offset State
- BZHIQ R8, R14, CX
- SHRXQ R8, R14, R14
- MOVQ $0x00001010, R13
- BEXTRQ R13, R8, R8
- ADDQ CX, R8
+ BZHIQ R8, R14, CX
+ SHRXQ R8, R14, R14
+ SHRL $0x10, R8
+ ADDQ CX, R8
// Load ctx.ofTable
MOVQ ctx+16(FP), CX
@@ -3716,11 +3694,10 @@ sequenceDecs_decodeSync_safe_bmi2_fill_2_end:
MOVQ (CX)(R8*8), R8
// Update Match Length State
- BZHIQ DI, R14, CX
- SHRXQ DI, R14, R14
- MOVQ $0x00001010, R13
- BEXTRQ R13, DI, DI
- ADDQ CX, DI
+ BZHIQ DI, R14, CX
+ SHRXQ DI, R14, R14
+ SHRL $0x10, DI
+ ADDQ CX, DI
// Load ctx.mlTable
MOVQ ctx+16(FP), CX
@@ -3728,10 +3705,9 @@ sequenceDecs_decodeSync_safe_bmi2_fill_2_end:
MOVQ (CX)(DI*8), DI
// Update Literal Length State
- BZHIQ SI, R14, CX
- MOVQ $0x00001010, R13
- BEXTRQ R13, SI, SI
- ADDQ CX, SI
+ BZHIQ SI, R14, CX
+ SHRL $0x10, SI
+ ADDQ CX, SI
// Load ctx.llTable
MOVQ ctx+16(FP), CX
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/backend/vendor/github.com/stretchr/testify/assert/assertion_compare.go
index b774da88d8..4d4b4aad6f 100644
--- a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare.go
+++ b/backend/vendor/github.com/stretchr/testify/assert/assertion_compare.go
@@ -28,6 +28,8 @@ var (
uint32Type = reflect.TypeOf(uint32(1))
uint64Type = reflect.TypeOf(uint64(1))
+ uintptrType = reflect.TypeOf(uintptr(1))
+
float32Type = reflect.TypeOf(float32(1))
float64Type = reflect.TypeOf(float64(1))
@@ -308,11 +310,11 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
case reflect.Struct:
{
// All structs enter here. We're not interested in most types.
- if !canConvert(obj1Value, timeType) {
+ if !obj1Value.CanConvert(timeType) {
break
}
- // time.Time can compared!
+ // time.Time can be compared!
timeObj1, ok := obj1.(time.Time)
if !ok {
timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
@@ -328,7 +330,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
case reflect.Slice:
{
// We only care about the []byte type.
- if !canConvert(obj1Value, bytesType) {
+ if !obj1Value.CanConvert(bytesType) {
break
}
@@ -345,6 +347,26 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
}
+ case reflect.Uintptr:
+ {
+ uintptrObj1, ok := obj1.(uintptr)
+ if !ok {
+ uintptrObj1 = obj1Value.Convert(uintptrType).Interface().(uintptr)
+ }
+ uintptrObj2, ok := obj2.(uintptr)
+ if !ok {
+ uintptrObj2 = obj2Value.Convert(uintptrType).Interface().(uintptr)
+ }
+ if uintptrObj1 > uintptrObj2 {
+ return compareGreater, true
+ }
+ if uintptrObj1 == uintptrObj2 {
+ return compareEqual, true
+ }
+ if uintptrObj1 < uintptrObj2 {
+ return compareLess, true
+ }
+ }
}
return compareEqual, false
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go b/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
deleted file mode 100644
index da867903e2..0000000000
--- a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build go1.17
-// +build go1.17
-
-// TODO: once support for Go 1.16 is dropped, this file can be
-// merged/removed with assertion_compare_go1.17_test.go and
-// assertion_compare_legacy.go
-
-package assert
-
-import "reflect"
-
-// Wrapper around reflect.Value.CanConvert, for compatibility
-// reasons.
-func canConvert(value reflect.Value, to reflect.Type) bool {
- return value.CanConvert(to)
-}
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go b/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
deleted file mode 100644
index 1701af2a3c..0000000000
--- a/backend/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build !go1.17
-// +build !go1.17
-
-// TODO: once support for Go 1.16 is dropped, this file can be
-// merged/removed with assertion_compare_go1.17_test.go and
-// assertion_compare_can_convert.go
-
-package assert
-
-import "reflect"
-
-// Older versions of Go does not have the reflect.Value.CanConvert
-// method.
-func canConvert(value reflect.Value, to reflect.Type) bool {
- return false
-}
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertion_format.go b/backend/vendor/github.com/stretchr/testify/assert/assertion_format.go
index 84dbd6c790..3ddab109ad 100644
--- a/backend/vendor/github.com/stretchr/testify/assert/assertion_format.go
+++ b/backend/vendor/github.com/stretchr/testify/assert/assertion_format.go
@@ -1,7 +1,4 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
+// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package assert
@@ -107,7 +104,7 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
-// EqualValuesf asserts that two objects are equal or convertable to the same types
+// EqualValuesf asserts that two objects are equal or convertible to the same types
// and equal.
//
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
@@ -616,6 +613,16 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf
return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
}
+// NotImplementsf asserts that an object does not implement the specified interface.
+//
+// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
+}
+
// NotNilf asserts that the specified object is not nil.
//
// assert.NotNilf(t, err, "error message %s", "formatted")
@@ -660,10 +667,12 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string,
return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
}
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubsetf asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
+// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -747,10 +756,11 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg
return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
}
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subsetf asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
+// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/backend/vendor/github.com/stretchr/testify/assert/assertion_forward.go
index b1d94aec53..a84e09bd40 100644
--- a/backend/vendor/github.com/stretchr/testify/assert/assertion_forward.go
+++ b/backend/vendor/github.com/stretchr/testify/assert/assertion_forward.go
@@ -1,7 +1,4 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
+// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package assert
@@ -189,7 +186,7 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
}
-// EqualValues asserts that two objects are equal or convertable to the same types
+// EqualValues asserts that two objects are equal or convertible to the same types
// and equal.
//
// a.EqualValues(uint32(123), int32(123))
@@ -200,7 +197,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
return EqualValues(a.t, expected, actual, msgAndArgs...)
}
-// EqualValuesf asserts that two objects are equal or convertable to the same types
+// EqualValuesf asserts that two objects are equal or convertible to the same types
// and equal.
//
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
@@ -1221,6 +1218,26 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in
return NotErrorIsf(a.t, err, target, msg, args...)
}
+// NotImplements asserts that an object does not implement the specified interface.
+//
+// a.NotImplements((*MyInterface)(nil), new(MyObject))
+func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotImplements(a.t, interfaceObject, object, msgAndArgs...)
+}
+
+// NotImplementsf asserts that an object does not implement the specified interface.
+//
+// a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotImplementsf(a.t, interfaceObject, object, msg, args...)
+}
+
// NotNil asserts that the specified object is not nil.
//
// a.NotNil(err)
@@ -1309,10 +1326,12 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri
return NotSamef(a.t, expected, actual, msg, args...)
}
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubset asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+// a.NotSubset([1, 3, 4], [1, 2])
+// a.NotSubset({"x": 1, "y": 2}, {"z": 3})
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1320,10 +1339,12 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs
return NotSubset(a.t, list, subset, msgAndArgs...)
}
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubsetf asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+// a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted")
+// a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1483,10 +1504,11 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string,
return Samef(a.t, expected, actual, msg, args...)
}
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subset asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+// a.Subset([1, 2, 3], [1, 2])
+// a.Subset({"x": 1, "y": 2}, {"x": 1})
func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1494,10 +1516,11 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...
return Subset(a.t, list, subset, msgAndArgs...)
}
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subsetf asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+// a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted")
+// a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
diff --git a/backend/vendor/github.com/stretchr/testify/assert/assertions.go b/backend/vendor/github.com/stretchr/testify/assert/assertions.go
index a55d1bba92..0b7570f21c 100644
--- a/backend/vendor/github.com/stretchr/testify/assert/assertions.go
+++ b/backend/vendor/github.com/stretchr/testify/assert/assertions.go
@@ -19,7 +19,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/pmezard/go-difflib/difflib"
- yaml "gopkg.in/yaml.v3"
+ "gopkg.in/yaml.v3"
)
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
@@ -110,7 +110,12 @@ func copyExportedFields(expected interface{}) interface{} {
return result.Interface()
case reflect.Array, reflect.Slice:
- result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
+ var result reflect.Value
+ if expectedKind == reflect.Array {
+ result = reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem()
+ } else {
+ result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
+ }
for i := 0; i < expectedValue.Len(); i++ {
index := expectedValue.Index(i)
if isNil(index) {
@@ -140,6 +145,8 @@ func copyExportedFields(expected interface{}) interface{} {
// structures.
//
// This function does no assertion of any kind.
+//
+// Deprecated: Use [EqualExportedValues] instead.
func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool {
expectedCleaned := copyExportedFields(expected)
actualCleaned := copyExportedFields(actual)
@@ -153,17 +160,40 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool {
return true
}
- actualType := reflect.TypeOf(actual)
- if actualType == nil {
+ expectedValue := reflect.ValueOf(expected)
+ actualValue := reflect.ValueOf(actual)
+ if !expectedValue.IsValid() || !actualValue.IsValid() {
return false
}
- expectedValue := reflect.ValueOf(expected)
- if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
+
+ expectedType := expectedValue.Type()
+ actualType := actualValue.Type()
+ if !expectedType.ConvertibleTo(actualType) {
+ return false
+ }
+
+ if !isNumericType(expectedType) || !isNumericType(actualType) {
// Attempt comparison after type conversion
- return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual)
+ return reflect.DeepEqual(
+ expectedValue.Convert(actualType).Interface(), actual,
+ )
}
- return false
+ // If BOTH values are numeric, there are chances of false positives due
+ // to overflow or underflow. So, we need to make sure to always convert
+ // the smaller type to a larger type before comparing.
+ if expectedType.Size() >= actualType.Size() {
+ return actualValue.Convert(expectedType).Interface() == expected
+ }
+
+ return expectedValue.Convert(actualType).Interface() == actual
+}
+
+// isNumericType returns true if the type is one of:
+// int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64,
+// float32, float64, complex64, complex128
+func isNumericType(t reflect.Type) bool {
+ return t.Kind() >= reflect.Int && t.Kind() <= reflect.Complex128
}
/* CallerInfo is necessary because the assert functions use the testing object
@@ -266,7 +296,7 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
// Aligns the provided message so that all lines after the first line start at the same location as the first line.
// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab).
-// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the
+// The longestLabelLen parameter specifies the length of the longest label in the output (required because this is the
// basis on which the alignment occurs).
func indentMessageLines(message string, longestLabelLen int) string {
outBuf := new(bytes.Buffer)
@@ -382,6 +412,25 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg
return true
}
+// NotImplements asserts that an object does not implement the specified interface.
+//
+// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
+func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ interfaceType := reflect.TypeOf(interfaceObject).Elem()
+
+ if object == nil {
+ return Fail(t, fmt.Sprintf("Cannot check if nil does not implement %v", interfaceType), msgAndArgs...)
+ }
+ if reflect.TypeOf(object).Implements(interfaceType) {
+ return Fail(t, fmt.Sprintf("%T implements %v", object, interfaceType), msgAndArgs...)
+ }
+
+ return true
+}
+
// IsType asserts that the specified objects are of the same type.
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
@@ -496,7 +545,7 @@ func samePointers(first, second interface{}) bool {
// representations appropriate to be presented to the user.
//
// If the values are not of like type, the returned strings will be prefixed
-// with the type name, and the value will be enclosed in parenthesis similar
+// with the type name, and the value will be enclosed in parentheses similar
// to a type conversion in the Go grammar.
func formatUnequalValues(expected, actual interface{}) (e string, a string) {
if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
@@ -523,7 +572,7 @@ func truncatingFormat(data interface{}) string {
return value
}
-// EqualValues asserts that two objects are equal or convertable to the same types
+// EqualValues asserts that two objects are equal or convertible to the same types
// and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
@@ -566,12 +615,19 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ..
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
}
+ if aType.Kind() == reflect.Ptr {
+ aType = aType.Elem()
+ }
+ if bType.Kind() == reflect.Ptr {
+ bType = bType.Elem()
+ }
+
if aType.Kind() != reflect.Struct {
- return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...)
}
if bType.Kind() != reflect.Struct {
- return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
}
expected = copyExportedFields(expected)
@@ -620,17 +676,6 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
return Fail(t, "Expected value not to be nil.", msgAndArgs...)
}
-// containsKind checks if a specified kind in the slice of kinds.
-func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool {
- for i := 0; i < len(kinds); i++ {
- if kind == kinds[i] {
- return true
- }
- }
-
- return false
-}
-
// isNil checks if a specified object is nil or not, without Failing.
func isNil(object interface{}) bool {
if object == nil {
@@ -638,16 +683,13 @@ func isNil(object interface{}) bool {
}
value := reflect.ValueOf(object)
- kind := value.Kind()
- isNilableKind := containsKind(
- []reflect.Kind{
- reflect.Chan, reflect.Func,
- reflect.Interface, reflect.Map,
- reflect.Ptr, reflect.Slice, reflect.UnsafePointer},
- kind)
-
- if isNilableKind && value.IsNil() {
- return true
+ switch value.Kind() {
+ case
+ reflect.Chan, reflect.Func,
+ reflect.Interface, reflect.Map,
+ reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
+
+ return value.IsNil()
}
return false
@@ -731,16 +773,14 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
}
-// getLen try to get length of object.
-// return (false, 0) if impossible.
-func getLen(x interface{}) (ok bool, length int) {
+// getLen tries to get the length of an object.
+// It returns (0, false) if impossible.
+func getLen(x interface{}) (length int, ok bool) {
v := reflect.ValueOf(x)
defer func() {
- if e := recover(); e != nil {
- ok = false
- }
+ ok = recover() == nil
}()
- return true, v.Len()
+ return v.Len(), true
}
// Len asserts that the specified object has specific length.
@@ -751,13 +791,13 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
if h, ok := t.(tHelper); ok {
h.Helper()
}
- ok, l := getLen(object)
+ l, ok := getLen(object)
if !ok {
- return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...)
}
if l != length {
- return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...)
+ return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...)
}
return true
}
@@ -919,10 +959,11 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})
}
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subset asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+// assert.Subset(t, [1, 2, 3], [1, 2])
+// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -975,10 +1016,12 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok
return true
}
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubset asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+// assert.NotSubset(t, [1, 3, 4], [1, 2])
+// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1439,7 +1482,7 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd
h.Helper()
}
if math.IsNaN(epsilon) {
- return Fail(t, "epsilon must not be NaN")
+ return Fail(t, "epsilon must not be NaN", msgAndArgs...)
}
actualEpsilon, err := calcRelativeError(expected, actual)
if err != nil {
@@ -1458,19 +1501,26 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m
if h, ok := t.(tHelper); ok {
h.Helper()
}
- if expected == nil || actual == nil ||
- reflect.TypeOf(actual).Kind() != reflect.Slice ||
- reflect.TypeOf(expected).Kind() != reflect.Slice {
+
+ if expected == nil || actual == nil {
return Fail(t, "Parameters must be slice", msgAndArgs...)
}
- actualSlice := reflect.ValueOf(actual)
expectedSlice := reflect.ValueOf(expected)
+ actualSlice := reflect.ValueOf(actual)
- for i := 0; i < actualSlice.Len(); i++ {
- result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon)
- if !result {
- return result
+ if expectedSlice.Type().Kind() != reflect.Slice {
+ return Fail(t, "Expected value must be slice", msgAndArgs...)
+ }
+
+ expectedLen := expectedSlice.Len()
+ if !IsType(t, expected, actual) || !Len(t, actual, expectedLen) {
+ return false
+ }
+
+ for i := 0; i < expectedLen; i++ {
+ if !InEpsilon(t, expectedSlice.Index(i).Interface(), actualSlice.Index(i).Interface(), epsilon, "at index %d", i) {
+ return false
}
}
@@ -1870,23 +1920,18 @@ func (c *CollectT) Errorf(format string, args ...interface{}) {
}
// FailNow panics.
-func (c *CollectT) FailNow() {
+func (*CollectT) FailNow() {
panic("Assertion failed")
}
-// Reset clears the collected errors.
-func (c *CollectT) Reset() {
- c.errors = nil
+// Deprecated: That was a method for internal usage that should not have been published. Now just panics.
+func (*CollectT) Reset() {
+ panic("Reset() is deprecated")
}
-// Copy copies the collected errors to the supplied t.
-func (c *CollectT) Copy(t TestingT) {
- if tt, ok := t.(tHelper); ok {
- tt.Helper()
- }
- for _, err := range c.errors {
- t.Errorf("%v", err)
- }
+// Deprecated: That was a method for internal usage that should not have been published. Now just panics.
+func (*CollectT) Copy(TestingT) {
+ panic("Copy() is deprecated")
}
// EventuallyWithT asserts that given condition will be met in waitFor time,
@@ -1912,8 +1957,8 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time
h.Helper()
}
- collect := new(CollectT)
- ch := make(chan bool, 1)
+ var lastFinishedTickErrs []error
+ ch := make(chan []error, 1)
timer := time.NewTimer(waitFor)
defer timer.Stop()
@@ -1924,19 +1969,25 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time
for tick := ticker.C; ; {
select {
case <-timer.C:
- collect.Copy(t)
+ for _, err := range lastFinishedTickErrs {
+ t.Errorf("%v", err)
+ }
return Fail(t, "Condition never satisfied", msgAndArgs...)
case <-tick:
tick = nil
- collect.Reset()
go func() {
+ collect := new(CollectT)
+ defer func() {
+ ch <- collect.errors
+ }()
condition(collect)
- ch <- len(collect.errors) == 0
}()
- case v := <-ch:
- if v {
+ case errs := <-ch:
+ if len(errs) == 0 {
return true
}
+ // Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached.
+ lastFinishedTickErrs = errs
tick = ticker.C
}
}
diff --git a/backend/vendor/github.com/stretchr/testify/assert/http_assertions.go b/backend/vendor/github.com/stretchr/testify/assert/http_assertions.go
index d8038c28a7..861ed4b7ce 100644
--- a/backend/vendor/github.com/stretchr/testify/assert/http_assertions.go
+++ b/backend/vendor/github.com/stretchr/testify/assert/http_assertions.go
@@ -12,7 +12,7 @@ import (
// an error if building a new request fails.
func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) {
w := httptest.NewRecorder()
- req, err := http.NewRequest(method, url, nil)
+ req, err := http.NewRequest(method, url, http.NoBody)
if err != nil {
return -1, err
}
@@ -32,12 +32,12 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, value
}
code, err := httpCode(handler, method, url, values)
if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
+ Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...)
}
isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent
if !isSuccessCode {
- Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code))
+ Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...)
}
return isSuccessCode
@@ -54,12 +54,12 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, valu
}
code, err := httpCode(handler, method, url, values)
if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
+ Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...)
}
isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect
if !isRedirectCode {
- Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code))
+ Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...)
}
return isRedirectCode
@@ -76,12 +76,12 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values
}
code, err := httpCode(handler, method, url, values)
if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
+ Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...)
}
isErrorCode := code >= http.StatusBadRequest
if !isErrorCode {
- Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code))
+ Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...)
}
return isErrorCode
@@ -98,12 +98,12 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va
}
code, err := httpCode(handler, method, url, values)
if err != nil {
- Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
+ Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...)
}
successful := code == statuscode
if !successful {
- Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code))
+ Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code), msgAndArgs...)
}
return successful
@@ -113,7 +113,10 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va
// empty string if building a new request fails.
func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string {
w := httptest.NewRecorder()
- req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
+ if len(values) > 0 {
+ url += "?" + values.Encode()
+ }
+ req, err := http.NewRequest(method, url, http.NoBody)
if err != nil {
return ""
}
@@ -135,7 +138,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string,
contains := strings.Contains(body, fmt.Sprint(str))
if !contains {
- Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
+ Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body), msgAndArgs...)
}
return contains
@@ -155,7 +158,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url strin
contains := strings.Contains(body, fmt.Sprint(str))
if contains {
- Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
+ Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body), msgAndArgs...)
}
return !contains
diff --git a/backend/vendor/github.com/stretchr/testify/require/require.go b/backend/vendor/github.com/stretchr/testify/require/require.go
index 63f8521476..506a82f807 100644
--- a/backend/vendor/github.com/stretchr/testify/require/require.go
+++ b/backend/vendor/github.com/stretchr/testify/require/require.go
@@ -1,7 +1,4 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
+// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package require
@@ -235,7 +232,7 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
t.FailNow()
}
-// EqualValues asserts that two objects are equal or convertable to the same types
+// EqualValues asserts that two objects are equal or convertible to the same types
// and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
@@ -249,7 +246,7 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg
t.FailNow()
}
-// EqualValuesf asserts that two objects are equal or convertable to the same types
+// EqualValuesf asserts that two objects are equal or convertible to the same types
// and equal.
//
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
@@ -1546,6 +1543,32 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf
t.FailNow()
}
+// NotImplements asserts that an object does not implement the specified interface.
+//
+// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
+func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotImplements(t, interfaceObject, object, msgAndArgs...) {
+ return
+ }
+ t.FailNow()
+}
+
+// NotImplementsf asserts that an object does not implement the specified interface.
+//
+// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotImplementsf(t, interfaceObject, object, msg, args...) {
+ return
+ }
+ t.FailNow()
+}
+
// NotNil asserts that the specified object is not nil.
//
// assert.NotNil(t, err)
@@ -1658,10 +1681,12 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string,
t.FailNow()
}
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubset asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+// assert.NotSubset(t, [1, 3, 4], [1, 2])
+// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1672,10 +1697,12 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i
t.FailNow()
}
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubsetf asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
+// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1880,10 +1907,11 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg
t.FailNow()
}
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subset asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+// assert.Subset(t, [1, 2, 3], [1, 2])
+// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1894,10 +1922,11 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte
t.FailNow()
}
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subsetf asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
+// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
diff --git a/backend/vendor/github.com/stretchr/testify/require/require_forward.go b/backend/vendor/github.com/stretchr/testify/require/require_forward.go
index 3b5b09330a..eee8310a5f 100644
--- a/backend/vendor/github.com/stretchr/testify/require/require_forward.go
+++ b/backend/vendor/github.com/stretchr/testify/require/require_forward.go
@@ -1,7 +1,4 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
- */
+// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package require
@@ -190,7 +187,7 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
EqualExportedValuesf(a.t, expected, actual, msg, args...)
}
-// EqualValues asserts that two objects are equal or convertable to the same types
+// EqualValues asserts that two objects are equal or convertible to the same types
// and equal.
//
// a.EqualValues(uint32(123), int32(123))
@@ -201,7 +198,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
EqualValues(a.t, expected, actual, msgAndArgs...)
}
-// EqualValuesf asserts that two objects are equal or convertable to the same types
+// EqualValuesf asserts that two objects are equal or convertible to the same types
// and equal.
//
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
@@ -1222,6 +1219,26 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in
NotErrorIsf(a.t, err, target, msg, args...)
}
+// NotImplements asserts that an object does not implement the specified interface.
+//
+// a.NotImplements((*MyInterface)(nil), new(MyObject))
+func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotImplements(a.t, interfaceObject, object, msgAndArgs...)
+}
+
+// NotImplementsf asserts that an object does not implement the specified interface.
+//
+// a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotImplementsf(a.t, interfaceObject, object, msg, args...)
+}
+
// NotNil asserts that the specified object is not nil.
//
// a.NotNil(err)
@@ -1310,10 +1327,12 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri
NotSamef(a.t, expected, actual, msg, args...)
}
-// NotSubset asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubset asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
+// a.NotSubset([1, 3, 4], [1, 2])
+// a.NotSubset({"x": 1, "y": 2}, {"z": 3})
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1321,10 +1340,12 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs
NotSubset(a.t, list, subset, msgAndArgs...)
}
-// NotSubsetf asserts that the specified list(array, slice...) contains not all
-// elements given in the specified subset(array, slice...).
+// NotSubsetf asserts that the specified list(array, slice...) or map does NOT
+// contain all elements given in the specified subset list(array, slice...) or
+// map.
//
-// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
+// a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted")
+// a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1484,10 +1505,11 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string,
Samef(a.t, expected, actual, msg, args...)
}
-// Subset asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subset asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
+// a.Subset([1, 2, 3], [1, 2])
+// a.Subset({"x": 1, "y": 2}, {"x": 1})
func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1495,10 +1517,11 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...
Subset(a.t, list, subset, msgAndArgs...)
}
-// Subsetf asserts that the specified list(array, slice...) contains all
-// elements given in the specified subset(array, slice...).
+// Subsetf asserts that the specified list(array, slice...) or map contains all
+// elements given in the specified subset list(array, slice...) or map.
//
-// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
+// a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted")
+// a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
diff --git a/backend/vendor/go.etcd.io/bbolt/bucket.go b/backend/vendor/go.etcd.io/bbolt/bucket.go
index 054467af30..f3533d3446 100644
--- a/backend/vendor/go.etcd.io/bbolt/bucket.go
+++ b/backend/vendor/go.etcd.io/bbolt/bucket.go
@@ -162,12 +162,17 @@ func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) {
return nil, ErrBucketNameRequired
}
+ // Insert into node.
+ // Tip: Use a new variable `newKey` instead of reusing the existing `key` to prevent
+ // it from being marked as leaking, and accordingly cannot be allocated on stack.
+ newKey := cloneBytes(key)
+
// Move cursor to correct position.
c := b.Cursor()
- k, _, flags := c.seek(key)
+ k, _, flags := c.seek(newKey)
// Return an error if there is an existing key.
- if bytes.Equal(key, k) {
+ if bytes.Equal(newKey, k) {
if (flags & bucketLeafFlag) != 0 {
return nil, ErrBucketExists
}
@@ -182,16 +187,14 @@ func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) {
}
var value = bucket.write()
- // Insert into node.
- key = cloneBytes(key)
- c.node().put(key, key, value, 0, bucketLeafFlag)
+ c.node().put(newKey, newKey, value, 0, bucketLeafFlag)
// Since subbuckets are not allowed on inline buckets, we need to
// dereference the inline page, if it exists. This will cause the bucket
// to be treated as a regular, non-inline bucket for the rest of the tx.
b.page = nil
- return b.Bucket(key), nil
+ return b.Bucket(newKey), nil
}
// CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it.
@@ -288,18 +291,23 @@ func (b *Bucket) Put(key []byte, value []byte) error {
return ErrValueTooLarge
}
+ // Insert into node.
+ // Tip: Use a new variable `newKey` instead of reusing the existing `key` to prevent
+ // it from being marked as leaking, and accordingly cannot be allocated on stack.
+ newKey := cloneBytes(key)
+
// Move cursor to correct position.
c := b.Cursor()
- k, _, flags := c.seek(key)
+ k, _, flags := c.seek(newKey)
// Return an error if there is an existing key with a bucket value.
- if bytes.Equal(key, k) && (flags&bucketLeafFlag) != 0 {
+ if bytes.Equal(newKey, k) && (flags&bucketLeafFlag) != 0 {
return ErrIncompatibleValue
}
- // Insert into node.
- key = cloneBytes(key)
- c.node().put(key, key, value, 0, 0)
+ // gofail: var beforeBucketPut struct{}
+
+ c.node().put(newKey, newKey, value, 0, 0)
return nil
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go
index 6ca8d9ad6c..652aa48b85 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go
@@ -15,16 +15,15 @@ import (
// ArrayCodec is the Codec used for bsoncore.Array values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// ArrayCodec registered.
+// Deprecated: ArrayCodec will not be directly accessible in Go Driver 2.0.
type ArrayCodec struct{}
var defaultArrayCodec = NewArrayCodec()
// NewArrayCodec returns an ArrayCodec.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// ArrayCodec registered.
+// Deprecated: NewArrayCodec will not be available in Go Driver 2.0. See
+// [ArrayCodec] for more details.
func NewArrayCodec() *ArrayCodec {
return &ArrayCodec{}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go
index dde3e76815..0134b5a94b 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go
@@ -17,13 +17,28 @@ import (
// ByteSliceCodec is the Codec used for []byte values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// ByteSliceCodec registered.
+// Deprecated: ByteSliceCodec will not be directly configurable in Go Driver
+// 2.0. To configure the byte slice encode and decode behavior, use the
+// configuration methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the byte slice
+// encode and decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to encode nil byte slices as empty
+// BSON binary values, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// NilByteSliceAsEmpty: true,
+// })
+//
+// See the deprecation notice for each field in ByteSliceCodec for the
+// corresponding settings.
type ByteSliceCodec struct {
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go byte slices as empty BSON binary values
// instead of BSON null.
//
- // Deprecated: Use bson.Encoder.NilByteSliceAsEmpty instead.
+ // Deprecated: Use bson.Encoder.NilByteSliceAsEmpty or options.BSONOptions.NilByteSliceAsEmpty
+ // instead.
EncodeNilAsEmpty bool
}
@@ -38,8 +53,8 @@ var (
// NewByteSliceCodec returns a ByteSliceCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// ByteSliceCodec registered.
+// Deprecated: NewByteSliceCodec will not be available in Go Driver 2.0. See
+// [ByteSliceCodec] for more details.
func NewByteSliceCodec(opts ...*bsonoptions.ByteSliceCodecOptions) *ByteSliceCodec {
byteSliceOpt := bsonoptions.MergeByteSliceCodecOptions(opts...)
codec := ByteSliceCodec{}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
index 2ce119731b..7e08aab35e 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
@@ -41,7 +41,7 @@ func newDefaultStructCodec() *StructCodec {
if err != nil {
// This function is called from the codec registration path, so errors can't be propagated. If there's an error
// constructing the StructCodec, we panic to avoid losing it.
- panic(fmt.Errorf("error creating default StructCodec: %v", err))
+ panic(fmt.Errorf("error creating default StructCodec: %w", err))
}
return codec
}
@@ -178,7 +178,7 @@ func (dvd DefaultValueDecoders) DDecodeValue(dc DecodeContext, vr bsonrw.ValueRe
for {
key, elemVr, err := dr.ReadElement()
- if err == bsonrw.ErrEOD {
+ if errors.Is(err, bsonrw.ErrEOD) {
break
} else if err != nil {
return err
@@ -1379,7 +1379,7 @@ func (dvd DefaultValueDecoders) MapDecodeValue(dc DecodeContext, vr bsonrw.Value
keyType := val.Type().Key()
for {
key, vr, err := dr.ReadElement()
- if err == bsonrw.ErrEOD {
+ if errors.Is(err, bsonrw.ErrEOD) {
break
}
if err != nil {
@@ -1675,7 +1675,7 @@ func (dvd DefaultValueDecoders) decodeDefault(dc DecodeContext, vr bsonrw.ValueR
idx := 0
for {
vr, err := ar.ReadValue()
- if err == bsonrw.ErrEOA {
+ if errors.Is(err, bsonrw.ErrEOA) {
break
}
if err != nil {
@@ -1787,7 +1787,7 @@ func (DefaultValueDecoders) decodeElemsFromDocumentReader(dc DecodeContext, dr b
elems := make([]reflect.Value, 0)
for {
key, vr, err := dr.ReadElement()
- if err == bsonrw.ErrEOD {
+ if errors.Is(err, bsonrw.ErrEOD) {
break
}
if err != nil {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
index 4ab14a668c..4751ae995e 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
@@ -343,7 +343,7 @@ func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.Docum
}
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.MapIndex(key))
- if lookupErr != nil && lookupErr != errInvalidValue {
+ if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
return lookupErr
}
@@ -352,7 +352,7 @@ func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.Docum
return err
}
- if lookupErr == errInvalidValue {
+ if errors.Is(lookupErr, errInvalidValue) {
err = vw.WriteNull()
if err != nil {
return err
@@ -418,7 +418,7 @@ func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.Val
for idx := 0; idx < val.Len(); idx++ {
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx))
- if lookupErr != nil && lookupErr != errInvalidValue {
+ if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
return lookupErr
}
@@ -427,7 +427,7 @@ func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.Val
return err
}
- if lookupErr == errInvalidValue {
+ if errors.Is(lookupErr, errInvalidValue) {
err = vw.WriteNull()
if err != nil {
return err
@@ -487,7 +487,7 @@ func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.Val
for idx := 0; idx < val.Len(); idx++ {
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx))
- if lookupErr != nil && lookupErr != errInvalidValue {
+ if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
return lookupErr
}
@@ -496,7 +496,7 @@ func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.Val
return err
}
- if lookupErr == errInvalidValue {
+ if errors.Is(lookupErr, errInvalidValue) {
err = vw.WriteNull()
if err != nil {
return err
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go
index 94f7dcf1eb..098368f071 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go
@@ -17,13 +17,27 @@ import (
// EmptyInterfaceCodec is the Codec used for interface{} values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// EmptyInterfaceCodec registered.
+// Deprecated: EmptyInterfaceCodec will not be directly configurable in Go
+// Driver 2.0. To configure the empty interface encode and decode behavior, use
+// the configuration methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the empty interface
+// encode and decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to unmarshal BSON binary field
+// values as a Go byte slice, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// BinaryAsSlice: true,
+// })
+//
+// See the deprecation notice for each field in EmptyInterfaceCodec for the
+// corresponding settings.
type EmptyInterfaceCodec struct {
// DecodeBinaryAsSlice causes DecodeValue to unmarshal BSON binary field values that are the
// "Generic" or "Old" BSON binary subtype as a Go byte slice instead of a primitive.Binary.
//
- // Deprecated: Use bson.Decoder.BinaryAsSlice instead.
+ // Deprecated: Use bson.Decoder.BinaryAsSlice or options.BSONOptions.BinaryAsSlice instead.
DecodeBinaryAsSlice bool
}
@@ -38,8 +52,8 @@ var (
// NewEmptyInterfaceCodec returns a EmptyInterfaceCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// EmptyInterfaceCodec registered.
+// Deprecated: NewEmptyInterfaceCodec will not be available in Go Driver 2.0. See
+// [EmptyInterfaceCodec] for more details.
func NewEmptyInterfaceCodec(opts ...*bsonoptions.EmptyInterfaceCodecOptions) *EmptyInterfaceCodec {
interfaceOpt := bsonoptions.MergeEmptyInterfaceCodecOptions(opts...)
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go
index 325c1738ab..d7e00ffa8d 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go
@@ -8,6 +8,7 @@ package bsoncodec
import (
"encoding"
+ "errors"
"fmt"
"reflect"
"strconv"
@@ -21,25 +22,40 @@ var defaultMapCodec = NewMapCodec()
// MapCodec is the Codec used for map values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// MapCodec registered.
+// Deprecated: MapCodec will not be directly configurable in Go Driver 2.0. To
+// configure the map encode and decode behavior, use the configuration methods
+// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the map encode and
+// decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to marshal nil Go maps as empty BSON
+// documents, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// NilMapAsEmpty: true,
+// })
+//
+// See the deprecation notice for each field in MapCodec for the corresponding
+// settings.
type MapCodec struct {
// DecodeZerosMap causes DecodeValue to delete any existing values from Go maps in the destination
// value passed to Decode before unmarshaling BSON documents into them.
//
- // Deprecated: Use bson.Decoder.ZeroMaps instead.
+ // Deprecated: Use bson.Decoder.ZeroMaps or options.BSONOptions.ZeroMaps instead.
DecodeZerosMap bool
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go maps as empty BSON documents instead of
// BSON null.
//
- // Deprecated: Use bson.Encoder.NilMapAsEmpty instead.
+ // Deprecated: Use bson.Encoder.NilMapAsEmpty or options.BSONOptions.NilMapAsEmpty instead.
EncodeNilAsEmpty bool
// EncodeKeysWithStringer causes the Encoder to convert Go map keys to BSON document field name
// strings using fmt.Sprintf() instead of the default string conversion logic.
//
- // Deprecated: Use bson.Encoder.StringifyMapKeysWithFmt instead.
+ // Deprecated: Use bson.Encoder.StringifyMapKeysWithFmt or
+ // options.BSONOptions.StringifyMapKeysWithFmt instead.
EncodeKeysWithStringer bool
}
@@ -61,8 +77,8 @@ type KeyUnmarshaler interface {
// NewMapCodec returns a MapCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// MapCodec registered.
+// Deprecated: NewMapCodec will not be available in Go Driver 2.0. See
+// [MapCodec] for more details.
func NewMapCodec(opts ...*bsonoptions.MapCodecOptions) *MapCodec {
mapOpt := bsonoptions.MergeMapCodecOptions(opts...)
@@ -128,7 +144,7 @@ func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, v
}
currEncoder, currVal, lookupErr := defaultValueEncoders.lookupElementEncoder(ec, encoder, val.MapIndex(key))
- if lookupErr != nil && lookupErr != errInvalidValue {
+ if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
return lookupErr
}
@@ -137,7 +153,7 @@ func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, v
return err
}
- if lookupErr == errInvalidValue {
+ if errors.Is(lookupErr, errInvalidValue) {
err = vw.WriteNull()
if err != nil {
return err
@@ -200,7 +216,7 @@ func (mc *MapCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val ref
for {
key, vr, err := dr.ReadElement()
- if err == bsonrw.ErrEOD {
+ if errors.Is(err, bsonrw.ErrEOD) {
break
}
if err != nil {
@@ -313,7 +329,7 @@ func (mc *MapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value,
if mc.EncodeKeysWithStringer {
parsed, err := strconv.ParseFloat(key, 64)
if err != nil {
- return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %v", keyType.Kind(), err)
+ return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %w", keyType.Kind(), err)
}
keyVal = reflect.ValueOf(parsed)
break
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
index e5923230b0..ddfa4a33e1 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
@@ -18,8 +18,16 @@ var _ ValueDecoder = &PointerCodec{}
// PointerCodec is the Codec used for pointers.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// PointerCodec registered.
+// Deprecated: PointerCodec will not be directly accessible in Go Driver 2.0. To
+// override the default pointer encode and decode behavior, create a new registry
+// with [go.mongodb.org/mongo-driver/bson.NewRegistry] and register a new
+// encoder and decoder for pointers.
+//
+// For example,
+//
+// reg := bson.NewRegistry()
+// reg.RegisterKindEncoder(reflect.Ptr, myPointerEncoder)
+// reg.RegisterKindDecoder(reflect.Ptr, myPointerDecoder)
type PointerCodec struct {
ecache typeEncoderCache
dcache typeDecoderCache
@@ -27,8 +35,8 @@ type PointerCodec struct {
// NewPointerCodec returns a PointerCodec that has been initialized.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// PointerCodec registered.
+// Deprecated: NewPointerCodec will not be available in Go Driver 2.0. See
+// [PointerCodec] for more details.
func NewPointerCodec() *PointerCodec {
return &PointerCodec{}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go
index a43daf005f..14c9fd2564 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go
@@ -7,6 +7,7 @@
package bsoncodec
import (
+ "errors"
"fmt"
"reflect"
@@ -20,8 +21,22 @@ var defaultSliceCodec = NewSliceCodec()
// SliceCodec is the Codec used for slice values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// SliceCodec registered.
+// Deprecated: SliceCodec will not be directly configurable in Go Driver 2.0. To
+// configure the slice encode and decode behavior, use the configuration methods
+// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the slice encode and
+// decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to marshal nil Go slices as empty
+// BSON arrays, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// NilSliceAsEmpty: true,
+// })
+//
+// See the deprecation notice for each field in SliceCodec for the corresponding
+// settings.
type SliceCodec struct {
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go slices as empty BSON arrays instead of
// BSON null.
@@ -32,8 +47,8 @@ type SliceCodec struct {
// NewSliceCodec returns a MapCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// SliceCodec registered.
+// Deprecated: NewSliceCodec will not be available in Go Driver 2.0. See
+// [SliceCodec] for more details.
func NewSliceCodec(opts ...*bsonoptions.SliceCodecOptions) *SliceCodec {
sliceOpt := bsonoptions.MergeSliceCodecOptions(opts...)
@@ -93,7 +108,7 @@ func (sc SliceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val re
for idx := 0; idx < val.Len(); idx++ {
currEncoder, currVal, lookupErr := defaultValueEncoders.lookupElementEncoder(ec, encoder, val.Index(idx))
- if lookupErr != nil && lookupErr != errInvalidValue {
+ if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
return lookupErr
}
@@ -102,7 +117,7 @@ func (sc SliceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val re
return err
}
- if lookupErr == errInvalidValue {
+ if errors.Is(lookupErr, errInvalidValue) {
err = vw.WriteNull()
if err != nil {
return err
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go
index ff931b7253..a8f885a854 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go
@@ -17,8 +17,16 @@ import (
// StringCodec is the Codec used for string values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// StringCodec registered.
+// Deprecated: StringCodec will not be directly accessible in Go Driver 2.0. To
+// override the default string encode and decode behavior, create a new registry
+// with [go.mongodb.org/mongo-driver/bson.NewRegistry] and register a new
+// encoder and decoder for strings.
+//
+// For example,
+//
+// reg := bson.NewRegistry()
+// reg.RegisterKindEncoder(reflect.String, myStringEncoder)
+// reg.RegisterKindDecoder(reflect.String, myStringDecoder)
type StringCodec struct {
// DecodeObjectIDAsHex specifies if object IDs should be decoded as their hex representation.
// If false, a string made from the raw object ID bytes will be used. Defaults to true.
@@ -38,8 +46,8 @@ var (
// NewStringCodec returns a StringCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// StringCodec registered.
+// Deprecated: NewStringCodec will not be available in Go Driver 2.0. See
+// [StringCodec] for more details.
func NewStringCodec(opts ...*bsonoptions.StringCodecOptions) *StringCodec {
stringOpt := bsonoptions.MergeStringCodecOptions(opts...)
return &StringCodec{*stringOpt.DecodeObjectIDAsHex}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
index 4cde0a4d6b..f8d9690c13 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
@@ -60,8 +60,22 @@ type Zeroer interface {
// StructCodec is the Codec used for struct values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// StructCodec registered.
+// Deprecated: StructCodec will not be directly configurable in Go Driver 2.0.
+// To configure the struct encode and decode behavior, use the configuration
+// methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the struct encode
+// and decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to omit zero-value structs when
+// using the "omitempty" struct tag, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// OmitZeroStruct: true,
+// })
+//
+// See the deprecation notice for each field in StructCodec for the corresponding
+// settings.
type StructCodec struct {
cache sync.Map // map[reflect.Type]*structDescription
parser StructTagParser
@@ -69,7 +83,7 @@ type StructCodec struct {
// DecodeZeroStruct causes DecodeValue to delete any existing values from Go structs in the
// destination value passed to Decode before unmarshaling BSON documents into them.
//
- // Deprecated: Use bson.Decoder.ZeroStructs instead.
+ // Deprecated: Use bson.Decoder.ZeroStructs or options.BSONOptions.ZeroStructs instead.
DecodeZeroStruct bool
// DecodeDeepZeroInline causes DecodeValue to delete any existing values from Go structs in the
@@ -82,7 +96,7 @@ type StructCodec struct {
// MyStruct{}) as empty and omit it from the marshaled BSON when the "omitempty" struct tag
// option is set.
//
- // Deprecated: Use bson.Encoder.OmitZeroStruct instead.
+ // Deprecated: Use bson.Encoder.OmitZeroStruct or options.BSONOptions.OmitZeroStruct instead.
EncodeOmitDefaultStruct bool
// AllowUnexportedFields allows encoding and decoding values from un-exported struct fields.
@@ -95,7 +109,8 @@ type StructCodec struct {
// a duplicate field in the marshaled BSON when the "inline" struct tag option is set. The
// default value is true.
//
- // Deprecated: Use bson.Encoder.ErrorOnInlineDuplicates instead.
+ // Deprecated: Use bson.Encoder.ErrorOnInlineDuplicates or
+ // options.BSONOptions.ErrorOnInlineDuplicates instead.
OverwriteDuplicatedInlinedFields bool
}
@@ -104,8 +119,8 @@ var _ ValueDecoder = &StructCodec{}
// NewStructCodec returns a StructCodec that uses p for struct tag parsing.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// StructCodec registered.
+// Deprecated: NewStructCodec will not be available in Go Driver 2.0. See
+// [StructCodec] for more details.
func NewStructCodec(p StructTagParser, opts ...*bsonoptions.StructCodecOptions) (*StructCodec, error) {
if p == nil {
return nil, errors.New("a StructTagParser must be provided to NewStructCodec")
@@ -164,11 +179,11 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
desc.encoder, rv, err = defaultValueEncoders.lookupElementEncoder(ec, desc.encoder, rv)
- if err != nil && err != errInvalidValue {
+ if err != nil && !errors.Is(err, errInvalidValue) {
return err
}
- if err == errInvalidValue {
+ if errors.Is(err, errInvalidValue) {
if desc.omitEmpty {
continue
}
@@ -189,17 +204,17 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
encoder := desc.encoder
- var zero bool
+ var empty bool
if cz, ok := encoder.(CodecZeroer); ok {
- zero = cz.IsTypeZero(rv.Interface())
+ empty = cz.IsTypeZero(rv.Interface())
} else if rv.Kind() == reflect.Interface {
- // isZero will not treat an interface rv as an interface, so we need to check for the
- // zero interface separately.
- zero = rv.IsNil()
+ // isEmpty will not treat an interface rv as an interface, so we need to check for the
+ // nil interface separately.
+ empty = rv.IsNil()
} else {
- zero = isZero(rv, sc.EncodeOmitDefaultStruct || ec.omitZeroStruct)
+ empty = isEmpty(rv, sc.EncodeOmitDefaultStruct || ec.omitZeroStruct)
}
- if desc.omitEmpty && zero {
+ if desc.omitEmpty && empty {
continue
}
@@ -239,8 +254,8 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
}
func newDecodeError(key string, original error) error {
- de, ok := original.(*DecodeError)
- if !ok {
+ var de *DecodeError
+ if !errors.As(original, &de) {
return &DecodeError{
keys: []string{key},
wrapped: original,
@@ -308,7 +323,7 @@ func (sc *StructCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val
for {
name, vr, err := dr.ReadElement()
- if err == bsonrw.ErrEOD {
+ if errors.Is(err, bsonrw.ErrEOD) {
break
}
if err != nil {
@@ -391,12 +406,15 @@ func (sc *StructCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val
return nil
}
-func isZero(v reflect.Value, omitZeroStruct bool) bool {
+func isEmpty(v reflect.Value, omitZeroStruct bool) bool {
kind := v.Kind()
if (kind != reflect.Ptr || !v.IsNil()) && v.Type().Implements(tZeroer) {
return v.Interface().(Zeroer).IsZero()
}
- if kind == reflect.Struct {
+ switch kind {
+ case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
+ return v.Len() == 0
+ case reflect.Struct:
if !omitZeroStruct {
return false
}
@@ -410,7 +428,7 @@ func isZero(v reflect.Value, omitZeroStruct bool) bool {
if ff.PkgPath != "" && !ff.Anonymous {
continue // Private field
}
- if !isZero(v.Field(i), omitZeroStruct) {
+ if !isEmpty(v.Field(i), omitZeroStruct) {
return false
}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go
index 7b005a9958..22fb762c41 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go
@@ -23,12 +23,26 @@ const (
// TimeCodec is the Codec used for time.Time values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// TimeCodec registered.
+// Deprecated: TimeCodec will not be directly configurable in Go Driver 2.0.
+// To configure the time.Time encode and decode behavior, use the configuration
+// methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the time.Time encode
+// and decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to ..., use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// UseLocalTimeZone: true,
+// })
+//
+// See the deprecation notice for each field in TimeCodec for the corresponding
+// settings.
type TimeCodec struct {
// UseLocalTimeZone specifies if we should decode into the local time zone. Defaults to false.
//
- // Deprecated: Use bson.Decoder.UseLocalTimeZone instead.
+ // Deprecated: Use bson.Decoder.UseLocalTimeZone or options.BSONOptions.UseLocalTimeZone
+ // instead.
UseLocalTimeZone bool
}
@@ -42,8 +56,8 @@ var (
// NewTimeCodec returns a TimeCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// TimeCodec registered.
+// Deprecated: NewTimeCodec will not be available in Go Driver 2.0. See
+// [TimeCodec] for more details.
func NewTimeCodec(opts ...*bsonoptions.TimeCodecOptions) *TimeCodec {
timeOpt := bsonoptions.MergeTimeCodecOptions(opts...)
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go
index 7eb1069050..8525472769 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go
@@ -18,13 +18,27 @@ import (
// UIntCodec is the Codec used for uint values.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// UIntCodec registered.
+// Deprecated: UIntCodec will not be directly configurable in Go Driver 2.0. To
+// configure the uint encode and decode behavior, use the configuration methods
+// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
+// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the uint encode and
+// decode behavior for a mongo.Client, use
+// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
+//
+// For example, to configure a mongo.Client to marshal Go uint values as the
+// minimum BSON int size that can represent the value, use:
+//
+// opt := options.Client().SetBSONOptions(&options.BSONOptions{
+// IntMinSize: true,
+// })
+//
+// See the deprecation notice for each field in UIntCodec for the corresponding
+// settings.
type UIntCodec struct {
// EncodeToMinSize causes EncodeValue to marshal Go uint values (excluding uint64) as the
// minimum BSON int size (either 32-bit or 64-bit) that can represent the integer value.
//
- // Deprecated: Use bson.Encoder.IntMinSize instead.
+ // Deprecated: Use bson.Encoder.IntMinSize or options.BSONOptions.IntMinSize instead.
EncodeToMinSize bool
}
@@ -38,8 +52,8 @@ var (
// NewUIntCodec returns a UIntCodec with options opts.
//
-// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
-// UIntCodec registered.
+// Deprecated: NewUIntCodec will not be available in Go Driver 2.0. See
+// [UIntCodec] for more details.
func NewUIntCodec(opts ...*bsonoptions.UIntCodecOptions) *UIntCodec {
uintOpt := bsonoptions.MergeUIntCodecOptions(opts...)
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go
index 4d279b7fee..1e25570b85 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go
@@ -7,6 +7,7 @@
package bsonrw
import (
+ "errors"
"fmt"
"io"
@@ -442,7 +443,7 @@ func (c Copier) copyArray(dst ValueWriter, src ValueReader) error {
for {
vr, err := ar.ReadValue()
- if err == ErrEOA {
+ if errors.Is(err, ErrEOA) {
break
}
if err != nil {
@@ -466,7 +467,7 @@ func (c Copier) copyArray(dst ValueWriter, src ValueReader) error {
func (c Copier) copyDocumentCore(dw DocumentWriter, dr DocumentReader) error {
for {
key, vr, err := dr.ReadElement()
- if err == ErrEOD {
+ if errors.Is(err, ErrEOD) {
break
}
if err != nil {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go
index 54c76bf746..bb52a0ec3d 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go
@@ -313,7 +313,7 @@ func (ejp *extJSONParser) readValue(t bsontype.Type) (*extJSONValue, error) {
// convert hex to bytes
bytes, err := hex.DecodeString(uuidNoHyphens)
if err != nil {
- return nil, fmt.Errorf("$uuid value does not follow RFC 4122 format regarding hex bytes: %v", err)
+ return nil, fmt.Errorf("$uuid value does not follow RFC 4122 format regarding hex bytes: %w", err)
}
ejp.advanceState()
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
index 2aca37a91f..59ddfc4485 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
@@ -7,6 +7,7 @@
package bsonrw
import (
+ "errors"
"fmt"
"io"
"sync"
@@ -613,7 +614,7 @@ func (ejvr *extJSONValueReader) ReadElement() (string, ValueReader, error) {
name, t, err := ejvr.p.readKey()
if err != nil {
- if err == ErrEOD {
+ if errors.Is(err, ErrEOD) {
if ejvr.stack[ejvr.frame].mode == mCodeWithScope {
_, err := ejvr.p.peekType()
if err != nil {
@@ -640,7 +641,7 @@ func (ejvr *extJSONValueReader) ReadValue() (ValueReader, error) {
t, err := ejvr.p.peekType()
if err != nil {
- if err == ErrEOA {
+ if errors.Is(err, ErrEOA) {
ejvr.pop()
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go
index cd4843a3a4..43f3e4f383 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go
@@ -58,7 +58,7 @@ func (js *jsonScanner) nextToken() (*jsonToken, error) {
c, err = js.readNextByte()
}
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return &jsonToken{t: jttEOF}, nil
} else if err != nil {
return nil, err
@@ -198,7 +198,7 @@ func (js *jsonScanner) scanString() (*jsonToken, error) {
for {
c, err = js.readNextByte()
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, errors.New("end of input in JSON string")
}
return nil, err
@@ -209,7 +209,7 @@ func (js *jsonScanner) scanString() (*jsonToken, error) {
case '\\':
c, err = js.readNextByte()
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, errors.New("end of input in JSON string")
}
return nil, err
@@ -248,7 +248,7 @@ func (js *jsonScanner) scanString() (*jsonToken, error) {
if utf16.IsSurrogate(rn) {
c, err = js.readNextByte()
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, errors.New("end of input in JSON string")
}
return nil, err
@@ -264,7 +264,7 @@ func (js *jsonScanner) scanString() (*jsonToken, error) {
c, err = js.readNextByte()
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, errors.New("end of input in JSON string")
}
return nil, err
@@ -325,17 +325,17 @@ func (js *jsonScanner) scanLiteral(first byte) (*jsonToken, error) {
c5, err := js.readNextByte()
- if bytes.Equal([]byte("true"), lit) && (isValueTerminator(c5) || err == io.EOF) {
+ if bytes.Equal([]byte("true"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)) {
js.pos = int(math.Max(0, float64(js.pos-1)))
return &jsonToken{t: jttBool, v: true, p: p}, nil
- } else if bytes.Equal([]byte("null"), lit) && (isValueTerminator(c5) || err == io.EOF) {
+ } else if bytes.Equal([]byte("null"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)) {
js.pos = int(math.Max(0, float64(js.pos-1)))
return &jsonToken{t: jttNull, v: nil, p: p}, nil
} else if bytes.Equal([]byte("fals"), lit) {
if c5 == 'e' {
c5, err = js.readNextByte()
- if isValueTerminator(c5) || err == io.EOF {
+ if isValueTerminator(c5) || errors.Is(err, io.EOF) {
js.pos = int(math.Max(0, float64(js.pos-1)))
return &jsonToken{t: jttBool, v: false, p: p}, nil
}
@@ -384,7 +384,7 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
for {
c, err = js.readNextByte()
- if err != nil && err != io.EOF {
+ if err != nil && !errors.Is(err, io.EOF) {
return nil, err
}
@@ -413,7 +413,7 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
case '}', ']', ',':
s = nssDone
default:
- if isWhiteSpace(c) || err == io.EOF {
+ if isWhiteSpace(c) || errors.Is(err, io.EOF) {
s = nssDone
} else {
s = nssInvalid
@@ -430,7 +430,7 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
case '}', ']', ',':
s = nssDone
default:
- if isWhiteSpace(c) || err == io.EOF {
+ if isWhiteSpace(c) || errors.Is(err, io.EOF) {
s = nssDone
} else if isDigit(c) {
s = nssSawIntegerDigits
@@ -455,7 +455,7 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
case '}', ']', ',':
s = nssDone
default:
- if isWhiteSpace(c) || err == io.EOF {
+ if isWhiteSpace(c) || errors.Is(err, io.EOF) {
s = nssDone
} else if isDigit(c) {
s = nssSawFractionDigits
@@ -490,7 +490,7 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
case '}', ']', ',':
s = nssDone
default:
- if isWhiteSpace(c) || err == io.EOF {
+ if isWhiteSpace(c) || errors.Is(err, io.EOF) {
s = nssDone
} else if isDigit(c) {
s = nssSawExponentDigits
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/doc.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/doc.go
index 048b5eb998..af6098475e 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/doc.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/doc.go
@@ -6,9 +6,9 @@
// Package bson is a library for reading, writing, and manipulating BSON. BSON is a binary serialization format used to
// store documents and make remote procedure calls in MongoDB. The BSON specification is located at https://bsonspec.org.
-// The BSON library handles marshalling and unmarshalling of values through a configurable codec system. For a description
-// of the codec system and examples of registering custom codecs, see the bsoncodec package. For additional information and
-// usage examples, check out the [Work with BSON] page in the Go Driver docs site.
+// The BSON library handles marshaling and unmarshaling of values through a configurable codec system. For a description
+// of the codec system and examples of registering custom codecs, see the bsoncodec package. For additional information
+// and usage examples, check out the [Work with BSON] page in the Go Driver docs site.
//
// # Raw BSON
//
@@ -38,7 +38,7 @@
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
//
-// When decoding BSON to a D or M, the following type mappings apply when unmarshalling:
+// When decoding BSON to a D or M, the following type mappings apply when unmarshaling:
//
// 1. BSON int32 unmarshals to an int32.
// 2. BSON int64 unmarshals to an int64.
@@ -62,83 +62,78 @@
// 20. BSON DBPointer unmarshals to a primitive.DBPointer.
// 21. BSON symbol unmarshals to a primitive.Symbol.
//
-// The above mappings also apply when marshalling a D or M to BSON. Some other useful marshalling mappings are:
+// The above mappings also apply when marshaling a D or M to BSON. Some other useful marshaling mappings are:
//
// 1. time.Time marshals to a BSON datetime.
// 2. int8, int16, and int32 marshal to a BSON int32.
// 3. int marshals to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32, inclusive, and a BSON int64
// otherwise.
-// 4. int64 marshals to BSON int64.
+// 4. int64 marshals to BSON int64 (unless [Encoder.IntMinSize] is set).
// 5. uint8 and uint16 marshal to a BSON int32.
-// 6. uint, uint32, and uint64 marshal to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32,
-// inclusive, and BSON int64 otherwise.
-// 7. BSON null and undefined values will unmarshal into the zero value of a field (e.g. unmarshalling a BSON null or
+// 6. uint, uint32, and uint64 marshal to a BSON int64 (unless [Encoder.IntMinSize] is set).
+// 7. BSON null and undefined values will unmarshal into the zero value of a field (e.g. unmarshaling a BSON null or
// undefined value into a string will yield the empty string.).
//
// # Structs
//
-// Structs can be marshalled/unmarshalled to/from BSON or Extended JSON. When transforming structs to/from BSON or Extended
+// Structs can be marshaled/unmarshaled to/from BSON or Extended JSON. When transforming structs to/from BSON or Extended
// JSON, the following rules apply:
//
-// 1. Only exported fields in structs will be marshalled or unmarshalled.
+// 1. Only exported fields in structs will be marshaled or unmarshaled.
//
-// 2. When marshalling a struct, each field will be lowercased to generate the key for the corresponding BSON element.
+// 2. When marshaling a struct, each field will be lowercased to generate the key for the corresponding BSON element.
// For example, a struct field named "Foo" will generate key "foo". This can be overridden via a struct tag (e.g.
// `bson:"fooField"` to generate key "fooField" instead).
//
-// 3. An embedded struct field is marshalled as a subdocument. The key will be the lowercased name of the field's type.
+// 3. An embedded struct field is marshaled as a subdocument. The key will be the lowercased name of the field's type.
//
-// 4. A pointer field is marshalled as the underlying type if the pointer is non-nil. If the pointer is nil, it is
-// marshalled as a BSON null value.
+// 4. A pointer field is marshaled as the underlying type if the pointer is non-nil. If the pointer is nil, it is
+// marshaled as a BSON null value.
//
-// 5. When unmarshalling, a field of type interface{} will follow the D/M type mappings listed above. BSON documents
-// unmarshalled into an interface{} field will be unmarshalled as a D.
+// 5. When unmarshaling, a field of type interface{} will follow the D/M type mappings listed above. BSON documents
+// unmarshaled into an interface{} field will be unmarshaled as a D.
//
// The encoding of each struct field can be customized by the "bson" struct tag.
//
// This tag behavior is configurable, and different struct tag behavior can be configured by initializing a new
-// bsoncodec.StructCodec with the desired tag parser and registering that StructCodec onto the Registry. By default, JSON tags
-// are not honored, but that can be enabled by creating a StructCodec with JSONFallbackStructTagParser, like below:
+// bsoncodec.StructCodec with the desired tag parser and registering that StructCodec onto the Registry. By default, JSON
+// tags are not honored, but that can be enabled by creating a StructCodec with JSONFallbackStructTagParser, like below:
//
// Example:
//
// structcodec, _ := bsoncodec.NewStructCodec(bsoncodec.JSONFallbackStructTagParser)
//
// The bson tag gives the name of the field, possibly followed by a comma-separated list of options.
-// The name may be empty in order to specify options without overriding the default field name. The following options can be used
-// to configure behavior:
-//
-// 1. omitempty: If the omitempty struct tag is specified on a field, the field will not be marshalled if it is set to
-// the zero value. Fields with language primitive types such as integers, booleans, and strings are considered empty if
-// their value is equal to the zero value for the type (i.e. 0 for integers, false for booleans, and "" for strings).
-// Slices, maps, and arrays are considered empty if they are of length zero. Interfaces and pointers are considered
-// empty if their value is nil. By default, structs are only considered empty if the struct type implements the
-// bsoncodec.Zeroer interface and the IsZero method returns true. Struct fields whose types do not implement Zeroer are
-// never considered empty and will be marshalled as embedded documents.
+// The name may be empty in order to specify options without overriding the default field name. The following options can
+// be used to configure behavior:
+//
+// 1. omitempty: If the omitempty struct tag is specified on a field, the field will be omitted from the marshaling if
+// the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array,
+// slice, map, or string.
// NOTE: It is recommended that this tag be used for all slice and map fields.
//
// 2. minsize: If the minsize struct tag is specified on a field of type int64, uint, uint32, or uint64 and the value of
-// the field can fit in a signed int32, the field will be serialized as a BSON int32 rather than a BSON int64. For other
-// types, this tag is ignored.
+// the field can fit in a signed int32, the field will be serialized as a BSON int32 rather than a BSON int64. For
+// other types, this tag is ignored.
//
-// 3. truncate: If the truncate struct tag is specified on a field with a non-float numeric type, BSON doubles unmarshalled
-// into that field will be truncated at the decimal point. For example, if 3.14 is unmarshalled into a field of type int,
-// it will be unmarshalled as 3. If this tag is not specified, the decoder will throw an error if the value cannot be
-// decoded without losing precision. For float64 or non-numeric types, this tag is ignored.
+// 3. truncate: If the truncate struct tag is specified on a field with a non-float numeric type, BSON doubles
+// unmarshaled into that field will be truncated at the decimal point. For example, if 3.14 is unmarshaled into a
+// field of type int, it will be unmarshaled as 3. If this tag is not specified, the decoder will throw an error if
+// the value cannot be decoded without losing precision. For float64 or non-numeric types, this tag is ignored.
//
// 4. inline: If the inline struct tag is specified for a struct or map field, the field will be "flattened" when
-// marshalling and "un-flattened" when unmarshalling. This means that all of the fields in that struct/map will be
-// pulled up one level and will become top-level fields rather than being fields in a nested document. For example, if a
-// map field named "Map" with value map[string]interface{}{"foo": "bar"} is inlined, the resulting document will be
-// {"foo": "bar"} instead of {"map": {"foo": "bar"}}. There can only be one inlined map field in a struct. If there are
-// duplicated fields in the resulting document when an inlined struct is marshalled, the inlined field will be overwritten.
-// If there are duplicated fields in the resulting document when an inlined map is marshalled, an error will be returned.
-// This tag can be used with fields that are pointers to structs. If an inlined pointer field is nil, it will not be
-// marshalled. For fields that are not maps or structs, this tag is ignored.
-//
-// # Marshalling and Unmarshalling
-//
-// Manually marshalling and unmarshalling can be done with the Marshal and Unmarshal family of functions.
+// marshaling and "un-flattened" when unmarshaling. This means that all of the fields in that struct/map will be
+// pulled up one level and will become top-level fields rather than being fields in a nested document. For example,
+// if a map field named "Map" with value map[string]interface{}{"foo": "bar"} is inlined, the resulting document will
+// be {"foo": "bar"} instead of {"map": {"foo": "bar"}}. There can only be one inlined map field in a struct. If
+// there are duplicated fields in the resulting document when an inlined struct is marshaled, the inlined field will
+// be overwritten. If there are duplicated fields in the resulting document when an inlined map is marshaled, an
+// error will be returned. This tag can be used with fields that are pointers to structs. If an inlined pointer field
+// is nil, it will not be marshaled. For fields that are not maps or structs, this tag is ignored.
+//
+// # Marshaling and Unmarshaling
+//
+// Manually marshaling and unmarshaling can be done with the Marshal and Unmarshal family of functions.
//
// [Work with BSON]: https://www.mongodb.com/docs/drivers/go/current/fundamentals/bson/
package bson
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
index 24ab58fc49..08c39514be 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
@@ -164,9 +164,6 @@ func (d Decimal128) BigInt() (*big.Int, int, error) {
// Would be handled by the logic below, but that's trivial and common.
if high == 0 && low == 0 && exp == 0 {
- if posSign {
- return new(big.Int), 0, nil
- }
return new(big.Int), 0, nil
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go b/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go
index 9bbaffac26..c130e3ff19 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go
@@ -183,7 +183,7 @@ func processUniqueBytes() [5]byte {
var b [5]byte
_, err := io.ReadFull(rand.Reader, b[:])
if err != nil {
- panic(fmt.Errorf("cannot initialize objectid package with crypto.rand.Reader: %v", err))
+ panic(fmt.Errorf("cannot initialize objectid package with crypto.rand.Reader: %w", err))
}
return b
@@ -193,7 +193,7 @@ func readRandomUint32() uint32 {
var b [4]byte
_, err := io.ReadFull(rand.Reader, b[:])
if err != nil {
- panic(fmt.Errorf("cannot initialize objectid package with crypto.rand.Reader: %v", err))
+ panic(fmt.Errorf("cannot initialize objectid package with crypto.rand.Reader: %w", err))
}
return (uint32(b[0]) << 0) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24)
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/event/monitoring.go b/backend/vendor/go.mongodb.org/mongo-driver/event/monitoring.go
index 53d1caf2e3..cc2c7a4e6c 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/event/monitoring.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/event/monitoring.go
@@ -120,8 +120,9 @@ type PoolEvent struct {
Reason string `json:"reason"`
// ServiceID is only set if the Type is PoolCleared and the server is deployed behind a load balancer. This field
// can be used to distinguish between individual servers in a load balanced deployment.
- ServiceID *primitive.ObjectID `json:"serviceId"`
- Error error `json:"error"`
+ ServiceID *primitive.ObjectID `json:"serviceId"`
+ Interruption bool `json:"interruptInUseConnections"`
+ Error error `json:"error"`
}
// PoolMonitor is a function that allows the user to gain access to events occurring in the pool
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/internal/csfle/csfle.go b/backend/vendor/go.mongodb.org/mongo-driver/internal/csfle/csfle.go
index 71e71b4687..20a6d43a0d 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/internal/csfle/csfle.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/internal/csfle/csfle.go
@@ -7,6 +7,7 @@
package csfle
import (
+ "errors"
"fmt"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
@@ -23,7 +24,7 @@ func GetEncryptedStateCollectionName(efBSON bsoncore.Document, dataCollectionNam
fieldName := stateCollection + "Collection"
val, err := efBSON.LookupErr(fieldName)
if err != nil {
- if err != bsoncore.ErrElementNotFound {
+ if !errors.Is(err, bsoncore.ErrElementNotFound) {
return "", err
}
// Return default name.
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/internal/logger/logger.go b/backend/vendor/go.mongodb.org/mongo-driver/internal/logger/logger.go
index 03d42814f4..2250286e4a 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/internal/logger/logger.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/internal/logger/logger.go
@@ -183,7 +183,7 @@ func selectLogSink(sink LogSink) (LogSink, *os.File, error) {
if path != "" {
logFile, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
- return nil, nil, fmt.Errorf("unable to open log file: %v", err)
+ return nil, nil, fmt.Errorf("unable to open log file: %w", err)
}
return NewIOSink(logFile), logFile, nil
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go
index 42d286ea7d..3fdb67b9a2 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go
@@ -8,6 +8,7 @@ package mongo
import (
"context"
+ "errors"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/primitive"
@@ -71,7 +72,7 @@ func (bw *bulkWrite) execute(ctx context.Context) error {
bwErr.WriteErrors = append(bwErr.WriteErrors, batchErr.WriteErrors...)
- commandErrorOccurred := err != nil && err != driver.ErrUnacknowledgedWrite
+ commandErrorOccurred := err != nil && !errors.Is(err, driver.ErrUnacknowledgedWrite)
writeErrorOccurred := len(batchErr.WriteErrors) > 0 || batchErr.WriteConcernError != nil
if !continueOnError && (commandErrorOccurred || writeErrorOccurred) {
if err != nil {
@@ -108,8 +109,8 @@ func (bw *bulkWrite) runBatch(ctx context.Context, batch bulkWriteBatch) (BulkWr
case *InsertOneModel:
res, err := bw.runInsert(ctx, batch)
if err != nil {
- writeErr, ok := err.(driver.WriteCommandError)
- if !ok {
+ var writeErr driver.WriteCommandError
+ if !errors.As(err, &writeErr) {
return BulkWriteResult{}, batchErr, err
}
writeErrors = writeErr.WriteErrors
@@ -120,8 +121,8 @@ func (bw *bulkWrite) runBatch(ctx context.Context, batch bulkWriteBatch) (BulkWr
case *DeleteOneModel, *DeleteManyModel:
res, err := bw.runDelete(ctx, batch)
if err != nil {
- writeErr, ok := err.(driver.WriteCommandError)
- if !ok {
+ var writeErr driver.WriteCommandError
+ if !errors.As(err, &writeErr) {
return BulkWriteResult{}, batchErr, err
}
writeErrors = writeErr.WriteErrors
@@ -132,8 +133,8 @@ func (bw *bulkWrite) runBatch(ctx context.Context, batch bulkWriteBatch) (BulkWr
case *ReplaceOneModel, *UpdateOneModel, *UpdateManyModel:
res, err := bw.runUpdate(ctx, batch)
if err != nil {
- writeErr, ok := err.(driver.WriteCommandError)
- if !ok {
+ var writeErr driver.WriteCommandError
+ if !errors.As(err, &writeErr) {
return BulkWriteResult{}, batchErr, err
}
writeErrors = writeErr.WriteErrors
@@ -170,7 +171,7 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera
if err != nil {
return operation.InsertResult{}, err
}
- doc, _, err = ensureID(doc, primitive.NewObjectID(), bw.collection.bsonOpts, bw.collection.registry)
+ doc, _, err = ensureID(doc, primitive.NilObjectID, bw.collection.bsonOpts, bw.collection.registry)
if err != nil {
return operation.InsertResult{}, err
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/change_stream.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/change_stream.go
index 773cbb0e5d..c4c2fb2590 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/change_stream.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/change_stream.go
@@ -689,8 +689,8 @@ func (cs *ChangeStream) loopNext(ctx context.Context, nonBlocking bool) {
}
func (cs *ChangeStream) isResumableError() bool {
- commandErr, ok := cs.err.(CommandError)
- if !ok || commandErr.HasErrorLabel(networkErrorLabel) {
+ var commandErr CommandError
+ if !errors.As(cs.err, &commandErr) || commandErr.HasErrorLabel(networkErrorLabel) {
// All non-server errors or network errors are resumable.
return true
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/client.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/client.go
index 5929274831..280749c7dd 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/client.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/client.go
@@ -555,7 +555,7 @@ func (c *Client) newMongoCrypt(opts *options.AutoEncryptionOptions) (*mongocrypt
kmsProviders, err := marshal(opts.KmsProviders, c.bsonOpts, c.registry)
if err != nil {
- return nil, fmt.Errorf("error creating KMS providers document: %v", err)
+ return nil, fmt.Errorf("error creating KMS providers document: %w", err)
}
// Set the crypt_shared library override path from the "cryptSharedLibPath" extra option if one
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/client_encryption.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/client_encryption.go
index 01c2ec3193..b51f57b473 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/client_encryption.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/client_encryption.go
@@ -46,7 +46,7 @@ func NewClientEncryption(keyVaultClient *Client, opts ...*options.ClientEncrypti
kmsProviders, err := marshal(ceo.KmsProviders, nil, nil)
if err != nil {
- return nil, fmt.Errorf("error creating KMS providers map: %v", err)
+ return nil, fmt.Errorf("error creating KMS providers map: %w", err)
}
mc, err := mongocrypt.NewMongoCrypt(mcopts.MongoCrypt().
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/collection.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
index fcbfcc77a1..c7b2a8a113 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
@@ -256,7 +256,7 @@ func (coll *Collection) insert(ctx context.Context, documents []interface{},
if err != nil {
return nil, err
}
- bsoncoreDoc, id, err := ensureID(bsoncoreDoc, primitive.NewObjectID(), coll.bsonOpts, coll.registry)
+ bsoncoreDoc, id, err := ensureID(bsoncoreDoc, primitive.NilObjectID, coll.bsonOpts, coll.registry)
if err != nil {
return nil, err
}
@@ -313,8 +313,8 @@ func (coll *Collection) insert(ctx context.Context, documents []interface{},
op = op.Retry(retry)
err = op.Execute(ctx)
- wce, ok := err.(driver.WriteCommandError)
- if !ok {
+ var wce driver.WriteCommandError
+ if !errors.As(err, &wce) {
return result, err
}
@@ -388,8 +388,8 @@ func (coll *Collection) InsertMany(ctx context.Context, documents []interface{},
}
imResult := &InsertManyResult{InsertedIDs: result}
- writeException, ok := err.(WriteException)
- if !ok {
+ var writeException WriteException
+ if !errors.As(err, &writeException) {
return imResult, err
}
@@ -1806,7 +1806,7 @@ func (coll *Collection) Drop(ctx context.Context) error {
func (coll *Collection) dropEncryptedCollection(ctx context.Context, ef interface{}) error {
efBSON, err := marshal(ef, coll.bsonOpts, coll.registry)
if err != nil {
- return fmt.Errorf("error transforming document: %v", err)
+ return fmt.Errorf("error transforming document: %w", err)
}
// Drop the two encryption-related, associated collections: `escCollection` and `ecocCollection`.
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/cursor.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/cursor.go
index d2228ed9c4..c77d1109f4 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/cursor.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/cursor.go
@@ -160,13 +160,13 @@ func (c *Cursor) next(ctx context.Context, nonBlocking bool) bool {
ctx = context.Background()
}
doc, err := c.batch.Next()
- switch err {
- case nil:
+ switch {
+ case err == nil:
// Consume the next document in the current batch.
c.batchLength--
c.Current = bson.Raw(doc)
return true
- case io.EOF: // Need to do a getMore
+ case errors.Is(err, io.EOF): // Need to do a getMore
default:
c.err = err
return false
@@ -204,12 +204,12 @@ func (c *Cursor) next(ctx context.Context, nonBlocking bool) bool {
c.batch = c.bc.Batch()
c.batchLength = c.batch.DocumentCount()
doc, err = c.batch.Next()
- switch err {
- case nil:
+ switch {
+ case err == nil:
c.batchLength--
c.Current = bson.Raw(doc)
return true
- case io.EOF: // Empty batch so we continue
+ case errors.Is(err, io.EOF): // Empty batch so we continue
default:
c.err = err
return false
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/database.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/database.go
index 6760f0d014..c5cda9e5bd 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/database.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/database.go
@@ -566,7 +566,7 @@ func (db *Database) getEncryptedFieldsFromServer(ctx context.Context, collection
}
collSpec := collSpecs[0]
rawValue, err := collSpec.Options.LookupErr("encryptedFields")
- if err == bsoncore.ErrElementNotFound {
+ if errors.Is(err, bsoncore.ErrElementNotFound) {
return nil, nil
} else if err != nil {
return nil, err
@@ -602,7 +602,7 @@ func (db *Database) getEncryptedFieldsFromMap(collectionName string) interface{}
func (db *Database) createCollectionWithEncryptedFields(ctx context.Context, name string, ef interface{}, opts ...*options.CreateCollectionOptions) error {
efBSON, err := marshal(ef, db.bsonOpts, db.registry)
if err != nil {
- return fmt.Errorf("error transforming document: %v", err)
+ return fmt.Errorf("error transforming document: %w", err)
}
// Check the wire version to ensure server is 7.0.0 or newer.
@@ -662,7 +662,7 @@ func (db *Database) createCollectionWithEncryptedFields(ctx context.Context, nam
// Create an index on the __safeContent__ field in the collection @collectionName.
if _, err := db.Collection(name).Indexes().CreateOne(ctx, IndexModel{Keys: bson.D{{"__safeContent__", 1}}}); err != nil {
- return fmt.Errorf("error creating safeContent index: %v", err)
+ return fmt.Errorf("error creating safeContent index: %w", err)
}
return nil
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/description/server_selector.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/description/server_selector.go
index aee1f050cb..176f0fb53a 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/description/server_selector.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/description/server_selector.go
@@ -182,7 +182,17 @@ func (writeServerSelector) SelectServer(t Topology, candidates []Server) ([]Serv
case Single, LoadBalanced:
return candidates, nil
default:
- result := []Server{}
+ // Determine the capacity of the results slice.
+ selected := 0
+ for _, candidate := range candidates {
+ switch candidate.Kind {
+ case Mongos, RSPrimary, Standalone:
+ selected++
+ }
+ }
+
+ // Append candidates to the results slice.
+ result := make([]Server, 0, selected)
for _, candidate := range candidates {
switch candidate.Kind {
case Mongos, RSPrimary, Standalone:
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/errors.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/errors.go
index 72c3bcc243..d92c9ca9bd 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/errors.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/errors.go
@@ -52,7 +52,7 @@ func replaceErrors(err error) error {
return nil
}
- if err == topology.ErrTopologyClosed {
+ if errors.Is(err, topology.ErrTopologyClosed) {
return ErrClientDisconnected
}
if de, ok := err.(driver.Error); ok {
@@ -630,7 +630,7 @@ const (
// WriteConcernError will be returned over WriteErrors if both are present.
func processWriteError(err error) (returnResult, error) {
switch {
- case err == driver.ErrUnacknowledgedWrite:
+ case errors.Is(err, driver.ErrUnacknowledgedWrite):
return rrAll, ErrUnacknowledgedWrite
case err != nil:
switch tt := err.(type) {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/bucket.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/bucket.go
index 61e2cb9e74..b231d1dd77 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/bucket.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/bucket.go
@@ -429,7 +429,7 @@ func (b *Bucket) openDownloadStream(filter interface{}, opts ...*options.FindOpt
// in the File type. After parsing it, use RawValue.Unmarshal to ensure File.ID is set to the appropriate value.
var foundFile File
if err = cursor.Decode(&foundFile); err != nil {
- return nil, fmt.Errorf("error decoding files collection document: %v", err)
+ return nil, fmt.Errorf("error decoding files collection document: %w", err)
}
if foundFile.Length == 0 {
@@ -594,7 +594,7 @@ func (b *Bucket) createIndexes(ctx context.Context) error {
docRes := cloned.FindOne(ctx, bson.D{}, options.FindOne().SetProjection(bson.D{{"_id", 1}}))
_, err = docRes.Raw()
- if err != mongo.ErrNoDocuments {
+ if !errors.Is(err, mongo.ErrNoDocuments) {
// nil, or error that occurred during the FindOne operation
return err
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/download_stream.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/download_stream.go
index 20c8df8a6f..7c75813f54 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/download_stream.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/gridfs/download_stream.go
@@ -160,7 +160,7 @@ func (ds *DownloadStream) Read(p []byte) (int, error) {
// Buffer is empty and can load in data from new chunk.
err = ds.fillBuffer(ctx)
if err != nil {
- if err == errNoMoreChunks {
+ if errors.Is(err, errNoMoreChunks) {
if bytesCopied == 0 {
ds.done = true
return 0, io.EOF
@@ -203,7 +203,7 @@ func (ds *DownloadStream) Skip(skip int64) (int64, error) {
// Buffer is empty and can load in data from new chunk.
err = ds.fillBuffer(ctx)
if err != nil {
- if err == errNoMoreChunks {
+ if errors.Is(err, errNoMoreChunks) {
return skipped, nil
}
return skipped, err
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/mongo.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/mongo.go
index 393c5b7713..ec8e817c73 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/mongo.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/mongo.go
@@ -177,8 +177,11 @@ func marshal(
}
// ensureID inserts the given ObjectID as an element named "_id" at the
-// beginning of the given BSON document if there is not an "_id" already. If
-// there is already an element named "_id", the document is not modified. It
+// beginning of the given BSON document if there is not an "_id" already.
+// If the given ObjectID is primitive.NilObjectID, a new object ID will be
+// generated with time.Now().
+//
+// If there is already an element named "_id", the document is not modified. It
// returns the resulting document and the decoded Go value of the "_id" element.
func ensureID(
doc bsoncore.Document,
@@ -219,6 +222,9 @@ func ensureID(
const extraSpace = 17
doc = make(bsoncore.Document, 0, len(olddoc)+extraSpace)
_, doc = bsoncore.ReserveLength(doc)
+ if oid.IsZero() {
+ oid = primitive.NewObjectID()
+ }
doc = bsoncore.AppendObjectIDElement(doc, "_id", oid)
// Remove and re-write the BSON document length header.
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go b/backend/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go
index 42664be03a..db56745919 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go
@@ -237,7 +237,6 @@ type ClientOptions struct {
ZstdLevel *int
err error
- uri string
cs *connstring.ConnString
// AuthenticateToAnything skips server type checks when deciding if authentication is possible.
@@ -338,7 +337,10 @@ func (c *ClientOptions) validate() error {
// GetURI returns the original URI used to configure the ClientOptions instance. If ApplyURI was not called during
// construction, this returns "".
func (c *ClientOptions) GetURI() string {
- return c.uri
+ if c.cs == nil {
+ return ""
+ }
+ return c.cs.Original
}
// ApplyURI parses the given URI and sets options accordingly. The URI can contain host names, IPv4/IPv6 literals, or
@@ -360,13 +362,12 @@ func (c *ClientOptions) ApplyURI(uri string) *ClientOptions {
return c
}
- c.uri = uri
cs, err := connstring.ParseAndValidate(uri)
if err != nil {
c.err = err
return c
}
- c.cs = &cs
+ c.cs = cs
if cs.AppName != "" {
c.AppName = &cs.AppName
@@ -1134,9 +1135,6 @@ func MergeClientOptions(opts ...*ClientOptions) *ClientOptions {
if opt.err != nil {
c.err = opt.err
}
- if opt.uri != "" {
- c.uri = opt.uri
- }
if opt.cs != nil {
c.cs = opt.cs
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/version/version.go b/backend/vendor/go.mongodb.org/mongo-driver/version/version.go
index 738d44e6aa..13c18479af 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/version/version.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/version/version.go
@@ -8,4 +8,4 @@
package version // import "go.mongodb.org/mongo-driver/version"
// Driver is the current version of the driver.
-var Driver = "v1.13.1"
+var Driver = "v1.14.0"
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/sasl.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/sasl.go
index a7ae3368f0..2a84b53a64 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/sasl.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/sasl.go
@@ -102,7 +102,7 @@ func (sc *saslConversation) Finish(ctx context.Context, cfg *Config, firstRespon
var saslResp saslResponse
err := bson.Unmarshal(firstResponse, &saslResp)
if err != nil {
- fullErr := fmt.Errorf("unmarshal error: %v", err)
+ fullErr := fmt.Errorf("unmarshal error: %w", err)
return newError(fullErr, sc.mechanism)
}
@@ -146,7 +146,7 @@ func (sc *saslConversation) Finish(ctx context.Context, cfg *Config, firstRespon
err = bson.Unmarshal(rdr, &saslResp)
if err != nil {
- fullErr := fmt.Errorf("unmarshal error: %v", err)
+ fullErr := fmt.Errorf("unmarshal error: %w", err)
return newError(fullErr, sc.mechanism)
}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/scram.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/scram.go
index f4f069699c..c1238cd6a9 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/scram.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/scram.go
@@ -14,7 +14,6 @@ package auth
import (
"context"
- "fmt"
"github.com/xdg-go/scram"
"github.com/xdg-go/stringprep"
@@ -53,7 +52,7 @@ func newScramSHA1Authenticator(cred *Cred) (Authenticator, error) {
func newScramSHA256Authenticator(cred *Cred) (Authenticator, error) {
passprep, err := stringprep.SASLprep.Prepare(cred.Password)
if err != nil {
- return nil, newAuthError(fmt.Sprintf("error SASLprepping password '%s'", cred.Password), err)
+ return nil, newAuthError("error SASLprepping password", err)
}
client, err := scram.SHA256.NewClientUnprepped(cred.Username, passprep, "")
if err != nil {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batch_cursor.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batch_cursor.go
index fefcfdb475..23b4a6539d 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batch_cursor.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batch_cursor.go
@@ -79,7 +79,7 @@ type CursorResponse struct {
func NewCursorResponse(info ResponseInfo) (CursorResponse, error) {
response := info.ServerResponse
cur, err := response.LookupErr("cursor")
- if err == bsoncore.ErrElementNotFound {
+ if errors.Is(err, bsoncore.ErrElementNotFound) {
return CursorResponse{}, ErrNoCursor
}
if err != nil {
@@ -142,7 +142,7 @@ func NewCursorResponse(info ResponseInfo) (CursorResponse, error) {
return CursorResponse{}, fmt.Errorf("expected Connection used to establish a cursor to implement PinnedConnection, but got %T", info.Connection)
}
if err := refConn.PinToCursor(); err != nil {
- return CursorResponse{}, fmt.Errorf("error incrementing connection reference count when creating a cursor: %v", err)
+ return CursorResponse{}, fmt.Errorf("error incrementing connection reference count when creating a cursor: %w", err)
}
curresp.Connection = refConn
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/connstring/connstring.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/connstring/connstring.go
index cd43136471..52068b8ea8 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/connstring/connstring.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/connstring/connstring.go
@@ -73,29 +73,28 @@ var random = randutil.NewLockedRand()
// ParseAndValidate parses the provided URI into a ConnString object.
// It check that all values are valid.
-func ParseAndValidate(s string) (ConnString, error) {
- p := parser{dnsResolver: dns.DefaultResolver}
- err := p.parse(s)
+func ParseAndValidate(s string) (*ConnString, error) {
+ connStr, err := Parse(s)
if err != nil {
- return p.ConnString, fmt.Errorf("error parsing uri: %w", err)
+ return nil, err
}
- err = p.ConnString.Validate()
+ err = connStr.Validate()
if err != nil {
- return p.ConnString, fmt.Errorf("error validating uri: %w", err)
+ return nil, fmt.Errorf("error validating uri: %w", err)
}
- return p.ConnString, nil
+ return connStr, nil
}
// Parse parses the provided URI into a ConnString object
// but does not check that all values are valid. Use `ConnString.Validate()`
// to run the validation checks separately.
-func Parse(s string) (ConnString, error) {
+func Parse(s string) (*ConnString, error) {
p := parser{dnsResolver: dns.DefaultResolver}
- err := p.parse(s)
+ connStr, err := p.parse(s)
if err != nil {
- err = fmt.Errorf("error parsing uri: %w", err)
+ return nil, fmt.Errorf("error parsing uri: %w", err)
}
- return p.ConnString, err
+ return connStr, err
}
// ConnString represents a connection string to mongodb.
@@ -134,6 +133,7 @@ type ConnString struct {
MaxConnectingSet bool
Password string
PasswordSet bool
+ RawHosts []string
ReadConcernLevel string
ReadPreference string
ReadPreferenceTagSets []map[string]string
@@ -202,242 +202,51 @@ func (u *ConnString) HasAuthParameters() bool {
// Validate checks that the Auth and SSL parameters are valid values.
func (u *ConnString) Validate() error {
- p := parser{
- dnsResolver: dns.DefaultResolver,
- ConnString: *u,
- }
- return p.validate()
-}
-
-// ConnectMode informs the driver on how to connect
-// to the server.
-type ConnectMode uint8
-
-var _ fmt.Stringer = ConnectMode(0)
-
-// ConnectMode constants.
-const (
- AutoConnect ConnectMode = iota
- SingleConnect
-)
-
-// String implements the fmt.Stringer interface.
-func (c ConnectMode) String() string {
- switch c {
- case AutoConnect:
- return "automatic"
- case SingleConnect:
- return "direct"
- default:
- return "unknown"
- }
-}
-
-// Scheme constants
-const (
- SchemeMongoDB = "mongodb"
- SchemeMongoDBSRV = "mongodb+srv"
-)
-
-type parser struct {
- ConnString
-
- dnsResolver *dns.Resolver
- tlsssl *bool // used to determine if tls and ssl options are both specified and set differently.
-}
-
-func (p *parser) parse(original string) error {
- p.Original = original
- uri := original
-
var err error
- if strings.HasPrefix(uri, SchemeMongoDBSRV+"://") {
- p.Scheme = SchemeMongoDBSRV
- // remove the scheme
- uri = uri[len(SchemeMongoDBSRV)+3:]
- } else if strings.HasPrefix(uri, SchemeMongoDB+"://") {
- p.Scheme = SchemeMongoDB
- // remove the scheme
- uri = uri[len(SchemeMongoDB)+3:]
- } else {
- return errors.New(`scheme must be "mongodb" or "mongodb+srv"`)
- }
-
- if idx := strings.Index(uri, "@"); idx != -1 {
- userInfo := uri[:idx]
- uri = uri[idx+1:]
-
- username := userInfo
- var password string
-
- if idx := strings.Index(userInfo, ":"); idx != -1 {
- username = userInfo[:idx]
- password = userInfo[idx+1:]
- p.PasswordSet = true
- }
-
- // Validate and process the username.
- if strings.Contains(username, "/") {
- return fmt.Errorf("unescaped slash in username")
- }
- p.Username, err = url.PathUnescape(username)
- if err != nil {
- return fmt.Errorf("invalid username: %w", err)
- }
- p.UsernameSet = true
-
- // Validate and process the password.
- if strings.Contains(password, ":") {
- return fmt.Errorf("unescaped colon in password")
- }
- if strings.Contains(password, "/") {
- return fmt.Errorf("unescaped slash in password")
- }
- p.Password, err = url.PathUnescape(password)
- if err != nil {
- return fmt.Errorf("invalid password: %w", err)
- }
- }
-
- // fetch the hosts field
- hosts := uri
- if idx := strings.IndexAny(uri, "/?@"); idx != -1 {
- if uri[idx] == '@' {
- return fmt.Errorf("unescaped @ sign in user info")
- }
- if uri[idx] == '?' {
- return fmt.Errorf("must have a / before the query ?")
- }
- hosts = uri[:idx]
- }
- parsedHosts := strings.Split(hosts, ",")
- uri = uri[len(hosts):]
- extractedDatabase, err := extractDatabaseFromURI(uri)
- if err != nil {
+ if err = u.validateAuth(); err != nil {
return err
}
- uri = extractedDatabase.uri
- p.Database = extractedDatabase.db
-
- // grab connection arguments from URI
- connectionArgsFromQueryString, err := extractQueryArgsFromURI(uri)
- if err != nil {
- return err
- }
-
- // grab connection arguments from TXT record and enable SSL if "mongodb+srv://"
- var connectionArgsFromTXT []string
- if p.Scheme == SchemeMongoDBSRV {
- connectionArgsFromTXT, err = p.dnsResolver.GetConnectionArgsFromTXT(hosts)
- if err != nil {
- return err
- }
-
- // SSL is enabled by default for SRV, but can be manually disabled with "ssl=false".
- p.SSL = true
- p.SSLSet = true
- }
-
- // add connection arguments from URI and TXT records to connstring
- connectionArgPairs := make([]string, 0, len(connectionArgsFromTXT)+len(connectionArgsFromQueryString))
- connectionArgPairs = append(connectionArgPairs, connectionArgsFromTXT...)
- connectionArgPairs = append(connectionArgPairs, connectionArgsFromQueryString...)
-
- for _, pair := range connectionArgPairs {
- err := p.addOption(pair)
- if err != nil {
- return err
- }
- }
-
- // do SRV lookup if "mongodb+srv://"
- if p.Scheme == SchemeMongoDBSRV {
- parsedHosts, err = p.dnsResolver.ParseHosts(hosts, p.SRVServiceName, true)
- if err != nil {
- return err
- }
-
- // If p.SRVMaxHosts is non-zero and is less than the number of hosts, randomly
- // select SRVMaxHosts hosts from parsedHosts.
- if p.SRVMaxHosts > 0 && p.SRVMaxHosts < len(parsedHosts) {
- random.Shuffle(len(parsedHosts), func(i, j int) {
- parsedHosts[i], parsedHosts[j] = parsedHosts[j], parsedHosts[i]
- })
- parsedHosts = parsedHosts[:p.SRVMaxHosts]
- }
- }
-
- for _, host := range parsedHosts {
- err = p.addHost(host)
- if err != nil {
- return fmt.Errorf("invalid host %q: %w", host, err)
- }
- }
- if len(p.Hosts) == 0 {
- return fmt.Errorf("must have at least 1 host")
- }
-
- err = p.setDefaultAuthParams(extractedDatabase.db)
- if err != nil {
- return err
- }
-
- // If WTimeout was set from manual options passed in, set WTImeoutSet to true.
- if p.WTimeoutSetFromOption {
- p.WTimeoutSet = true
- }
-
- return nil
-}
-
-func (p *parser) validate() error {
- var err error
-
- err = p.validateAuth()
- if err != nil {
- return err
- }
-
- if err = p.validateSSL(); err != nil {
+ if err = u.validateSSL(); err != nil {
return err
}
// Check for invalid write concern (i.e. w=0 and j=true)
- if p.WNumberSet && p.WNumber == 0 && p.JSet && p.J {
+ if u.WNumberSet && u.WNumber == 0 && u.JSet && u.J {
return writeconcern.ErrInconsistent
}
// Check for invalid use of direct connections.
- if (p.ConnectSet && p.Connect == SingleConnect) || (p.DirectConnectionSet && p.DirectConnection) {
- if len(p.Hosts) > 1 {
+ if (u.ConnectSet && u.Connect == SingleConnect) ||
+ (u.DirectConnectionSet && u.DirectConnection) {
+ if len(u.Hosts) > 1 {
return errors.New("a direct connection cannot be made if multiple hosts are specified")
}
- if p.Scheme == SchemeMongoDBSRV {
+ if u.Scheme == SchemeMongoDBSRV {
return errors.New("a direct connection cannot be made if an SRV URI is used")
}
- if p.LoadBalancedSet && p.LoadBalanced {
+ if u.LoadBalancedSet && u.LoadBalanced {
return ErrLoadBalancedWithDirectConnection
}
}
// Validation for load-balanced mode.
- if p.LoadBalancedSet && p.LoadBalanced {
- if len(p.Hosts) > 1 {
+ if u.LoadBalancedSet && u.LoadBalanced {
+ if len(u.Hosts) > 1 {
return ErrLoadBalancedWithMultipleHosts
}
- if p.ReplicaSet != "" {
+ if u.ReplicaSet != "" {
return ErrLoadBalancedWithReplicaSet
}
}
// Check for invalid use of SRVMaxHosts.
- if p.SRVMaxHosts > 0 {
- if p.ReplicaSet != "" {
+ if u.SRVMaxHosts > 0 {
+ if u.ReplicaSet != "" {
return ErrSRVMaxHostsWithReplicaSet
}
- if p.LoadBalanced {
+ if u.LoadBalanced {
return ErrSRVMaxHostsWithLoadBalanced
}
}
@@ -445,34 +254,34 @@ func (p *parser) validate() error {
return nil
}
-func (p *parser) setDefaultAuthParams(dbName string) error {
+func (u *ConnString) setDefaultAuthParams(dbName string) error {
// We do this check here rather than in validateAuth because this function is called as part of parsing and sets
// the value of AuthSource if authentication is enabled.
- if p.AuthSourceSet && p.AuthSource == "" {
+ if u.AuthSourceSet && u.AuthSource == "" {
return errors.New("authSource must be non-empty when supplied in a URI")
}
- switch strings.ToLower(p.AuthMechanism) {
+ switch strings.ToLower(u.AuthMechanism) {
case "plain":
- if p.AuthSource == "" {
- p.AuthSource = dbName
- if p.AuthSource == "" {
- p.AuthSource = "$external"
+ if u.AuthSource == "" {
+ u.AuthSource = dbName
+ if u.AuthSource == "" {
+ u.AuthSource = "$external"
}
}
case "gssapi":
- if p.AuthMechanismProperties == nil {
- p.AuthMechanismProperties = map[string]string{
+ if u.AuthMechanismProperties == nil {
+ u.AuthMechanismProperties = map[string]string{
"SERVICE_NAME": "mongodb",
}
- } else if v, ok := p.AuthMechanismProperties["SERVICE_NAME"]; !ok || v == "" {
- p.AuthMechanismProperties["SERVICE_NAME"] = "mongodb"
+ } else if v, ok := u.AuthMechanismProperties["SERVICE_NAME"]; !ok || v == "" {
+ u.AuthMechanismProperties["SERVICE_NAME"] = "mongodb"
}
fallthrough
case "mongodb-aws", "mongodb-x509":
- if p.AuthSource == "" {
- p.AuthSource = "$external"
- } else if p.AuthSource != "$external" {
+ if u.AuthSource == "" {
+ u.AuthSource = "$external"
+ } else if u.AuthSource != "$external" {
return fmt.Errorf("auth source must be $external")
}
case "mongodb-cr":
@@ -480,18 +289,18 @@ func (p *parser) setDefaultAuthParams(dbName string) error {
case "scram-sha-1":
fallthrough
case "scram-sha-256":
- if p.AuthSource == "" {
- p.AuthSource = dbName
- if p.AuthSource == "" {
- p.AuthSource = "admin"
+ if u.AuthSource == "" {
+ u.AuthSource = dbName
+ if u.AuthSource == "" {
+ u.AuthSource = "admin"
}
}
case "":
// Only set auth source if there is a request for authentication via non-empty credentials.
- if p.AuthSource == "" && (p.AuthMechanismProperties != nil || p.Username != "" || p.PasswordSet) {
- p.AuthSource = dbName
- if p.AuthSource == "" {
- p.AuthSource = "admin"
+ if u.AuthSource == "" && (u.AuthMechanismProperties != nil || u.Username != "" || u.PasswordSet) {
+ u.AuthSource = dbName
+ if u.AuthSource == "" {
+ u.AuthSource = "admin"
}
}
default:
@@ -500,83 +309,473 @@ func (p *parser) setDefaultAuthParams(dbName string) error {
return nil
}
-func (p *parser) validateAuth() error {
- switch strings.ToLower(p.AuthMechanism) {
+func (u *ConnString) addOptions(connectionArgPairs []string) error {
+ var tlsssl *bool // used to determine if tls and ssl options are both specified and set differently.
+ for _, pair := range connectionArgPairs {
+ kv := strings.SplitN(pair, "=", 2)
+ if len(kv) != 2 || kv[0] == "" {
+ return fmt.Errorf("invalid option")
+ }
+
+ key, err := url.QueryUnescape(kv[0])
+ if err != nil {
+ return fmt.Errorf("invalid option key %q: %w", kv[0], err)
+ }
+
+ value, err := url.QueryUnescape(kv[1])
+ if err != nil {
+ return fmt.Errorf("invalid option value %q: %w", kv[1], err)
+ }
+
+ lowerKey := strings.ToLower(key)
+ switch lowerKey {
+ case "appname":
+ u.AppName = value
+ case "authmechanism":
+ u.AuthMechanism = value
+ case "authmechanismproperties":
+ u.AuthMechanismProperties = make(map[string]string)
+ pairs := strings.Split(value, ",")
+ for _, pair := range pairs {
+ kv := strings.SplitN(pair, ":", 2)
+ if len(kv) != 2 || kv[0] == "" {
+ return fmt.Errorf("invalid authMechanism property")
+ }
+ u.AuthMechanismProperties[kv[0]] = kv[1]
+ }
+ u.AuthMechanismPropertiesSet = true
+ case "authsource":
+ u.AuthSource = value
+ u.AuthSourceSet = true
+ case "compressors":
+ compressors := strings.Split(value, ",")
+ if len(compressors) < 1 {
+ return fmt.Errorf("must have at least 1 compressor")
+ }
+ u.Compressors = compressors
+ case "connect":
+ switch strings.ToLower(value) {
+ case "automatic":
+ case "direct":
+ u.Connect = SingleConnect
+ default:
+ return fmt.Errorf("invalid 'connect' value: %q", value)
+ }
+ if u.DirectConnectionSet {
+ expectedValue := u.Connect == SingleConnect // directConnection should be true if connect=direct
+ if u.DirectConnection != expectedValue {
+ return fmt.Errorf("options connect=%q and directConnection=%v conflict", value, u.DirectConnection)
+ }
+ }
+
+ u.ConnectSet = true
+ case "directconnection":
+ switch strings.ToLower(value) {
+ case "true":
+ u.DirectConnection = true
+ case "false":
+ default:
+ return fmt.Errorf("invalid 'directConnection' value: %q", value)
+ }
+
+ if u.ConnectSet {
+ expectedValue := AutoConnect
+ if u.DirectConnection {
+ expectedValue = SingleConnect
+ }
+
+ if u.Connect != expectedValue {
+ return fmt.Errorf("options connect=%q and directConnection=%q conflict", u.Connect, value)
+ }
+ }
+ u.DirectConnectionSet = true
+ case "connecttimeoutms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.ConnectTimeout = time.Duration(n) * time.Millisecond
+ u.ConnectTimeoutSet = true
+ case "heartbeatintervalms", "heartbeatfrequencyms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.HeartbeatInterval = time.Duration(n) * time.Millisecond
+ u.HeartbeatIntervalSet = true
+ case "journal":
+ switch value {
+ case "true":
+ u.J = true
+ case "false":
+ u.J = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.JSet = true
+ case "loadbalanced":
+ switch value {
+ case "true":
+ u.LoadBalanced = true
+ case "false":
+ u.LoadBalanced = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.LoadBalancedSet = true
+ case "localthresholdms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.LocalThreshold = time.Duration(n) * time.Millisecond
+ u.LocalThresholdSet = true
+ case "maxidletimems":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.MaxConnIdleTime = time.Duration(n) * time.Millisecond
+ u.MaxConnIdleTimeSet = true
+ case "maxpoolsize":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.MaxPoolSize = uint64(n)
+ u.MaxPoolSizeSet = true
+ case "minpoolsize":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.MinPoolSize = uint64(n)
+ u.MinPoolSizeSet = true
+ case "maxconnecting":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.MaxConnecting = uint64(n)
+ u.MaxConnectingSet = true
+ case "readconcernlevel":
+ u.ReadConcernLevel = value
+ case "readpreference":
+ u.ReadPreference = value
+ case "readpreferencetags":
+ if value == "" {
+ // If "readPreferenceTags=" is supplied, append an empty map to tag sets to
+ // represent a wild-card.
+ u.ReadPreferenceTagSets = append(u.ReadPreferenceTagSets, map[string]string{})
+ break
+ }
+
+ tags := make(map[string]string)
+ items := strings.Split(value, ",")
+ for _, item := range items {
+ parts := strings.Split(item, ":")
+ if len(parts) != 2 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ tags[parts[0]] = parts[1]
+ }
+ u.ReadPreferenceTagSets = append(u.ReadPreferenceTagSets, tags)
+ case "maxstaleness", "maxstalenessseconds":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.MaxStaleness = time.Duration(n) * time.Second
+ u.MaxStalenessSet = true
+ case "replicaset":
+ u.ReplicaSet = value
+ case "retrywrites":
+ switch value {
+ case "true":
+ u.RetryWrites = true
+ case "false":
+ u.RetryWrites = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.RetryWritesSet = true
+ case "retryreads":
+ switch value {
+ case "true":
+ u.RetryReads = true
+ case "false":
+ u.RetryReads = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.RetryReadsSet = true
+ case "servermonitoringmode":
+ if !IsValidServerMonitoringMode(value) {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.ServerMonitoringMode = value
+ case "serverselectiontimeoutms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.ServerSelectionTimeout = time.Duration(n) * time.Millisecond
+ u.ServerSelectionTimeoutSet = true
+ case "sockettimeoutms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.SocketTimeout = time.Duration(n) * time.Millisecond
+ u.SocketTimeoutSet = true
+ case "srvmaxhosts":
+ // srvMaxHosts can only be set on URIs with the "mongodb+srv" scheme
+ if u.Scheme != SchemeMongoDBSRV {
+ return fmt.Errorf("cannot specify srvMaxHosts on non-SRV URI")
+ }
+
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.SRVMaxHosts = n
+ case "srvservicename":
+ // srvServiceName can only be set on URIs with the "mongodb+srv" scheme
+ if u.Scheme != SchemeMongoDBSRV {
+ return fmt.Errorf("cannot specify srvServiceName on non-SRV URI")
+ }
+
+ // srvServiceName must be between 1 and 62 characters according to
+ // our specification. Empty service names are not valid, and the service
+ // name (including prepended underscore) should not exceed the 63 character
+ // limit for DNS query subdomains.
+ if len(value) < 1 || len(value) > 62 {
+ return fmt.Errorf("srvServiceName value must be between 1 and 62 characters")
+ }
+ u.SRVServiceName = value
+ case "ssl", "tls":
+ switch value {
+ case "true":
+ u.SSL = true
+ case "false":
+ u.SSL = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ if tlsssl == nil {
+ tlsssl = new(bool)
+ *tlsssl = u.SSL
+ } else if *tlsssl != u.SSL {
+ return errors.New("tls and ssl options, when both specified, must be equivalent")
+ }
+
+ u.SSLSet = true
+ case "sslclientcertificatekeyfile", "tlscertificatekeyfile":
+ u.SSL = true
+ u.SSLSet = true
+ u.SSLClientCertificateKeyFile = value
+ u.SSLClientCertificateKeyFileSet = true
+ case "sslclientcertificatekeypassword", "tlscertificatekeyfilepassword":
+ u.SSLClientCertificateKeyPassword = func() string { return value }
+ u.SSLClientCertificateKeyPasswordSet = true
+ case "tlscertificatefile":
+ u.SSL = true
+ u.SSLSet = true
+ u.SSLCertificateFile = value
+ u.SSLCertificateFileSet = true
+ case "tlsprivatekeyfile":
+ u.SSL = true
+ u.SSLSet = true
+ u.SSLPrivateKeyFile = value
+ u.SSLPrivateKeyFileSet = true
+ case "sslinsecure", "tlsinsecure":
+ switch value {
+ case "true":
+ u.SSLInsecure = true
+ case "false":
+ u.SSLInsecure = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.SSLInsecureSet = true
+ case "sslcertificateauthorityfile", "tlscafile":
+ u.SSL = true
+ u.SSLSet = true
+ u.SSLCaFile = value
+ u.SSLCaFileSet = true
+ case "timeoutms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.Timeout = time.Duration(n) * time.Millisecond
+ u.TimeoutSet = true
+ case "tlsdisableocspendpointcheck":
+ u.SSL = true
+ u.SSLSet = true
+
+ switch value {
+ case "true":
+ u.SSLDisableOCSPEndpointCheck = true
+ case "false":
+ u.SSLDisableOCSPEndpointCheck = false
+ default:
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.SSLDisableOCSPEndpointCheckSet = true
+ case "w":
+ if w, err := strconv.Atoi(value); err == nil {
+ if w < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ u.WNumber = w
+ u.WNumberSet = true
+ u.WString = ""
+ break
+ }
+
+ u.WString = value
+ u.WNumberSet = false
+
+ case "wtimeoutms":
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.WTimeout = time.Duration(n) * time.Millisecond
+ u.WTimeoutSet = true
+ case "wtimeout":
+ // Defer to wtimeoutms, but not to a manually-set option.
+ if u.WTimeoutSet {
+ break
+ }
+ n, err := strconv.Atoi(value)
+ if err != nil || n < 0 {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+ u.WTimeout = time.Duration(n) * time.Millisecond
+ case "zlibcompressionlevel":
+ level, err := strconv.Atoi(value)
+ if err != nil || (level < -1 || level > 9) {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ if level == -1 {
+ level = wiremessage.DefaultZlibLevel
+ }
+ u.ZlibLevel = level
+ u.ZlibLevelSet = true
+ case "zstdcompressionlevel":
+ const maxZstdLevel = 22 // https://github.com/facebook/zstd/blob/a880ca239b447968493dd2fed3850e766d6305cc/contrib/linux-kernel/lib/zstd/compress.c#L3291
+ level, err := strconv.Atoi(value)
+ if err != nil || (level < -1 || level > maxZstdLevel) {
+ return fmt.Errorf("invalid value for %q: %q", key, value)
+ }
+
+ if level == -1 {
+ level = wiremessage.DefaultZstdLevel
+ }
+ u.ZstdLevel = level
+ u.ZstdLevelSet = true
+ default:
+ if u.UnknownOptions == nil {
+ u.UnknownOptions = make(map[string][]string)
+ }
+ u.UnknownOptions[lowerKey] = append(u.UnknownOptions[lowerKey], value)
+ }
+
+ if u.Options == nil {
+ u.Options = make(map[string][]string)
+ }
+ u.Options[lowerKey] = append(u.Options[lowerKey], value)
+ }
+ return nil
+}
+
+func (u *ConnString) validateAuth() error {
+ switch strings.ToLower(u.AuthMechanism) {
case "mongodb-cr":
- if p.Username == "" {
+ if u.Username == "" {
return fmt.Errorf("username required for MONGO-CR")
}
- if p.Password == "" {
+ if u.Password == "" {
return fmt.Errorf("password required for MONGO-CR")
}
- if p.AuthMechanismProperties != nil {
+ if u.AuthMechanismProperties != nil {
return fmt.Errorf("MONGO-CR cannot have mechanism properties")
}
case "mongodb-x509":
- if p.Password != "" {
+ if u.Password != "" {
return fmt.Errorf("password cannot be specified for MONGO-X509")
}
- if p.AuthMechanismProperties != nil {
+ if u.AuthMechanismProperties != nil {
return fmt.Errorf("MONGO-X509 cannot have mechanism properties")
}
case "mongodb-aws":
- if p.Username != "" && p.Password == "" {
+ if u.Username != "" && u.Password == "" {
return fmt.Errorf("username without password is invalid for MONGODB-AWS")
}
- if p.Username == "" && p.Password != "" {
+ if u.Username == "" && u.Password != "" {
return fmt.Errorf("password without username is invalid for MONGODB-AWS")
}
var token bool
- for k := range p.AuthMechanismProperties {
+ for k := range u.AuthMechanismProperties {
if k != "AWS_SESSION_TOKEN" {
return fmt.Errorf("invalid auth property for MONGODB-AWS")
}
token = true
}
- if token && p.Username == "" && p.Password == "" {
+ if token && u.Username == "" && u.Password == "" {
return fmt.Errorf("token without username and password is invalid for MONGODB-AWS")
}
case "gssapi":
- if p.Username == "" {
+ if u.Username == "" {
return fmt.Errorf("username required for GSSAPI")
}
- for k := range p.AuthMechanismProperties {
+ for k := range u.AuthMechanismProperties {
if k != "SERVICE_NAME" && k != "CANONICALIZE_HOST_NAME" && k != "SERVICE_REALM" && k != "SERVICE_HOST" {
return fmt.Errorf("invalid auth property for GSSAPI")
}
}
case "plain":
- if p.Username == "" {
+ if u.Username == "" {
return fmt.Errorf("username required for PLAIN")
}
- if p.Password == "" {
+ if u.Password == "" {
return fmt.Errorf("password required for PLAIN")
}
- if p.AuthMechanismProperties != nil {
+ if u.AuthMechanismProperties != nil {
return fmt.Errorf("PLAIN cannot have mechanism properties")
}
case "scram-sha-1":
- if p.Username == "" {
+ if u.Username == "" {
return fmt.Errorf("username required for SCRAM-SHA-1")
}
- if p.Password == "" {
+ if u.Password == "" {
return fmt.Errorf("password required for SCRAM-SHA-1")
}
- if p.AuthMechanismProperties != nil {
+ if u.AuthMechanismProperties != nil {
return fmt.Errorf("SCRAM-SHA-1 cannot have mechanism properties")
}
case "scram-sha-256":
- if p.Username == "" {
+ if u.Username == "" {
return fmt.Errorf("username required for SCRAM-SHA-256")
}
- if p.Password == "" {
+ if u.Password == "" {
return fmt.Errorf("password required for SCRAM-SHA-256")
}
- if p.AuthMechanismProperties != nil {
+ if u.AuthMechanismProperties != nil {
return fmt.Errorf("SCRAM-SHA-256 cannot have mechanism properties")
}
case "":
- if p.UsernameSet && p.Username == "" {
+ if u.UsernameSet && u.Username == "" {
return fmt.Errorf("username required if URI contains user info")
}
default:
@@ -585,457 +784,261 @@ func (p *parser) validateAuth() error {
return nil
}
-func (p *parser) validateSSL() error {
- if !p.SSL {
+func (u *ConnString) validateSSL() error {
+ if !u.SSL {
return nil
}
- if p.SSLClientCertificateKeyFileSet {
- if p.SSLCertificateFileSet || p.SSLPrivateKeyFileSet {
+ if u.SSLClientCertificateKeyFileSet {
+ if u.SSLCertificateFileSet || u.SSLPrivateKeyFileSet {
return errors.New("the sslClientCertificateKeyFile/tlsCertificateKeyFile URI option cannot be provided " +
"along with tlsCertificateFile or tlsPrivateKeyFile")
}
return nil
}
- if p.SSLCertificateFileSet && !p.SSLPrivateKeyFileSet {
+ if u.SSLCertificateFileSet && !u.SSLPrivateKeyFileSet {
return errors.New("the tlsPrivateKeyFile URI option must be provided if the tlsCertificateFile option is specified")
}
- if p.SSLPrivateKeyFileSet && !p.SSLCertificateFileSet {
+ if u.SSLPrivateKeyFileSet && !u.SSLCertificateFileSet {
return errors.New("the tlsCertificateFile URI option must be provided if the tlsPrivateKeyFile option is specified")
}
- if p.SSLInsecureSet && p.SSLDisableOCSPEndpointCheckSet {
+ if u.SSLInsecureSet && u.SSLDisableOCSPEndpointCheckSet {
return errors.New("the sslInsecure/tlsInsecure URI option cannot be provided along with " +
"tlsDisableOCSPEndpointCheck ")
}
return nil
}
-func (p *parser) addHost(host string) error {
+func sanitizeHost(host string) (string, error) {
if host == "" {
- return nil
+ return host, nil
}
- host, err := url.QueryUnescape(host)
+ unescaped, err := url.QueryUnescape(host)
if err != nil {
- return fmt.Errorf("invalid host %q: %w", host, err)
+ return "", fmt.Errorf("invalid host %q: %w", host, err)
}
- _, port, err := net.SplitHostPort(host)
+ _, port, err := net.SplitHostPort(unescaped)
// this is unfortunate that SplitHostPort actually requires
// a port to exist.
if err != nil {
if addrError, ok := err.(*net.AddrError); !ok || addrError.Err != "missing port in address" {
- return err
+ return "", err
}
}
if port != "" {
d, err := strconv.Atoi(port)
if err != nil {
- return fmt.Errorf("port must be an integer: %w", err)
+ return "", fmt.Errorf("port must be an integer: %w", err)
}
if d <= 0 || d >= 65536 {
- return fmt.Errorf("port must be in the range [1, 65535]")
+ return "", fmt.Errorf("port must be in the range [1, 65535]")
}
}
- p.Hosts = append(p.Hosts, host)
- return nil
+ return unescaped, nil
}
-// IsValidServerMonitoringMode will return true if the given string matches a
-// valid server monitoring mode.
-func IsValidServerMonitoringMode(mode string) bool {
- return mode == ServerMonitoringModeAuto ||
- mode == ServerMonitoringModeStream ||
- mode == ServerMonitoringModePoll
-}
+// ConnectMode informs the driver on how to connect
+// to the server.
+type ConnectMode uint8
-func (p *parser) addOption(pair string) error {
- kv := strings.SplitN(pair, "=", 2)
- if len(kv) != 2 || kv[0] == "" {
- return fmt.Errorf("invalid option")
- }
+var _ fmt.Stringer = ConnectMode(0)
- key, err := url.QueryUnescape(kv[0])
- if err != nil {
- return fmt.Errorf("invalid option key %q: %w", kv[0], err)
- }
+// ConnectMode constants.
+const (
+ AutoConnect ConnectMode = iota
+ SingleConnect
+)
- value, err := url.QueryUnescape(kv[1])
- if err != nil {
- return fmt.Errorf("invalid option value %q: %w", kv[1], err)
+// String implements the fmt.Stringer interface.
+func (c ConnectMode) String() string {
+ switch c {
+ case AutoConnect:
+ return "automatic"
+ case SingleConnect:
+ return "direct"
+ default:
+ return "unknown"
}
+}
- lowerKey := strings.ToLower(key)
- switch lowerKey {
- case "appname":
- p.AppName = value
- case "authmechanism":
- p.AuthMechanism = value
- case "authmechanismproperties":
- p.AuthMechanismProperties = make(map[string]string)
- pairs := strings.Split(value, ",")
- for _, pair := range pairs {
- kv := strings.SplitN(pair, ":", 2)
- if len(kv) != 2 || kv[0] == "" {
- return fmt.Errorf("invalid authMechanism property")
- }
- p.AuthMechanismProperties[kv[0]] = kv[1]
- }
- p.AuthMechanismPropertiesSet = true
- case "authsource":
- p.AuthSource = value
- p.AuthSourceSet = true
- case "compressors":
- compressors := strings.Split(value, ",")
- if len(compressors) < 1 {
- return fmt.Errorf("must have at least 1 compressor")
- }
- p.Compressors = compressors
- case "connect":
- switch strings.ToLower(value) {
- case "automatic":
- case "direct":
- p.Connect = SingleConnect
- default:
- return fmt.Errorf("invalid 'connect' value: %q", value)
- }
- if p.DirectConnectionSet {
- expectedValue := p.Connect == SingleConnect // directConnection should be true if connect=direct
- if p.DirectConnection != expectedValue {
- return fmt.Errorf("options connect=%q and directConnection=%v conflict", value, p.DirectConnection)
- }
- }
+// Scheme constants
+const (
+ SchemeMongoDB = "mongodb"
+ SchemeMongoDBSRV = "mongodb+srv"
+)
- p.ConnectSet = true
- case "directconnection":
- switch strings.ToLower(value) {
- case "true":
- p.DirectConnection = true
- case "false":
- default:
- return fmt.Errorf("invalid 'directConnection' value: %q", value)
- }
+type parser struct {
+ dnsResolver *dns.Resolver
+}
- if p.ConnectSet {
- expectedValue := AutoConnect
- if p.DirectConnection {
- expectedValue = SingleConnect
- }
+func (p *parser) parse(original string) (*ConnString, error) {
+ connStr := &ConnString{}
+ connStr.Original = original
+ uri := original
- if p.Connect != expectedValue {
- return fmt.Errorf("options connect=%q and directConnection=%q conflict", p.Connect, value)
- }
- }
- p.DirectConnectionSet = true
- case "connecttimeoutms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.ConnectTimeout = time.Duration(n) * time.Millisecond
- p.ConnectTimeoutSet = true
- case "heartbeatintervalms", "heartbeatfrequencyms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.HeartbeatInterval = time.Duration(n) * time.Millisecond
- p.HeartbeatIntervalSet = true
- case "journal":
- switch value {
- case "true":
- p.J = true
- case "false":
- p.J = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
+ var err error
+ if strings.HasPrefix(uri, SchemeMongoDBSRV+"://") {
+ connStr.Scheme = SchemeMongoDBSRV
+ // remove the scheme
+ uri = uri[len(SchemeMongoDBSRV)+3:]
+ } else if strings.HasPrefix(uri, SchemeMongoDB+"://") {
+ connStr.Scheme = SchemeMongoDB
+ // remove the scheme
+ uri = uri[len(SchemeMongoDB)+3:]
+ } else {
+ return nil, errors.New(`scheme must be "mongodb" or "mongodb+srv"`)
+ }
- p.JSet = true
- case "loadbalanced":
- switch value {
- case "true":
- p.LoadBalanced = true
- case "false":
- p.LoadBalanced = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
+ if idx := strings.Index(uri, "@"); idx != -1 {
+ userInfo := uri[:idx]
+ uri = uri[idx+1:]
- p.LoadBalancedSet = true
- case "localthresholdms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.LocalThreshold = time.Duration(n) * time.Millisecond
- p.LocalThresholdSet = true
- case "maxidletimems":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.MaxConnIdleTime = time.Duration(n) * time.Millisecond
- p.MaxConnIdleTimeSet = true
- case "maxpoolsize":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.MaxPoolSize = uint64(n)
- p.MaxPoolSizeSet = true
- case "minpoolsize":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.MinPoolSize = uint64(n)
- p.MinPoolSizeSet = true
- case "maxconnecting":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.MaxConnecting = uint64(n)
- p.MaxConnectingSet = true
- case "readconcernlevel":
- p.ReadConcernLevel = value
- case "readpreference":
- p.ReadPreference = value
- case "readpreferencetags":
- if value == "" {
- // If "readPreferenceTags=" is supplied, append an empty map to tag sets to
- // represent a wild-card.
- p.ReadPreferenceTagSets = append(p.ReadPreferenceTagSets, map[string]string{})
- break
- }
+ username := userInfo
+ var password string
- tags := make(map[string]string)
- items := strings.Split(value, ",")
- for _, item := range items {
- parts := strings.Split(item, ":")
- if len(parts) != 2 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- tags[parts[0]] = parts[1]
- }
- p.ReadPreferenceTagSets = append(p.ReadPreferenceTagSets, tags)
- case "maxstaleness", "maxstalenessseconds":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.MaxStaleness = time.Duration(n) * time.Second
- p.MaxStalenessSet = true
- case "replicaset":
- p.ReplicaSet = value
- case "retrywrites":
- switch value {
- case "true":
- p.RetryWrites = true
- case "false":
- p.RetryWrites = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ if idx := strings.Index(userInfo, ":"); idx != -1 {
+ username = userInfo[:idx]
+ password = userInfo[idx+1:]
+ connStr.PasswordSet = true
}
- p.RetryWritesSet = true
- case "retryreads":
- switch value {
- case "true":
- p.RetryReads = true
- case "false":
- p.RetryReads = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ // Validate and process the username.
+ if strings.Contains(username, "/") {
+ return nil, fmt.Errorf("unescaped slash in username")
}
-
- p.RetryReadsSet = true
- case "servermonitoringmode":
- if !IsValidServerMonitoringMode(value) {
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ connStr.Username, err = url.PathUnescape(username)
+ if err != nil {
+ return nil, fmt.Errorf("invalid username: %w", err)
}
+ connStr.UsernameSet = true
- p.ServerMonitoringMode = value
- case "serverselectiontimeoutms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ // Validate and process the password.
+ if strings.Contains(password, ":") {
+ return nil, fmt.Errorf("unescaped colon in password")
}
- p.ServerSelectionTimeout = time.Duration(n) * time.Millisecond
- p.ServerSelectionTimeoutSet = true
- case "sockettimeoutms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ if strings.Contains(password, "/") {
+ return nil, fmt.Errorf("unescaped slash in password")
}
- p.SocketTimeout = time.Duration(n) * time.Millisecond
- p.SocketTimeoutSet = true
- case "srvmaxhosts":
- // srvMaxHosts can only be set on URIs with the "mongodb+srv" scheme
- if p.Scheme != SchemeMongoDBSRV {
- return fmt.Errorf("cannot specify srvMaxHosts on non-SRV URI")
+ connStr.Password, err = url.PathUnescape(password)
+ if err != nil {
+ return nil, fmt.Errorf("invalid password: %w", err)
}
+ }
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ // fetch the hosts field
+ hosts := uri
+ if idx := strings.IndexAny(uri, "/?@"); idx != -1 {
+ if uri[idx] == '@' {
+ return nil, fmt.Errorf("unescaped @ sign in user info")
}
- p.SRVMaxHosts = n
- case "srvservicename":
- // srvServiceName can only be set on URIs with the "mongodb+srv" scheme
- if p.Scheme != SchemeMongoDBSRV {
- return fmt.Errorf("cannot specify srvServiceName on non-SRV URI")
+ if uri[idx] == '?' {
+ return nil, fmt.Errorf("must have a / before the query ?")
}
+ hosts = uri[:idx]
+ }
- // srvServiceName must be between 1 and 62 characters according to
- // our specification. Empty service names are not valid, and the service
- // name (including prepended underscore) should not exceed the 63 character
- // limit for DNS query subdomains.
- if len(value) < 1 || len(value) > 62 {
- return fmt.Errorf("srvServiceName value must be between 1 and 62 characters")
- }
- p.SRVServiceName = value
- case "ssl", "tls":
- switch value {
- case "true":
- p.SSL = true
- case "false":
- p.SSL = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ for _, host := range strings.Split(hosts, ",") {
+ host, err = sanitizeHost(host)
+ if err != nil {
+ return nil, fmt.Errorf("invalid host %q: %w", host, err)
}
- if p.tlsssl != nil && *p.tlsssl != p.SSL {
- return errors.New("tls and ssl options, when both specified, must be equivalent")
+ if host != "" {
+ connStr.RawHosts = append(connStr.RawHosts, host)
}
+ }
+ connStr.Hosts = connStr.RawHosts
+ uri = uri[len(hosts):]
+ extractedDatabase, err := extractDatabaseFromURI(uri)
+ if err != nil {
+ return nil, err
+ }
- p.tlsssl = new(bool)
- *p.tlsssl = p.SSL
-
- p.SSLSet = true
- case "sslclientcertificatekeyfile", "tlscertificatekeyfile":
- p.SSL = true
- p.SSLSet = true
- p.SSLClientCertificateKeyFile = value
- p.SSLClientCertificateKeyFileSet = true
- case "sslclientcertificatekeypassword", "tlscertificatekeyfilepassword":
- p.SSLClientCertificateKeyPassword = func() string { return value }
- p.SSLClientCertificateKeyPasswordSet = true
- case "tlscertificatefile":
- p.SSL = true
- p.SSLSet = true
- p.SSLCertificateFile = value
- p.SSLCertificateFileSet = true
- case "tlsprivatekeyfile":
- p.SSL = true
- p.SSLSet = true
- p.SSLPrivateKeyFile = value
- p.SSLPrivateKeyFileSet = true
- case "sslinsecure", "tlsinsecure":
- switch value {
- case "true":
- p.SSLInsecure = true
- case "false":
- p.SSLInsecure = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
+ uri = extractedDatabase.uri
+ connStr.Database = extractedDatabase.db
- p.SSLInsecureSet = true
- case "sslcertificateauthorityfile", "tlscafile":
- p.SSL = true
- p.SSLSet = true
- p.SSLCaFile = value
- p.SSLCaFileSet = true
- case "timeoutms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.Timeout = time.Duration(n) * time.Millisecond
- p.TimeoutSet = true
- case "tlsdisableocspendpointcheck":
- p.SSL = true
- p.SSLSet = true
-
- switch value {
- case "true":
- p.SSLDisableOCSPEndpointCheck = true
- case "false":
- p.SSLDisableOCSPEndpointCheck = false
- default:
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.SSLDisableOCSPEndpointCheckSet = true
- case "w":
- if w, err := strconv.Atoi(value); err == nil {
- if w < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
+ // grab connection arguments from URI
+ connectionArgsFromQueryString, err := extractQueryArgsFromURI(uri)
+ if err != nil {
+ return nil, err
+ }
- p.WNumber = w
- p.WNumberSet = true
- p.WString = ""
- break
+ // grab connection arguments from TXT record and enable SSL if "mongodb+srv://"
+ var connectionArgsFromTXT []string
+ if connStr.Scheme == SchemeMongoDBSRV && p.dnsResolver != nil {
+ connectionArgsFromTXT, err = p.dnsResolver.GetConnectionArgsFromTXT(hosts)
+ if err != nil {
+ return nil, err
}
- p.WString = value
- p.WNumberSet = false
+ // SSL is enabled by default for SRV, but can be manually disabled with "ssl=false".
+ connStr.SSL = true
+ connStr.SSLSet = true
+ }
+
+ // add connection arguments from URI and TXT records to connstring
+ connectionArgPairs := make([]string, 0, len(connectionArgsFromTXT)+len(connectionArgsFromQueryString))
+ connectionArgPairs = append(connectionArgPairs, connectionArgsFromTXT...)
+ connectionArgPairs = append(connectionArgPairs, connectionArgsFromQueryString...)
- case "wtimeoutms":
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.WTimeout = time.Duration(n) * time.Millisecond
- p.WTimeoutSet = true
- case "wtimeout":
- // Defer to wtimeoutms, but not to a manually-set option.
- if p.WTimeoutSet {
- break
- }
- n, err := strconv.Atoi(value)
- if err != nil || n < 0 {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
- p.WTimeout = time.Duration(n) * time.Millisecond
- case "zlibcompressionlevel":
- level, err := strconv.Atoi(value)
- if err != nil || (level < -1 || level > 9) {
- return fmt.Errorf("invalid value for %q: %q", key, value)
- }
+ err = connStr.addOptions(connectionArgPairs)
+ if err != nil {
+ return nil, err
+ }
- if level == -1 {
- level = wiremessage.DefaultZlibLevel
- }
- p.ZlibLevel = level
- p.ZlibLevelSet = true
- case "zstdcompressionlevel":
- const maxZstdLevel = 22 // https://github.com/facebook/zstd/blob/a880ca239b447968493dd2fed3850e766d6305cc/contrib/linux-kernel/lib/zstd/compress.c#L3291
- level, err := strconv.Atoi(value)
- if err != nil || (level < -1 || level > maxZstdLevel) {
- return fmt.Errorf("invalid value for %q: %q", key, value)
+ // do SRV lookup if "mongodb+srv://"
+ if connStr.Scheme == SchemeMongoDBSRV && p.dnsResolver != nil {
+ parsedHosts, err := p.dnsResolver.ParseHosts(hosts, connStr.SRVServiceName, true)
+ if err != nil {
+ return connStr, err
}
- if level == -1 {
- level = wiremessage.DefaultZstdLevel
+ // If p.SRVMaxHosts is non-zero and is less than the number of hosts, randomly
+ // select SRVMaxHosts hosts from parsedHosts.
+ if connStr.SRVMaxHosts > 0 && connStr.SRVMaxHosts < len(parsedHosts) {
+ random.Shuffle(len(parsedHosts), func(i, j int) {
+ parsedHosts[i], parsedHosts[j] = parsedHosts[j], parsedHosts[i]
+ })
+ parsedHosts = parsedHosts[:connStr.SRVMaxHosts]
}
- p.ZstdLevel = level
- p.ZstdLevelSet = true
- default:
- if p.UnknownOptions == nil {
- p.UnknownOptions = make(map[string][]string)
+
+ var hosts []string
+ for _, host := range parsedHosts {
+ host, err = sanitizeHost(host)
+ if err != nil {
+ return connStr, fmt.Errorf("invalid host %q: %w", host, err)
+ }
+ if host != "" {
+ hosts = append(hosts, host)
+ }
}
- p.UnknownOptions[lowerKey] = append(p.UnknownOptions[lowerKey], value)
+ connStr.Hosts = hosts
+ }
+ if len(connStr.Hosts) == 0 {
+ return nil, fmt.Errorf("must have at least 1 host")
}
- if p.Options == nil {
- p.Options = make(map[string][]string)
+ err = connStr.setDefaultAuthParams(extractedDatabase.db)
+ if err != nil {
+ return nil, err
}
- p.Options[lowerKey] = append(p.Options[lowerKey], value)
- return nil
+ // If WTimeout was set from manual options passed in, set WTImeoutSet to true.
+ if connStr.WTimeoutSetFromOption {
+ connStr.WTimeoutSet = true
+ }
+
+ return connStr, nil
+}
+
+// IsValidServerMonitoringMode will return true if the given string matches a
+// valid server monitoring mode.
+func IsValidServerMonitoringMode(mode string) bool {
+ return mode == ServerMonitoringModeAuto ||
+ mode == ServerMonitoringModeStream ||
+ mode == ServerMonitoringModePoll
}
func extractQueryArgsFromURI(uri string) ([]string, error) {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/crypt.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/crypt.go
index 4c254c03cf..576c007d67 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/crypt.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/crypt.go
@@ -9,6 +9,7 @@ package driver
import (
"context"
"crypto/tls"
+ "errors"
"fmt"
"io"
"strings"
@@ -399,7 +400,7 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
res := make([]byte, bytesNeeded)
bytesRead, err := conn.Read(res)
- if err != nil && err != io.EOF {
+ if err != nil && !errors.Is(err, io.EOF) {
return err
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/dns/dns.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/dns/dns.go
index 848554d3a1..6573a4c1ad 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/dns/dns.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/dns/dns.go
@@ -104,8 +104,8 @@ func (r *Resolver) fetchSeedlistFromSRV(host string, srvName string, stopOnErr b
}
func validateSRVResult(recordFromSRV, inputHostName string) error {
- separatedInputDomain := strings.Split(inputHostName, ".")
- separatedRecord := strings.Split(recordFromSRV, ".")
+ separatedInputDomain := strings.Split(strings.ToLower(inputHostName), ".")
+ separatedRecord := strings.Split(strings.ToLower(recordFromSRV), ".")
if len(separatedRecord) < 2 {
return errors.New("DNS name must contain at least 2 labels")
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/config.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/config.go
index eac2aab7fa..5b720cd590 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/config.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/config.go
@@ -57,11 +57,11 @@ func newConfig(certChain []*x509.Certificate, opts *VerifyOptions) (config, erro
var err error
cfg.ocspRequestBytes, err = ocsp.CreateRequest(cfg.serverCert, cfg.issuer, nil)
if err != nil {
- return cfg, fmt.Errorf("error creating OCSP request: %v", err)
+ return cfg, fmt.Errorf("error creating OCSP request: %w", err)
}
cfg.ocspRequest, err = ocsp.ParseRequest(cfg.ocspRequestBytes)
if err != nil {
- return cfg, fmt.Errorf("error parsing OCSP request bytes: %v", err)
+ return cfg, fmt.Errorf("error parsing OCSP request bytes: %w", err)
}
return cfg, nil
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/ocsp.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/ocsp.go
index 849530fde9..8700728729 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/ocsp.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/ocsp.go
@@ -161,10 +161,10 @@ func processStaple(cfg config, staple []byte) (*ResponseDetails, error) {
// If the stapled response could not be parsed correctly, error. This can happen if the response is malformed,
// the response does not cover the certificate presented by the server, or if the response contains an error
// status.
- return nil, fmt.Errorf("error parsing stapled response: %v", err)
+ return nil, fmt.Errorf("error parsing stapled response: %w", err)
}
if err = verifyResponse(cfg, parsedResponse); err != nil {
- return nil, fmt.Errorf("error validating stapled response: %v", err)
+ return nil, fmt.Errorf("error validating stapled response: %w", err)
}
return extractResponseDetails(parsedResponse), nil
@@ -192,7 +192,7 @@ func isMustStapleCertificate(cert *x509.Certificate) (bool, error) {
// Use []*big.Int to ensure that all values in the sequence can be successfully unmarshalled.
var featureValues []*big.Int
if _, err := asn1.Unmarshal(featureExtension.Value, &featureValues); err != nil {
- return false, fmt.Errorf("error unmarshalling TLS feature extension values: %v", err)
+ return false, fmt.Errorf("error unmarshalling TLS feature extension values: %w", err)
}
for _, value := range featureValues {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation.go
index 905c9cfc55..b39a63abe4 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation.go
@@ -458,7 +458,7 @@ func (op Operation) getServerAndConnection(
if err := pinnedConn.PinToTransaction(); err != nil {
// Close the original connection to avoid a leak.
_ = conn.Close()
- return nil, nil, fmt.Errorf("error incrementing connection reference count when starting a transaction: %v", err)
+ return nil, nil, fmt.Errorf("error incrementing connection reference count when starting a transaction: %w", err)
}
op.Client.PinnedConnection = pinnedConn
}
@@ -1492,7 +1492,7 @@ func (op Operation) addWriteConcern(dst []byte, desc description.SelectedServer)
}
t, data, err := wc.MarshalBSONValue()
- if err == writeconcern.ErrEmptyWriteConcern {
+ if errors.Is(err, writeconcern.ErrEmptyWriteConcern) {
return dst, nil
}
if err != nil {
@@ -1748,7 +1748,7 @@ func (op Operation) createReadPref(desc description.SelectedServer, isOpQuery bo
doc = bsoncore.AppendBooleanElement(doc, "enabled", *hedgeEnabled)
doc, err = bsoncore.AppendDocumentEnd(doc, hedgeIdx)
if err != nil {
- return nil, fmt.Errorf("error creating hedge document: %v", err)
+ return nil, fmt.Errorf("error creating hedge document: %w", err)
}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go
index ac78c12045..13035abc0f 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go
@@ -337,7 +337,10 @@ func (c *connection) cancellationListenerCallback() {
func (c *connection) writeWireMessage(ctx context.Context, wm []byte) error {
var err error
if atomic.LoadInt64(&c.state) != connConnected {
- return ConnectionError{ConnectionID: c.id, message: "connection is closed"}
+ return ConnectionError{
+ ConnectionID: c.id,
+ message: "connection is closed",
+ }
}
var deadline time.Time
@@ -388,7 +391,10 @@ func (c *connection) write(ctx context.Context, wm []byte) (err error) {
// readWireMessage reads a wiremessage from the connection. The dst parameter will be overwritten.
func (c *connection) readWireMessage(ctx context.Context) ([]byte, error) {
if atomic.LoadInt64(&c.state) != connConnected {
- return nil, ConnectionError{ConnectionID: c.id, message: "connection is closed"}
+ return nil, ConnectionError{
+ ConnectionID: c.id,
+ message: "connection is closed",
+ }
}
var deadline time.Time
@@ -411,7 +417,7 @@ func (c *connection) readWireMessage(ctx context.Context) ([]byte, error) {
// We closeConnection the connection because we don't know if there are other bytes left to read.
c.close()
message := errMsg
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
message = "socket was unexpectedly closed"
}
return nil, ConnectionError{
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go
index 7ce41864e6..a6630aae76 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go
@@ -8,6 +8,7 @@ package topology
import (
"context"
+ "errors"
"fmt"
"time"
@@ -86,9 +87,9 @@ type pinnedConnections struct {
// Error implements the error interface.
func (w WaitQueueTimeoutError) Error() string {
errorMsg := "timed out while checking out a connection from connection pool"
- switch w.Wrapped {
- case nil:
- case context.Canceled:
+ switch {
+ case w.Wrapped == nil:
+ case errors.Is(w.Wrapped, context.Canceled):
errorMsg = fmt.Sprintf(
"%s: %s",
"canceled while checking out a connection from connection pool",
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go
index 6e150344db..6ca23c071b 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go
@@ -375,6 +375,13 @@ func (p *pool) close(ctx context.Context) {
// Empty the idle connections stack and try to deliver ErrPoolClosed to any waiting wantConns
// from idleConnWait while holding the idleMu lock.
p.idleMu.Lock()
+ for _, conn := range p.idleConns {
+ _ = p.removeConnection(conn, reason{
+ loggerConn: logger.ReasonConnClosedPoolClosed,
+ event: event.ReasonPoolClosed,
+ }, nil)
+ _ = p.closeConnection(conn) // We don't care about errors while closing the connection.
+ }
p.idleConns = p.idleConns[:0]
for {
w := p.idleConnWait.popFront()
@@ -402,16 +409,6 @@ func (p *pool) close(ctx context.Context) {
}
p.createConnectionsCond.L.Unlock()
- // Now that we're not holding any locks, remove all of the connections we collected from the
- // pool.
- for _, conn := range conns {
- _ = p.removeConnection(conn, reason{
- loggerConn: logger.ReasonConnClosedPoolClosed,
- event: event.ReasonPoolClosed,
- }, nil)
- _ = p.closeConnection(conn) // We don't care about errors while closing the connection.
- }
-
if mustLogPoolMessage(p) {
logPoolMessage(p, logger.ConnectionPoolClosed)
}
@@ -422,6 +419,16 @@ func (p *pool) close(ctx context.Context) {
Address: p.address.String(),
})
}
+
+ // Now that we're not holding any locks, remove all of the connections we collected from the
+ // pool.
+ for _, conn := range conns {
+ _ = p.removeConnection(conn, reason{
+ loggerConn: logger.ReasonConnClosedPoolClosed,
+ event: event.ReasonPoolClosed,
+ }, nil)
+ _ = p.closeConnection(conn) // We don't care about errors while closing the connection.
+ }
}
func (p *pool) pinConnectionToCursor() {
@@ -782,20 +789,16 @@ func (p *pool) checkInNoEvent(conn *connection) error {
// connection should never be perished due to max idle time.
conn.bumpIdleDeadline()
- if reason, perished := connectionPerished(conn); perished {
- _ = p.removeConnection(conn, reason, nil)
- go func() {
- _ = p.closeConnection(conn)
- }()
- return nil
- }
-
- if conn.pool.getState() == poolClosed {
- _ = p.removeConnection(conn, reason{
+ r, perished := connectionPerished(conn)
+ if !perished && conn.pool.getState() == poolClosed {
+ perished = true
+ r = reason{
loggerConn: logger.ReasonConnClosedPoolClosed,
event: event.ReasonPoolClosed,
- }, nil)
-
+ }
+ }
+ if perished {
+ _ = p.removeConnection(conn, r, nil)
go func() {
_ = p.closeConnection(conn)
}()
@@ -825,12 +828,37 @@ func (p *pool) checkInNoEvent(conn *connection) error {
return nil
}
+// clear calls clearImpl internally with a false interruptAllConnections value.
+func (p *pool) clear(err error, serviceID *primitive.ObjectID) {
+ p.clearImpl(err, serviceID, false)
+}
+
+// clearAll does same as the "clear" method but interrupts all connections.
+func (p *pool) clearAll(err error, serviceID *primitive.ObjectID) {
+ p.clearImpl(err, serviceID, true)
+}
+
+// interruptConnections interrupts the input connections.
+func (p *pool) interruptConnections(conns []*connection) {
+ for _, conn := range conns {
+ _ = p.removeConnection(conn, reason{
+ loggerConn: logger.ReasonConnClosedStale,
+ event: event.ReasonStale,
+ }, nil)
+ go func(c *connection) {
+ _ = p.closeConnection(c)
+ }(conn)
+ }
+}
+
// clear marks all connections as stale by incrementing the generation number, stops all background
// goroutines, removes all requests from idleConnWait and newConnWait, and sets the pool state to
// "paused". If serviceID is nil, clear marks all connections as stale. If serviceID is not nil,
// clear marks only connections associated with the given serviceID stale (for use in load balancer
// mode).
-func (p *pool) clear(err error, serviceID *primitive.ObjectID) {
+// If interruptAllConnections is true, this function calls interruptConnections to interrupt all
+// non-idle connections.
+func (p *pool) clearImpl(err error, serviceID *primitive.ObjectID, interruptAllConnections bool) {
if p.getState() == poolClosed {
return
}
@@ -854,7 +882,51 @@ func (p *pool) clear(err error, serviceID *primitive.ObjectID) {
}
p.lastClearErr = err
p.stateMu.Unlock()
+ }
+
+ if mustLogPoolMessage(p) {
+ keysAndValues := logger.KeyValues{
+ logger.KeyServiceID, serviceID,
+ }
+
+ logPoolMessage(p, logger.ConnectionPoolCleared, keysAndValues...)
+ }
+
+ if sendEvent && p.monitor != nil {
+ event := &event.PoolEvent{
+ Type: event.PoolCleared,
+ Address: p.address.String(),
+ ServiceID: serviceID,
+ Interruption: interruptAllConnections,
+ Error: err,
+ }
+ p.monitor.Event(event)
+ }
+
+ p.removePerishedConns()
+ if interruptAllConnections {
+ p.createConnectionsCond.L.Lock()
+ p.idleMu.Lock()
+
+ idleConns := make(map[*connection]bool, len(p.idleConns))
+ for _, idle := range p.idleConns {
+ idleConns[idle] = true
+ }
+
+ conns := make([]*connection, 0, len(p.conns))
+ for _, conn := range p.conns {
+ if _, ok := idleConns[conn]; !ok && p.stale(conn) {
+ conns = append(conns, conn)
+ }
+ }
+
+ p.idleMu.Unlock()
+ p.createConnectionsCond.L.Unlock()
+
+ p.interruptConnections(conns)
+ }
+ if serviceID == nil {
pcErr := poolClearedError{err: err, address: p.address}
// Clear the idle connections wait queue.
@@ -881,23 +953,6 @@ func (p *pool) clear(err error, serviceID *primitive.ObjectID) {
}
p.createConnectionsCond.L.Unlock()
}
-
- if mustLogPoolMessage(p) {
- keysAndValues := logger.KeyValues{
- logger.KeyServiceID, serviceID,
- }
-
- logPoolMessage(p, logger.ConnectionPoolCleared, keysAndValues...)
- }
-
- if sendEvent && p.monitor != nil {
- p.monitor.Event(&event.PoolEvent{
- Type: event.PoolCleared,
- Address: p.address.String(),
- ServiceID: serviceID,
- Error: err,
- })
- }
}
// getOrQueueForIdleConn attempts to deliver an idle connection to the given wantConn. If there is
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool_generation_counter.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool_generation_counter.go
index 47fac2f618..dd10c0ce7a 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool_generation_counter.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool_generation_counter.go
@@ -112,25 +112,21 @@ func (p *poolGenerationMap) stale(serviceIDPtr *primitive.ObjectID, knownGenerat
return true
}
- serviceID := getServiceID(serviceIDPtr)
- p.Lock()
- defer p.Unlock()
-
- if stats, ok := p.generationMap[serviceID]; ok {
- return knownGeneration < stats.generation
+ if generation, ok := p.getGeneration(serviceIDPtr); ok {
+ return knownGeneration < generation
}
return false
}
-func (p *poolGenerationMap) getGeneration(serviceIDPtr *primitive.ObjectID) uint64 {
+func (p *poolGenerationMap) getGeneration(serviceIDPtr *primitive.ObjectID) (uint64, bool) {
serviceID := getServiceID(serviceIDPtr)
p.Lock()
defer p.Unlock()
if stats, ok := p.generationMap[serviceID]; ok {
- return stats.generation
+ return stats.generation, true
}
- return 0
+ return 0, false
}
func (p *poolGenerationMap) getNumConns(serviceIDPtr *primitive.ObjectID) uint64 {
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/rtt_monitor.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/rtt_monitor.go
index 0934beed89..3dd031f2ea 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/rtt_monitor.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/rtt_monitor.go
@@ -267,7 +267,7 @@ func percentile(perc float64, samples []time.Duration, minSamples int) time.Dura
p, err := stats.Percentile(floatSamples, perc)
if err != nil {
- panic(fmt.Errorf("x/mongo/driver/topology: error calculating %f percentile RTT: %v for samples:\n%v", perc, err, floatSamples))
+ panic(fmt.Errorf("x/mongo/driver/topology: error calculating %f percentile RTT: %w for samples:\n%v", perc, err, floatSamples))
}
return time.Duration(p)
}
@@ -318,7 +318,7 @@ func (r *rttMonitor) Stats() string {
var err error
stdDev, err = stats.StandardDeviation(floatSamples)
if err != nil {
- panic(fmt.Errorf("x/mongo/driver/topology: error calculating standard deviation RTT: %v for samples:\n%v", err, floatSamples))
+ panic(fmt.Errorf("x/mongo/driver/topology: error calculating standard deviation RTT: %w for samples:\n%v", err, floatSamples))
}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go
index 1a9ee28241..f4c6d744aa 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go
@@ -15,6 +15,7 @@ import (
"sync/atomic"
"time"
+ "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/internal/driverutil"
@@ -333,7 +334,7 @@ func (s *Server) ProcessHandshakeError(err error, startingGenerationNumber uint6
return
}
// Ignore the error if the connection is stale.
- if startingGenerationNumber < s.pool.generation.getGeneration(serviceID) {
+ if generation, _ := s.pool.generation.getGeneration(serviceID); startingGenerationNumber < generation {
return
}
@@ -415,8 +416,8 @@ func (s *Server) RequestImmediateCheck() {
// (error, true) if the error is a WriteConcernError and the falls under the requirements for SDAM error
// handling and (nil, false) otherwise.
func getWriteConcernErrorForProcessing(err error) (*driver.WriteConcernError, bool) {
- writeCmdErr, ok := err.(driver.WriteCommandError)
- if !ok {
+ var writeCmdErr driver.WriteCommandError
+ if !errors.As(err, &writeCmdErr) {
return nil, false
}
@@ -549,9 +550,7 @@ func (s *Server) update() {
checkNow := s.checkNow
done := s.done
- defer func() {
- _ = recover()
- }()
+ defer logUnexpectedFailure(s.cfg.logger, "Encountered unexpected failure updating server")
closeServer := func() {
s.subLock.Lock()
@@ -603,7 +602,7 @@ func (s *Server) update() {
// Perform the next check.
desc, err := s.check()
- if err == errCheckCancelled {
+ if errors.Is(err, errCheckCancelled) {
if atomic.LoadInt64(&s.state) != serverConnected {
continue
}
@@ -640,7 +639,11 @@ func (s *Server) update() {
// Clear the pool once the description has been updated to Unknown. Pass in a nil service ID to clear
// because the monitoring routine only runs for non-load balanced deployments in which servers don't return
// IDs.
- s.pool.clear(err, nil)
+ if timeoutCnt > 0 {
+ s.pool.clearAll(err, nil)
+ } else {
+ s.pool.clear(err, nil)
+ }
}
// We're either not handling a timeout error, or we just handled the 2nd consecutive
// timeout error. In either case, reset the timeout count to 0 and return false to
@@ -683,10 +686,7 @@ func (s *Server) updateDescription(desc description.Server) {
return
}
- defer func() {
- // ¯\_(ツ)_/¯
- _ = recover()
- }()
+ defer logUnexpectedFailure(s.cfg.logger, "Encountered unexpected failure updating server description")
// Anytime we update the server description to something other than "unknown", set the pool to
// "ready". Do this before updating the description so that connections can be checked out as
@@ -1060,10 +1060,24 @@ func (s *Server) publishServerHeartbeatSucceededEvent(connectionID string,
}
if mustLogServerMessage(s) {
- logServerMessage(s, logger.TopologyServerHeartbeatStarted,
+ descRaw, _ := bson.Marshal(struct {
+ description.Server `bson:",inline"`
+ Ok int32
+ }{
+ Server: desc,
+ Ok: func() int32 {
+ if desc.LastError != nil {
+ return 0
+ }
+
+ return 1
+ }(),
+ })
+
+ logServerMessage(s, logger.TopologyServerHeartbeatSucceeded,
logger.KeyAwaited, await,
logger.KeyDurationMS, duration.Milliseconds(),
- logger.KeyReply, desc)
+ logger.KeyReply, bson.Raw(descRaw).String())
}
}
diff --git a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go
index bbffbd1da7..3dbbcfb860 100644
--- a/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go
+++ b/backend/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go
@@ -15,7 +15,6 @@ import (
"errors"
"fmt"
"net"
- "net/url"
"strconv"
"strings"
"sync"
@@ -30,6 +29,7 @@ import (
"go.mongodb.org/mongo-driver/mongo/description"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/x/mongo/driver"
+ "go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
"go.mongodb.org/mongo-driver/x/mongo/driver/dns"
)
@@ -87,6 +87,8 @@ type Topology struct {
rescanSRVInterval time.Duration
pollHeartbeatTime atomic.Value // holds a bool
+ hosts []string
+
updateCallback updateTopologyCallback
fsm *fsm
@@ -153,7 +155,12 @@ func New(cfg *Config) (*Topology, error) {
}
if t.cfg.URI != "" {
- t.pollingRequired = strings.HasPrefix(t.cfg.URI, "mongodb+srv://") && !t.cfg.LoadBalanced
+ connStr, err := connstring.Parse(t.cfg.URI)
+ if err != nil {
+ return nil, err
+ }
+ t.pollingRequired = (connStr.Scheme == connstring.SchemeMongoDBSRV) && !t.cfg.LoadBalanced
+ t.hosts = connStr.RawHosts
}
t.publishTopologyOpeningEvent()
@@ -269,6 +276,32 @@ func logServerSelectionFailed(
logger.KeyFailure, err.Error())
}
+// logUnexpectedFailure is a defer-recover function for logging unexpected
+// failures encountered while maintaining a topology.
+//
+// Most topology maintenance actions, such as updating a server, should not take
+// down a client's application. This function provides a best-effort to log
+// unexpected failures. If the logger passed to this function is nil, then the
+// recovery will be silent.
+func logUnexpectedFailure(log *logger.Logger, msg string, callbacks ...func()) {
+ r := recover()
+ if r == nil {
+ return
+ }
+
+ defer func() {
+ for _, clbk := range callbacks {
+ clbk()
+ }
+ }()
+
+ if log == nil {
+ return
+ }
+
+ log.Print(logger.LevelInfo, logger.ComponentTopology, fmt.Sprintf("%s: %v", msg, r))
+}
+
// Connect initializes a Topology and starts the monitoring process. This function
// must be called to properly monitor the topology.
func (t *Topology) Connect() error {
@@ -351,26 +384,21 @@ func (t *Topology) Connect() error {
}
t.serversLock.Unlock()
- uri, err := url.Parse(t.cfg.URI)
- if err != nil {
- return err
- }
- parsedHosts := strings.Split(uri.Host, ",")
if mustLogTopologyMessage(t, logger.LevelInfo) {
- logTopologyThirdPartyUsage(t, parsedHosts)
+ logTopologyThirdPartyUsage(t, t.hosts)
}
if t.pollingRequired {
// sanity check before passing the hostname to resolver
- if len(parsedHosts) != 1 {
+ if len(t.hosts) != 1 {
return fmt.Errorf("URI with SRV must include one and only one hostname")
}
- _, _, err = net.SplitHostPort(uri.Host)
+ _, _, err = net.SplitHostPort(t.hosts[0])
if err == nil {
// we were able to successfully extract a port from the host,
// but should not be able to when using SRV
return fmt.Errorf("URI with srv must not include a port number")
}
- go t.pollSRVRecords(uri.Host)
+ go t.pollSRVRecords(t.hosts[0])
t.pollingwg.Add(1)
}
@@ -546,7 +574,7 @@ func (t *Topology) SelectServer(ctx context.Context, ss description.ServerSelect
return nil, err
}
- defer t.Unsubscribe(sub)
+ defer func() { _ = t.Unsubscribe(sub) }()
}
suitable, selectErr = t.selectServerFromSubscription(ctx, sub.Updates, selectionState)
@@ -768,12 +796,11 @@ func (t *Topology) pollSRVRecords(hosts string) {
defer pollTicker.Stop()
t.pollHeartbeatTime.Store(false)
var doneOnce bool
- defer func() {
- // ¯\_(ツ)_/¯
- if r := recover(); r != nil && !doneOnce {
+ defer logUnexpectedFailure(t.cfg.logger, "Encountered unexpected failure polling SRV records", func() {
+ if !doneOnce {
<-t.pollingDone
}
- }()
+ })
for {
select {
diff --git a/backend/vendor/golang.org/x/crypto/ocsp/ocsp.go b/backend/vendor/golang.org/x/crypto/ocsp/ocsp.go
index 4269ed113b..bf2259537d 100644
--- a/backend/vendor/golang.org/x/crypto/ocsp/ocsp.go
+++ b/backend/vendor/golang.org/x/crypto/ocsp/ocsp.go
@@ -279,21 +279,22 @@ func getOIDFromHashAlgorithm(target crypto.Hash) asn1.ObjectIdentifier {
// This is the exposed reflection of the internal OCSP structures.
-// The status values that can be expressed in OCSP. See RFC 6960.
+// The status values that can be expressed in OCSP. See RFC 6960.
+// These are used for the Response.Status field.
const (
// Good means that the certificate is valid.
- Good = iota
+ Good = 0
// Revoked means that the certificate has been deliberately revoked.
- Revoked
+ Revoked = 1
// Unknown means that the OCSP responder doesn't know about the certificate.
- Unknown
+ Unknown = 2
// ServerFailed is unused and was never used (see
// https://go-review.googlesource.com/#/c/18944). ParseResponse will
// return a ResponseError when an error response is parsed.
- ServerFailed
+ ServerFailed = 3
)
-// The enumerated reasons for revoking a certificate. See RFC 5280.
+// The enumerated reasons for revoking a certificate. See RFC 5280.
const (
Unspecified = 0
KeyCompromise = 1
diff --git a/backend/vendor/golang.org/x/oauth2/google/default.go b/backend/vendor/golang.org/x/oauth2/google/default.go
index 02ccd08a77..18f369851b 100644
--- a/backend/vendor/golang.org/x/oauth2/google/default.go
+++ b/backend/vendor/golang.org/x/oauth2/google/default.go
@@ -22,7 +22,7 @@ import (
const (
adcSetupURL = "https://cloud.google.com/docs/authentication/external/set-up-adc"
- universeDomainDefault = "googleapis.com"
+ defaultUniverseDomain = "googleapis.com"
)
// Credentials holds Google credentials, including "Application Default Credentials".
@@ -58,7 +58,7 @@ type Credentials struct {
// See also [The attached service account](https://cloud.google.com/docs/authentication/application-default-credentials#attached-sa).
func (c *Credentials) UniverseDomain() string {
if c.universeDomain == "" {
- return universeDomainDefault
+ return defaultUniverseDomain
}
return c.universeDomain
}
@@ -89,7 +89,7 @@ func (c *Credentials) GetUniverseDomain() (string, error) {
// computeUniverseDomain that did not set universeDomain, set the default
// universe domain.
if c.universeDomain == "" {
- c.universeDomain = universeDomainDefault
+ c.universeDomain = defaultUniverseDomain
}
return c.universeDomain, nil
}
@@ -103,7 +103,7 @@ func (c *Credentials) computeUniverseDomain() error {
if err != nil {
if _, ok := err.(metadata.NotDefinedError); ok {
// http.StatusNotFound (404)
- c.universeDomain = universeDomainDefault
+ c.universeDomain = defaultUniverseDomain
return nil
} else {
return err
@@ -287,7 +287,7 @@ func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params
}
// Authorized user credentials are only supported in the googleapis.com universe.
if f.Type == userCredentialsKey {
- universeDomain = universeDomainDefault
+ universeDomain = defaultUniverseDomain
}
ts, err := f.tokenSource(ctx, params)
diff --git a/backend/vendor/golang.org/x/oauth2/google/doc.go b/backend/vendor/golang.org/x/oauth2/google/doc.go
index 03c42c6f87..830d268c1e 100644
--- a/backend/vendor/golang.org/x/oauth2/google/doc.go
+++ b/backend/vendor/golang.org/x/oauth2/google/doc.go
@@ -22,91 +22,9 @@
// the other by JWTConfigFromJSON. The returned Config can be used to obtain a TokenSource or
// create an http.Client.
//
-// # Workload Identity Federation
+// # Workload and Workforce Identity Federation
//
-// Using workload identity federation, your application can access Google Cloud
-// resources from Amazon Web Services (AWS), Microsoft Azure or any identity
-// provider that supports OpenID Connect (OIDC) or SAML 2.0.
-// Traditionally, applications running outside Google Cloud have used service
-// account keys to access Google Cloud resources. Using identity federation,
-// you can allow your workload to impersonate a service account.
-// This lets you access Google Cloud resources directly, eliminating the
-// maintenance and security burden associated with service account keys.
-//
-// Follow the detailed instructions on how to configure Workload Identity Federation
-// in various platforms:
-//
-// Amazon Web Services (AWS): https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#aws
-// Microsoft Azure: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#azure
-// OIDC identity provider: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#oidc
-// SAML 2.0 identity provider: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#saml
-//
-// For OIDC and SAML providers, the library can retrieve tokens in three ways:
-// from a local file location (file-sourced credentials), from a server
-// (URL-sourced credentials), or from a local executable (executable-sourced
-// credentials).
-// For file-sourced credentials, a background process needs to be continuously
-// refreshing the file location with a new OIDC/SAML token prior to expiration.
-// For tokens with one hour lifetimes, the token needs to be updated in the file
-// every hour. The token can be stored directly as plain text or in JSON format.
-// For URL-sourced credentials, a local server needs to host a GET endpoint to
-// return the OIDC/SAML token. The response can be in plain text or JSON.
-// Additional required request headers can also be specified.
-// For executable-sourced credentials, an application needs to be available to
-// output the OIDC/SAML token and other information in a JSON format.
-// For more information on how these work (and how to implement
-// executable-sourced credentials), please check out:
-// https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#create_a_credential_configuration
-//
-// Note that this library does not perform any validation on the token_url, token_info_url,
-// or service_account_impersonation_url fields of the credential configuration.
-// It is not recommended to use a credential configuration that you did not generate with
-// the gcloud CLI unless you verify that the URL fields point to a googleapis.com domain.
-//
-// # Workforce Identity Federation
-//
-// Workforce identity federation lets you use an external identity provider (IdP) to
-// authenticate and authorize a workforce—a group of users, such as employees, partners,
-// and contractors—using IAM, so that the users can access Google Cloud services.
-// Workforce identity federation extends Google Cloud's identity capabilities to support
-// syncless, attribute-based single sign on.
-//
-// With workforce identity federation, your workforce can access Google Cloud resources
-// using an external identity provider (IdP) that supports OpenID Connect (OIDC) or
-// SAML 2.0 such as Azure Active Directory (Azure AD), Active Directory Federation
-// Services (AD FS), Okta, and others.
-//
-// Follow the detailed instructions on how to configure Workload Identity Federation
-// in various platforms:
-//
-// Azure AD: https://cloud.google.com/iam/docs/workforce-sign-in-azure-ad
-// Okta: https://cloud.google.com/iam/docs/workforce-sign-in-okta
-// OIDC identity provider: https://cloud.google.com/iam/docs/configuring-workforce-identity-federation#oidc
-// SAML 2.0 identity provider: https://cloud.google.com/iam/docs/configuring-workforce-identity-federation#saml
-//
-// For workforce identity federation, the library can retrieve tokens in three ways:
-// from a local file location (file-sourced credentials), from a server
-// (URL-sourced credentials), or from a local executable (executable-sourced
-// credentials).
-// For file-sourced credentials, a background process needs to be continuously
-// refreshing the file location with a new OIDC/SAML token prior to expiration.
-// For tokens with one hour lifetimes, the token needs to be updated in the file
-// every hour. The token can be stored directly as plain text or in JSON format.
-// For URL-sourced credentials, a local server needs to host a GET endpoint to
-// return the OIDC/SAML token. The response can be in plain text or JSON.
-// Additional required request headers can also be specified.
-// For executable-sourced credentials, an application needs to be available to
-// output the OIDC/SAML token and other information in a JSON format.
-// For more information on how these work (and how to implement
-// executable-sourced credentials), please check out:
-// https://cloud.google.com/iam/docs/workforce-obtaining-short-lived-credentials#generate_a_configuration_file_for_non-interactive_sign-in
-//
-// # Security considerations
-//
-// Note that this library does not perform any validation on the token_url, token_info_url,
-// or service_account_impersonation_url fields of the credential configuration.
-// It is not recommended to use a credential configuration that you did not generate with
-// the gcloud CLI unless you verify that the URL fields point to a googleapis.com domain.
+// For information on how to use Workload and Workforce Identity Federation, see [golang.org/x/oauth2/google/externalaccount].
//
// # Credentials
//
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/aws.go
similarity index 77%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go
rename to backend/vendor/golang.org/x/oauth2/google/externalaccount/aws.go
index bd4efd19ba..da61d0c0e8 100644
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/aws.go
@@ -26,22 +26,28 @@ import (
"golang.org/x/oauth2"
)
-type awsSecurityCredentials struct {
- AccessKeyID string `json:"AccessKeyID"`
+// AwsSecurityCredentials models AWS security credentials.
+type AwsSecurityCredentials struct {
+ // AccessKeyId is the AWS Access Key ID - Required.
+ AccessKeyID string `json:"AccessKeyID"`
+ // SecretAccessKey is the AWS Secret Access Key - Required.
SecretAccessKey string `json:"SecretAccessKey"`
- SecurityToken string `json:"Token"`
+ // SessionToken is the AWS Session token. This should be provided for temporary AWS security credentials - Optional.
+ SessionToken string `json:"Token"`
}
// awsRequestSigner is a utility class to sign http requests using a AWS V4 signature.
type awsRequestSigner struct {
RegionName string
- AwsSecurityCredentials awsSecurityCredentials
+ AwsSecurityCredentials *AwsSecurityCredentials
}
// getenv aliases os.Getenv for testing
var getenv = os.Getenv
const (
+ defaultRegionalCredentialVerificationUrl = "https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15"
+
// AWS Signature Version 4 signing algorithm identifier.
awsAlgorithm = "AWS4-HMAC-SHA256"
@@ -197,8 +203,8 @@ func (rs *awsRequestSigner) SignRequest(req *http.Request) error {
signedRequest.Header.Add("host", requestHost(req))
- if rs.AwsSecurityCredentials.SecurityToken != "" {
- signedRequest.Header.Add(awsSecurityTokenHeader, rs.AwsSecurityCredentials.SecurityToken)
+ if rs.AwsSecurityCredentials.SessionToken != "" {
+ signedRequest.Header.Add(awsSecurityTokenHeader, rs.AwsSecurityCredentials.SessionToken)
}
if signedRequest.Header.Get("date") == "" {
@@ -251,16 +257,18 @@ func (rs *awsRequestSigner) generateAuthentication(req *http.Request, timestamp
}
type awsCredentialSource struct {
- EnvironmentID string
- RegionURL string
- RegionalCredVerificationURL string
- CredVerificationURL string
- IMDSv2SessionTokenURL string
- TargetResource string
- requestSigner *awsRequestSigner
- region string
- ctx context.Context
- client *http.Client
+ environmentID string
+ regionURL string
+ regionalCredVerificationURL string
+ credVerificationURL string
+ imdsv2SessionTokenURL string
+ targetResource string
+ requestSigner *awsRequestSigner
+ region string
+ ctx context.Context
+ client *http.Client
+ awsSecurityCredentialsSupplier AwsSecurityCredentialsSupplier
+ supplierOptions SupplierOptions
}
type awsRequestHeader struct {
@@ -292,18 +300,25 @@ func canRetrieveSecurityCredentialFromEnvironment() bool {
return getenv(awsAccessKeyId) != "" && getenv(awsSecretAccessKey) != ""
}
-func shouldUseMetadataServer() bool {
- return !canRetrieveRegionFromEnvironment() || !canRetrieveSecurityCredentialFromEnvironment()
+func (cs awsCredentialSource) shouldUseMetadataServer() bool {
+ return cs.awsSecurityCredentialsSupplier == nil && (!canRetrieveRegionFromEnvironment() || !canRetrieveSecurityCredentialFromEnvironment())
}
func (cs awsCredentialSource) credentialSourceType() string {
+ if cs.awsSecurityCredentialsSupplier != nil {
+ return "programmatic"
+ }
return "aws"
}
func (cs awsCredentialSource) subjectToken() (string, error) {
+ // Set Defaults
+ if cs.regionalCredVerificationURL == "" {
+ cs.regionalCredVerificationURL = defaultRegionalCredentialVerificationUrl
+ }
if cs.requestSigner == nil {
headers := make(map[string]string)
- if shouldUseMetadataServer() {
+ if cs.shouldUseMetadataServer() {
awsSessionToken, err := cs.getAWSSessionToken()
if err != nil {
return "", err
@@ -318,8 +333,8 @@ func (cs awsCredentialSource) subjectToken() (string, error) {
if err != nil {
return "", err
}
-
- if cs.region, err = cs.getRegion(headers); err != nil {
+ cs.region, err = cs.getRegion(headers)
+ if err != nil {
return "", err
}
@@ -331,7 +346,7 @@ func (cs awsCredentialSource) subjectToken() (string, error) {
// Generate the signed request to AWS STS GetCallerIdentity API.
// Use the required regional endpoint. Otherwise, the request will fail.
- req, err := http.NewRequest("POST", strings.Replace(cs.RegionalCredVerificationURL, "{region}", cs.region, 1), nil)
+ req, err := http.NewRequest("POST", strings.Replace(cs.regionalCredVerificationURL, "{region}", cs.region, 1), nil)
if err != nil {
return "", err
}
@@ -339,8 +354,8 @@ func (cs awsCredentialSource) subjectToken() (string, error) {
// provider, with or without the HTTPS prefix.
// Including this header as part of the signature is recommended to
// ensure data integrity.
- if cs.TargetResource != "" {
- req.Header.Add("x-goog-cloud-target-resource", cs.TargetResource)
+ if cs.targetResource != "" {
+ req.Header.Add("x-goog-cloud-target-resource", cs.targetResource)
}
cs.requestSigner.SignRequest(req)
@@ -387,11 +402,11 @@ func (cs awsCredentialSource) subjectToken() (string, error) {
}
func (cs *awsCredentialSource) getAWSSessionToken() (string, error) {
- if cs.IMDSv2SessionTokenURL == "" {
+ if cs.imdsv2SessionTokenURL == "" {
return "", nil
}
- req, err := http.NewRequest("PUT", cs.IMDSv2SessionTokenURL, nil)
+ req, err := http.NewRequest("PUT", cs.imdsv2SessionTokenURL, nil)
if err != nil {
return "", err
}
@@ -410,25 +425,29 @@ func (cs *awsCredentialSource) getAWSSessionToken() (string, error) {
}
if resp.StatusCode != 200 {
- return "", fmt.Errorf("oauth2/google: unable to retrieve AWS session token - %s", string(respBody))
+ return "", fmt.Errorf("oauth2/google/externalaccount: unable to retrieve AWS session token - %s", string(respBody))
}
return string(respBody), nil
}
func (cs *awsCredentialSource) getRegion(headers map[string]string) (string, error) {
+ if cs.awsSecurityCredentialsSupplier != nil {
+ return cs.awsSecurityCredentialsSupplier.AwsRegion(cs.ctx, cs.supplierOptions)
+ }
if canRetrieveRegionFromEnvironment() {
if envAwsRegion := getenv(awsRegion); envAwsRegion != "" {
+ cs.region = envAwsRegion
return envAwsRegion, nil
}
return getenv("AWS_DEFAULT_REGION"), nil
}
- if cs.RegionURL == "" {
- return "", errors.New("oauth2/google: unable to determine AWS region")
+ if cs.regionURL == "" {
+ return "", errors.New("oauth2/google/externalaccount: unable to determine AWS region")
}
- req, err := http.NewRequest("GET", cs.RegionURL, nil)
+ req, err := http.NewRequest("GET", cs.regionURL, nil)
if err != nil {
return "", err
}
@@ -449,7 +468,7 @@ func (cs *awsCredentialSource) getRegion(headers map[string]string) (string, err
}
if resp.StatusCode != 200 {
- return "", fmt.Errorf("oauth2/google: unable to retrieve AWS region - %s", string(respBody))
+ return "", fmt.Errorf("oauth2/google/externalaccount: unable to retrieve AWS region - %s", string(respBody))
}
// This endpoint will return the region in format: us-east-2b.
@@ -461,12 +480,15 @@ func (cs *awsCredentialSource) getRegion(headers map[string]string) (string, err
return string(respBody[:respBodyEnd]), nil
}
-func (cs *awsCredentialSource) getSecurityCredentials(headers map[string]string) (result awsSecurityCredentials, err error) {
+func (cs *awsCredentialSource) getSecurityCredentials(headers map[string]string) (result *AwsSecurityCredentials, err error) {
+ if cs.awsSecurityCredentialsSupplier != nil {
+ return cs.awsSecurityCredentialsSupplier.AwsSecurityCredentials(cs.ctx, cs.supplierOptions)
+ }
if canRetrieveSecurityCredentialFromEnvironment() {
- return awsSecurityCredentials{
+ return &AwsSecurityCredentials{
AccessKeyID: getenv(awsAccessKeyId),
SecretAccessKey: getenv(awsSecretAccessKey),
- SecurityToken: getenv(awsSessionToken),
+ SessionToken: getenv(awsSessionToken),
}, nil
}
@@ -481,20 +503,20 @@ func (cs *awsCredentialSource) getSecurityCredentials(headers map[string]string)
}
if credentials.AccessKeyID == "" {
- return result, errors.New("oauth2/google: missing AccessKeyId credential")
+ return result, errors.New("oauth2/google/externalaccount: missing AccessKeyId credential")
}
if credentials.SecretAccessKey == "" {
- return result, errors.New("oauth2/google: missing SecretAccessKey credential")
+ return result, errors.New("oauth2/google/externalaccount: missing SecretAccessKey credential")
}
- return credentials, nil
+ return &credentials, nil
}
-func (cs *awsCredentialSource) getMetadataSecurityCredentials(roleName string, headers map[string]string) (awsSecurityCredentials, error) {
- var result awsSecurityCredentials
+func (cs *awsCredentialSource) getMetadataSecurityCredentials(roleName string, headers map[string]string) (AwsSecurityCredentials, error) {
+ var result AwsSecurityCredentials
- req, err := http.NewRequest("GET", fmt.Sprintf("%s/%s", cs.CredVerificationURL, roleName), nil)
+ req, err := http.NewRequest("GET", fmt.Sprintf("%s/%s", cs.credVerificationURL, roleName), nil)
if err != nil {
return result, err
}
@@ -516,7 +538,7 @@ func (cs *awsCredentialSource) getMetadataSecurityCredentials(roleName string, h
}
if resp.StatusCode != 200 {
- return result, fmt.Errorf("oauth2/google: unable to retrieve AWS security credentials - %s", string(respBody))
+ return result, fmt.Errorf("oauth2/google/externalaccount: unable to retrieve AWS security credentials - %s", string(respBody))
}
err = json.Unmarshal(respBody, &result)
@@ -524,11 +546,11 @@ func (cs *awsCredentialSource) getMetadataSecurityCredentials(roleName string, h
}
func (cs *awsCredentialSource) getMetadataRoleName(headers map[string]string) (string, error) {
- if cs.CredVerificationURL == "" {
- return "", errors.New("oauth2/google: unable to determine the AWS metadata server security credentials endpoint")
+ if cs.credVerificationURL == "" {
+ return "", errors.New("oauth2/google/externalaccount: unable to determine the AWS metadata server security credentials endpoint")
}
- req, err := http.NewRequest("GET", cs.CredVerificationURL, nil)
+ req, err := http.NewRequest("GET", cs.credVerificationURL, nil)
if err != nil {
return "", err
}
@@ -549,7 +571,7 @@ func (cs *awsCredentialSource) getMetadataRoleName(headers map[string]string) (s
}
if resp.StatusCode != 200 {
- return "", fmt.Errorf("oauth2/google: unable to retrieve AWS role name - %s", string(respBody))
+ return "", fmt.Errorf("oauth2/google/externalaccount: unable to retrieve AWS role name - %s", string(respBody))
}
return string(respBody), nil
diff --git a/backend/vendor/golang.org/x/oauth2/google/externalaccount/basecredentials.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/basecredentials.go
new file mode 100644
index 0000000000..400aa0a072
--- /dev/null
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/basecredentials.go
@@ -0,0 +1,484 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+/*
+Package externalaccount provides support for creating workload identity
+federation and workforce identity federation token sources that can be
+used to access Google Cloud resources from external identity providers.
+
+# Workload Identity Federation
+
+Using workload identity federation, your application can access Google Cloud
+resources from Amazon Web Services (AWS), Microsoft Azure or any identity
+provider that supports OpenID Connect (OIDC) or SAML 2.0.
+Traditionally, applications running outside Google Cloud have used service
+account keys to access Google Cloud resources. Using identity federation,
+you can allow your workload to impersonate a service account.
+This lets you access Google Cloud resources directly, eliminating the
+maintenance and security burden associated with service account keys.
+
+Follow the detailed instructions on how to configure Workload Identity Federation
+in various platforms:
+
+Amazon Web Services (AWS): https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#aws
+Microsoft Azure: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#azure
+OIDC identity provider: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#oidc
+SAML 2.0 identity provider: https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#saml
+
+For OIDC and SAML providers, the library can retrieve tokens in fours ways:
+from a local file location (file-sourced credentials), from a server
+(URL-sourced credentials), from a local executable (executable-sourced
+credentials), or from a user defined function that returns an OIDC or SAML token.
+For file-sourced credentials, a background process needs to be continuously
+refreshing the file location with a new OIDC/SAML token prior to expiration.
+For tokens with one hour lifetimes, the token needs to be updated in the file
+every hour. The token can be stored directly as plain text or in JSON format.
+For URL-sourced credentials, a local server needs to host a GET endpoint to
+return the OIDC/SAML token. The response can be in plain text or JSON.
+Additional required request headers can also be specified.
+For executable-sourced credentials, an application needs to be available to
+output the OIDC/SAML token and other information in a JSON format.
+For more information on how these work (and how to implement
+executable-sourced credentials), please check out:
+https://cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#create_a_credential_configuration
+
+To use a custom function to supply the token, define a struct that implements the [SubjectTokenSupplier] interface for OIDC/SAML providers,
+or one that implements [AwsSecurityCredentialsSupplier] for AWS providers. This can then be used when building a [Config].
+The [golang.org/x/oauth2.TokenSource] created from the config using [NewTokenSource] can then be used to access Google
+Cloud resources. For instance, you can create a new client from the
+[cloud.google.com/go/storage] package and pass in option.WithTokenSource(yourTokenSource))
+
+Note that this library does not perform any validation on the token_url, token_info_url,
+or service_account_impersonation_url fields of the credential configuration.
+It is not recommended to use a credential configuration that you did not generate with
+the gcloud CLI unless you verify that the URL fields point to a googleapis.com domain.
+
+# Workforce Identity Federation
+
+Workforce identity federation lets you use an external identity provider (IdP) to
+authenticate and authorize a workforce—a group of users, such as employees, partners,
+and contractors—using IAM, so that the users can access Google Cloud services.
+Workforce identity federation extends Google Cloud's identity capabilities to support
+syncless, attribute-based single sign on.
+
+With workforce identity federation, your workforce can access Google Cloud resources
+using an external identity provider (IdP) that supports OpenID Connect (OIDC) or
+SAML 2.0 such as Azure Active Directory (Azure AD), Active Directory Federation
+Services (AD FS), Okta, and others.
+
+Follow the detailed instructions on how to configure Workload Identity Federation
+in various platforms:
+
+Azure AD: https://cloud.google.com/iam/docs/workforce-sign-in-azure-ad
+Okta: https://cloud.google.com/iam/docs/workforce-sign-in-okta
+OIDC identity provider: https://cloud.google.com/iam/docs/configuring-workforce-identity-federation#oidc
+SAML 2.0 identity provider: https://cloud.google.com/iam/docs/configuring-workforce-identity-federation#saml
+
+For workforce identity federation, the library can retrieve tokens in four ways:
+from a local file location (file-sourced credentials), from a server
+(URL-sourced credentials), from a local executable (executable-sourced
+credentials), or from a user supplied function that returns an OIDC or SAML token.
+For file-sourced credentials, a background process needs to be continuously
+refreshing the file location with a new OIDC/SAML token prior to expiration.
+For tokens with one hour lifetimes, the token needs to be updated in the file
+every hour. The token can be stored directly as plain text or in JSON format.
+For URL-sourced credentials, a local server needs to host a GET endpoint to
+return the OIDC/SAML token. The response can be in plain text or JSON.
+Additional required request headers can also be specified.
+For executable-sourced credentials, an application needs to be available to
+output the OIDC/SAML token and other information in a JSON format.
+For more information on how these work (and how to implement
+executable-sourced credentials), please check out:
+https://cloud.google.com/iam/docs/workforce-obtaining-short-lived-credentials#generate_a_configuration_file_for_non-interactive_sign-in
+
+To use a custom function to supply the token, define a struct that implements the [SubjectTokenSupplier] interface for OIDC/SAML providers.
+This can then be used when building a [Config].
+The [golang.org/x/oauth2.TokenSource] created from the config using [NewTokenSource] can then be used access Google
+Cloud resources. For instance, you can create a new client from the
+[cloud.google.com/go/storage] package and pass in option.WithTokenSource(yourTokenSource))
+
+# Security considerations
+
+Note that this library does not perform any validation on the token_url, token_info_url,
+or service_account_impersonation_url fields of the credential configuration.
+It is not recommended to use a credential configuration that you did not generate with
+the gcloud CLI unless you verify that the URL fields point to a googleapis.com domain.
+*/
+package externalaccount
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "regexp"
+ "strconv"
+ "strings"
+ "time"
+
+ "golang.org/x/oauth2"
+ "golang.org/x/oauth2/google/internal/impersonate"
+ "golang.org/x/oauth2/google/internal/stsexchange"
+)
+
+const (
+ universeDomainPlaceholder = "UNIVERSE_DOMAIN"
+ defaultTokenURL = "https://sts.UNIVERSE_DOMAIN/v1/token"
+ defaultUniverseDomain = "googleapis.com"
+)
+
+// now aliases time.Now for testing
+var now = func() time.Time {
+ return time.Now().UTC()
+}
+
+// Config stores the configuration for fetching tokens with external credentials.
+type Config struct {
+ // Audience is the Secure Token Service (STS) audience which contains the resource name for the workload
+ // identity pool or the workforce pool and the provider identifier in that pool. Required.
+ Audience string
+ // SubjectTokenType is the STS token type based on the Oauth2.0 token exchange spec.
+ // Expected values include:
+ // “urn:ietf:params:oauth:token-type:jwt”
+ // “urn:ietf:params:oauth:token-type:id-token”
+ // “urn:ietf:params:oauth:token-type:saml2”
+ // “urn:ietf:params:aws:token-type:aws4_request”
+ // Required.
+ SubjectTokenType string
+ // TokenURL is the STS token exchange endpoint. If not provided, will default to
+ // https://sts.UNIVERSE_DOMAIN/v1/token, with UNIVERSE_DOMAIN set to the
+ // default service domain googleapis.com unless UniverseDomain is set.
+ // Optional.
+ TokenURL string
+ // TokenInfoURL is the token_info endpoint used to retrieve the account related information (
+ // user attributes like account identifier, eg. email, username, uid, etc). This is
+ // needed for gCloud session account identification. Optional.
+ TokenInfoURL string
+ // ServiceAccountImpersonationURL is the URL for the service account impersonation request. This is only
+ // required for workload identity pools when APIs to be accessed have not integrated with UberMint. Optional.
+ ServiceAccountImpersonationURL string
+ // ServiceAccountImpersonationLifetimeSeconds is the number of seconds the service account impersonation
+ // token will be valid for. If not provided, it will default to 3600. Optional.
+ ServiceAccountImpersonationLifetimeSeconds int
+ // ClientSecret is currently only required if token_info endpoint also
+ // needs to be called with the generated GCP access token. When provided, STS will be
+ // called with additional basic authentication using ClientId as username and ClientSecret as password. Optional.
+ ClientSecret string
+ // ClientID is only required in conjunction with ClientSecret, as described above. Optional.
+ ClientID string
+ // CredentialSource contains the necessary information to retrieve the token itself, as well
+ // as some environmental information. One of SubjectTokenSupplier, AWSSecurityCredentialSupplier or
+ // CredentialSource must be provided. Optional.
+ CredentialSource *CredentialSource
+ // QuotaProjectID is injected by gCloud. If the value is non-empty, the Auth libraries
+ // will set the x-goog-user-project header which overrides the project associated with the credentials. Optional.
+ QuotaProjectID string
+ // Scopes contains the desired scopes for the returned access token. Optional.
+ Scopes []string
+ // WorkforcePoolUserProject is the workforce pool user project number when the credential
+ // corresponds to a workforce pool and not a workload identity pool.
+ // The underlying principal must still have serviceusage.services.use IAM
+ // permission to use the project for billing/quota. Optional.
+ WorkforcePoolUserProject string
+ // SubjectTokenSupplier is an optional token supplier for OIDC/SAML credentials.
+ // One of SubjectTokenSupplier, AWSSecurityCredentialSupplier or CredentialSource must be provided. Optional.
+ SubjectTokenSupplier SubjectTokenSupplier
+ // AwsSecurityCredentialsSupplier is an AWS Security Credential supplier for AWS credentials.
+ // One of SubjectTokenSupplier, AWSSecurityCredentialSupplier or CredentialSource must be provided. Optional.
+ AwsSecurityCredentialsSupplier AwsSecurityCredentialsSupplier
+ // UniverseDomain is the default service domain for a given Cloud universe.
+ // This value will be used in the default STS token URL. The default value
+ // is "googleapis.com". It will not be used if TokenURL is set. Optional.
+ UniverseDomain string
+}
+
+var (
+ validWorkforceAudiencePattern *regexp.Regexp = regexp.MustCompile(`//iam\.googleapis\.com/locations/[^/]+/workforcePools/`)
+)
+
+func validateWorkforceAudience(input string) bool {
+ return validWorkforceAudiencePattern.MatchString(input)
+}
+
+// NewTokenSource Returns an external account TokenSource using the provided external account config.
+func NewTokenSource(ctx context.Context, conf Config) (oauth2.TokenSource, error) {
+ if conf.Audience == "" {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: Audience must be set")
+ }
+ if conf.SubjectTokenType == "" {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: Subject token type must be set")
+ }
+ if conf.WorkforcePoolUserProject != "" {
+ valid := validateWorkforceAudience(conf.Audience)
+ if !valid {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: Workforce pool user project should not be set for non-workforce pool credentials")
+ }
+ }
+ count := 0
+ if conf.CredentialSource != nil {
+ count++
+ }
+ if conf.SubjectTokenSupplier != nil {
+ count++
+ }
+ if conf.AwsSecurityCredentialsSupplier != nil {
+ count++
+ }
+ if count == 0 {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: One of CredentialSource, SubjectTokenSupplier, or AwsSecurityCredentialsSupplier must be set")
+ }
+ if count > 1 {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: Only one of CredentialSource, SubjectTokenSupplier, or AwsSecurityCredentialsSupplier must be set")
+ }
+ return conf.tokenSource(ctx, "https")
+}
+
+// tokenSource is a private function that's directly called by some of the tests,
+// because the unit test URLs are mocked, and would otherwise fail the
+// validity check.
+func (c *Config) tokenSource(ctx context.Context, scheme string) (oauth2.TokenSource, error) {
+
+ ts := tokenSource{
+ ctx: ctx,
+ conf: c,
+ }
+ if c.ServiceAccountImpersonationURL == "" {
+ return oauth2.ReuseTokenSource(nil, ts), nil
+ }
+ scopes := c.Scopes
+ ts.conf.Scopes = []string{"https://www.googleapis.com/auth/cloud-platform"}
+ imp := impersonate.ImpersonateTokenSource{
+ Ctx: ctx,
+ URL: c.ServiceAccountImpersonationURL,
+ Scopes: scopes,
+ Ts: oauth2.ReuseTokenSource(nil, ts),
+ TokenLifetimeSeconds: c.ServiceAccountImpersonationLifetimeSeconds,
+ }
+ return oauth2.ReuseTokenSource(nil, imp), nil
+}
+
+// Subject token file types.
+const (
+ fileTypeText = "text"
+ fileTypeJSON = "json"
+)
+
+// Format contains information needed to retireve a subject token for URL or File sourced credentials.
+type Format struct {
+ // Type should be either "text" or "json". This determines whether the file or URL sourced credentials
+ // expect a simple text subject token or if the subject token will be contained in a JSON object.
+ // When not provided "text" type is assumed.
+ Type string `json:"type"`
+ // SubjectTokenFieldName is only required for JSON format. This is the field name that the credentials will check
+ // for the subject token in the file or URL response. This would be "access_token" for azure.
+ SubjectTokenFieldName string `json:"subject_token_field_name"`
+}
+
+// CredentialSource stores the information necessary to retrieve the credentials for the STS exchange.
+type CredentialSource struct {
+ // File is the location for file sourced credentials.
+ // One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
+ File string `json:"file"`
+
+ // Url is the URL to call for URL sourced credentials.
+ // One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
+ URL string `json:"url"`
+ // Headers are the headers to attach to the request for URL sourced credentials.
+ Headers map[string]string `json:"headers"`
+
+ // Executable is the configuration object for executable sourced credentials.
+ // One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
+ Executable *ExecutableConfig `json:"executable"`
+
+ // EnvironmentID is the EnvironmentID used for AWS sourced credentials. This should start with "AWS".
+ // One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
+ EnvironmentID string `json:"environment_id"`
+ // RegionURL is the metadata URL to retrieve the region from for EC2 AWS credentials.
+ RegionURL string `json:"region_url"`
+ // RegionalCredVerificationURL is the AWS regional credential verification URL, will default to
+ // "https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15" if not provided."
+ RegionalCredVerificationURL string `json:"regional_cred_verification_url"`
+ // IMDSv2SessionTokenURL is the URL to retrieve the session token when using IMDSv2 in AWS.
+ IMDSv2SessionTokenURL string `json:"imdsv2_session_token_url"`
+ // Format is the format type for the subject token. Used for File and URL sourced credentials. Expected values are "text" or "json".
+ Format Format `json:"format"`
+}
+
+// ExecutableConfig contains information needed for executable sourced credentials.
+type ExecutableConfig struct {
+ // Command is the the full command to run to retrieve the subject token.
+ // This can include arguments. Must be an absolute path for the program. Required.
+ Command string `json:"command"`
+ // TimeoutMillis is the timeout duration, in milliseconds. Defaults to 30000 milliseconds when not provided. Optional.
+ TimeoutMillis *int `json:"timeout_millis"`
+ // OutputFile is the absolute path to the output file where the executable will cache the response.
+ // If specified the auth libraries will first check this location before running the executable. Optional.
+ OutputFile string `json:"output_file"`
+}
+
+// SubjectTokenSupplier can be used to supply a subject token to exchange for a GCP access token.
+type SubjectTokenSupplier interface {
+ // SubjectToken should return a valid subject token or an error.
+ // The external account token source does not cache the returned subject token, so caching
+ // logic should be implemented in the supplier to prevent multiple requests for the same subject token.
+ SubjectToken(ctx context.Context, options SupplierOptions) (string, error)
+}
+
+// AWSSecurityCredentialsSupplier can be used to supply AwsSecurityCredentials and an AWS Region to
+// exchange for a GCP access token.
+type AwsSecurityCredentialsSupplier interface {
+ // AwsRegion should return the AWS region or an error.
+ AwsRegion(ctx context.Context, options SupplierOptions) (string, error)
+ // GetAwsSecurityCredentials should return a valid set of AwsSecurityCredentials or an error.
+ // The external account token source does not cache the returned security credentials, so caching
+ // logic should be implemented in the supplier to prevent multiple requests for the same security credentials.
+ AwsSecurityCredentials(ctx context.Context, options SupplierOptions) (*AwsSecurityCredentials, error)
+}
+
+// SupplierOptions contains information about the requested subject token or AWS security credentials from the
+// Google external account credential.
+type SupplierOptions struct {
+ // Audience is the requested audience for the external account credential.
+ Audience string
+ // Subject token type is the requested subject token type for the external account credential. Expected values include:
+ // “urn:ietf:params:oauth:token-type:jwt”
+ // “urn:ietf:params:oauth:token-type:id-token”
+ // “urn:ietf:params:oauth:token-type:saml2”
+ // “urn:ietf:params:aws:token-type:aws4_request”
+ SubjectTokenType string
+}
+
+// tokenURL returns the default STS token endpoint with the configured universe
+// domain.
+func (c *Config) tokenURL() string {
+ if c.UniverseDomain == "" {
+ return strings.Replace(defaultTokenURL, universeDomainPlaceholder, defaultUniverseDomain, 1)
+ }
+ return strings.Replace(defaultTokenURL, universeDomainPlaceholder, c.UniverseDomain, 1)
+}
+
+// parse determines the type of CredentialSource needed.
+func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) {
+ //set Defaults
+ if c.TokenURL == "" {
+ c.TokenURL = c.tokenURL()
+ }
+ supplierOptions := SupplierOptions{Audience: c.Audience, SubjectTokenType: c.SubjectTokenType}
+
+ if c.AwsSecurityCredentialsSupplier != nil {
+ awsCredSource := awsCredentialSource{
+ awsSecurityCredentialsSupplier: c.AwsSecurityCredentialsSupplier,
+ targetResource: c.Audience,
+ supplierOptions: supplierOptions,
+ ctx: ctx,
+ }
+ return awsCredSource, nil
+ } else if c.SubjectTokenSupplier != nil {
+ return programmaticRefreshCredentialSource{subjectTokenSupplier: c.SubjectTokenSupplier, supplierOptions: supplierOptions, ctx: ctx}, nil
+ } else if len(c.CredentialSource.EnvironmentID) > 3 && c.CredentialSource.EnvironmentID[:3] == "aws" {
+ if awsVersion, err := strconv.Atoi(c.CredentialSource.EnvironmentID[3:]); err == nil {
+ if awsVersion != 1 {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: aws version '%d' is not supported in the current build", awsVersion)
+ }
+
+ awsCredSource := awsCredentialSource{
+ environmentID: c.CredentialSource.EnvironmentID,
+ regionURL: c.CredentialSource.RegionURL,
+ regionalCredVerificationURL: c.CredentialSource.RegionalCredVerificationURL,
+ credVerificationURL: c.CredentialSource.URL,
+ targetResource: c.Audience,
+ ctx: ctx,
+ }
+ if c.CredentialSource.IMDSv2SessionTokenURL != "" {
+ awsCredSource.imdsv2SessionTokenURL = c.CredentialSource.IMDSv2SessionTokenURL
+ }
+
+ return awsCredSource, nil
+ }
+ } else if c.CredentialSource.File != "" {
+ return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}, nil
+ } else if c.CredentialSource.URL != "" {
+ return urlCredentialSource{URL: c.CredentialSource.URL, Headers: c.CredentialSource.Headers, Format: c.CredentialSource.Format, ctx: ctx}, nil
+ } else if c.CredentialSource.Executable != nil {
+ return createExecutableCredential(ctx, c.CredentialSource.Executable, c)
+ }
+ return nil, fmt.Errorf("oauth2/google/externalaccount: unable to parse credential source")
+}
+
+type baseCredentialSource interface {
+ credentialSourceType() string
+ subjectToken() (string, error)
+}
+
+// tokenSource is the source that handles external credentials. It is used to retrieve Tokens.
+type tokenSource struct {
+ ctx context.Context
+ conf *Config
+}
+
+func getMetricsHeaderValue(conf *Config, credSource baseCredentialSource) string {
+ return fmt.Sprintf("gl-go/%s auth/%s google-byoid-sdk source/%s sa-impersonation/%t config-lifetime/%t",
+ goVersion(),
+ "unknown",
+ credSource.credentialSourceType(),
+ conf.ServiceAccountImpersonationURL != "",
+ conf.ServiceAccountImpersonationLifetimeSeconds != 0)
+}
+
+// Token allows tokenSource to conform to the oauth2.TokenSource interface.
+func (ts tokenSource) Token() (*oauth2.Token, error) {
+ conf := ts.conf
+
+ credSource, err := conf.parse(ts.ctx)
+ if err != nil {
+ return nil, err
+ }
+ subjectToken, err := credSource.subjectToken()
+
+ if err != nil {
+ return nil, err
+ }
+ stsRequest := stsexchange.TokenExchangeRequest{
+ GrantType: "urn:ietf:params:oauth:grant-type:token-exchange",
+ Audience: conf.Audience,
+ Scope: conf.Scopes,
+ RequestedTokenType: "urn:ietf:params:oauth:token-type:access_token",
+ SubjectToken: subjectToken,
+ SubjectTokenType: conf.SubjectTokenType,
+ }
+ header := make(http.Header)
+ header.Add("Content-Type", "application/x-www-form-urlencoded")
+ header.Add("x-goog-api-client", getMetricsHeaderValue(conf, credSource))
+ clientAuth := stsexchange.ClientAuthentication{
+ AuthStyle: oauth2.AuthStyleInHeader,
+ ClientID: conf.ClientID,
+ ClientSecret: conf.ClientSecret,
+ }
+ var options map[string]interface{}
+ // Do not pass workforce_pool_user_project when client authentication is used.
+ // The client ID is sufficient for determining the user project.
+ if conf.WorkforcePoolUserProject != "" && conf.ClientID == "" {
+ options = map[string]interface{}{
+ "userProject": conf.WorkforcePoolUserProject,
+ }
+ }
+ stsResp, err := stsexchange.ExchangeToken(ts.ctx, conf.TokenURL, &stsRequest, clientAuth, header, options)
+ if err != nil {
+ return nil, err
+ }
+
+ accessToken := &oauth2.Token{
+ AccessToken: stsResp.AccessToken,
+ TokenType: stsResp.TokenType,
+ }
+ if stsResp.ExpiresIn < 0 {
+ return nil, fmt.Errorf("oauth2/google/externalaccount: got invalid expiry from security token service")
+ } else if stsResp.ExpiresIn >= 0 {
+ accessToken.Expiry = now().Add(time.Duration(stsResp.ExpiresIn) * time.Second)
+ }
+
+ if stsResp.RefreshToken != "" {
+ accessToken.RefreshToken = stsResp.RefreshToken
+ }
+ return accessToken, nil
+}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/executablecredsource.go
similarity index 85%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go
rename to backend/vendor/golang.org/x/oauth2/google/externalaccount/executablecredsource.go
index 843d1c3302..dca5681a46 100644
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/executablecredsource.go
@@ -39,51 +39,51 @@ func (nce nonCacheableError) Error() string {
}
func missingFieldError(source, field string) error {
- return fmt.Errorf("oauth2/google: %v missing `%q` field", source, field)
+ return fmt.Errorf("oauth2/google/externalaccount: %v missing `%q` field", source, field)
}
func jsonParsingError(source, data string) error {
- return fmt.Errorf("oauth2/google: unable to parse %v\nResponse: %v", source, data)
+ return fmt.Errorf("oauth2/google/externalaccount: unable to parse %v\nResponse: %v", source, data)
}
func malformedFailureError() error {
- return nonCacheableError{"oauth2/google: response must include `error` and `message` fields when unsuccessful"}
+ return nonCacheableError{"oauth2/google/externalaccount: response must include `error` and `message` fields when unsuccessful"}
}
func userDefinedError(code, message string) error {
- return nonCacheableError{fmt.Sprintf("oauth2/google: response contains unsuccessful response: (%v) %v", code, message)}
+ return nonCacheableError{fmt.Sprintf("oauth2/google/externalaccount: response contains unsuccessful response: (%v) %v", code, message)}
}
func unsupportedVersionError(source string, version int) error {
- return fmt.Errorf("oauth2/google: %v contains unsupported version: %v", source, version)
+ return fmt.Errorf("oauth2/google/externalaccount: %v contains unsupported version: %v", source, version)
}
func tokenExpiredError() error {
- return nonCacheableError{"oauth2/google: the token returned by the executable is expired"}
+ return nonCacheableError{"oauth2/google/externalaccount: the token returned by the executable is expired"}
}
func tokenTypeError(source string) error {
- return fmt.Errorf("oauth2/google: %v contains unsupported token type", source)
+ return fmt.Errorf("oauth2/google/externalaccount: %v contains unsupported token type", source)
}
func exitCodeError(exitCode int) error {
- return fmt.Errorf("oauth2/google: executable command failed with exit code %v", exitCode)
+ return fmt.Errorf("oauth2/google/externalaccount: executable command failed with exit code %v", exitCode)
}
func executableError(err error) error {
- return fmt.Errorf("oauth2/google: executable command failed: %v", err)
+ return fmt.Errorf("oauth2/google/externalaccount: executable command failed: %v", err)
}
func executablesDisallowedError() error {
- return errors.New("oauth2/google: executables need to be explicitly allowed (set GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES to '1') to run")
+ return errors.New("oauth2/google/externalaccount: executables need to be explicitly allowed (set GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES to '1') to run")
}
func timeoutRangeError() error {
- return errors.New("oauth2/google: invalid `timeout_millis` field — executable timeout must be between 5 and 120 seconds")
+ return errors.New("oauth2/google/externalaccount: invalid `timeout_millis` field — executable timeout must be between 5 and 120 seconds")
}
func commandMissingError() error {
- return errors.New("oauth2/google: missing `command` field — executable command must be provided")
+ return errors.New("oauth2/google/externalaccount: missing `command` field — executable command must be provided")
}
type environment interface {
@@ -146,7 +146,7 @@ type executableCredentialSource struct {
// CreateExecutableCredential creates an executableCredentialSource given an ExecutableConfig.
// It also performs defaulting and type conversions.
-func CreateExecutableCredential(ctx context.Context, ec *ExecutableConfig, config *Config) (executableCredentialSource, error) {
+func createExecutableCredential(ctx context.Context, ec *ExecutableConfig, config *Config) (executableCredentialSource, error) {
if ec.Command == "" {
return executableCredentialSource{}, commandMissingError()
}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/filecredsource.go
similarity index 62%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go
rename to backend/vendor/golang.org/x/oauth2/google/externalaccount/filecredsource.go
index f35f73c5cb..33766b9722 100644
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/filecredsource.go
@@ -16,7 +16,7 @@ import (
type fileCredentialSource struct {
File string
- Format format
+ Format Format
}
func (cs fileCredentialSource) credentialSourceType() string {
@@ -26,12 +26,12 @@ func (cs fileCredentialSource) credentialSourceType() string {
func (cs fileCredentialSource) subjectToken() (string, error) {
tokenFile, err := os.Open(cs.File)
if err != nil {
- return "", fmt.Errorf("oauth2/google: failed to open credential file %q", cs.File)
+ return "", fmt.Errorf("oauth2/google/externalaccount: failed to open credential file %q", cs.File)
}
defer tokenFile.Close()
tokenBytes, err := ioutil.ReadAll(io.LimitReader(tokenFile, 1<<20))
if err != nil {
- return "", fmt.Errorf("oauth2/google: failed to read credential file: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: failed to read credential file: %v", err)
}
tokenBytes = bytes.TrimSpace(tokenBytes)
switch cs.Format.Type {
@@ -39,15 +39,15 @@ func (cs fileCredentialSource) subjectToken() (string, error) {
jsonData := make(map[string]interface{})
err = json.Unmarshal(tokenBytes, &jsonData)
if err != nil {
- return "", fmt.Errorf("oauth2/google: failed to unmarshal subject token file: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: failed to unmarshal subject token file: %v", err)
}
val, ok := jsonData[cs.Format.SubjectTokenFieldName]
if !ok {
- return "", errors.New("oauth2/google: provided subject_token_field_name not found in credentials")
+ return "", errors.New("oauth2/google/externalaccount: provided subject_token_field_name not found in credentials")
}
token, ok := val.(string)
if !ok {
- return "", errors.New("oauth2/google: improperly formatted subject token")
+ return "", errors.New("oauth2/google/externalaccount: improperly formatted subject token")
}
return token, nil
case "text":
@@ -55,7 +55,7 @@ func (cs fileCredentialSource) subjectToken() (string, error) {
case "":
return string(tokenBytes), nil
default:
- return "", errors.New("oauth2/google: invalid credential_source file format type")
+ return "", errors.New("oauth2/google/externalaccount: invalid credential_source file format type")
}
}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/header.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/header.go
similarity index 100%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/header.go
rename to backend/vendor/golang.org/x/oauth2/google/externalaccount/header.go
diff --git a/backend/vendor/golang.org/x/oauth2/google/externalaccount/programmaticrefreshcredsource.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/programmaticrefreshcredsource.go
new file mode 100644
index 0000000000..6c1abdf2da
--- /dev/null
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/programmaticrefreshcredsource.go
@@ -0,0 +1,21 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package externalaccount
+
+import "context"
+
+type programmaticRefreshCredentialSource struct {
+ supplierOptions SupplierOptions
+ subjectTokenSupplier SubjectTokenSupplier
+ ctx context.Context
+}
+
+func (cs programmaticRefreshCredentialSource) credentialSourceType() string {
+ return "programmatic"
+}
+
+func (cs programmaticRefreshCredentialSource) subjectToken() (string, error) {
+ return cs.subjectTokenSupplier.SubjectToken(cs.ctx, cs.supplierOptions)
+}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go b/backend/vendor/golang.org/x/oauth2/google/externalaccount/urlcredsource.go
similarity index 61%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go
rename to backend/vendor/golang.org/x/oauth2/google/externalaccount/urlcredsource.go
index 606bb4e800..71a7184e01 100644
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go
+++ b/backend/vendor/golang.org/x/oauth2/google/externalaccount/urlcredsource.go
@@ -19,7 +19,7 @@ import (
type urlCredentialSource struct {
URL string
Headers map[string]string
- Format format
+ Format Format
ctx context.Context
}
@@ -31,7 +31,7 @@ func (cs urlCredentialSource) subjectToken() (string, error) {
client := oauth2.NewClient(cs.ctx, nil)
req, err := http.NewRequest("GET", cs.URL, nil)
if err != nil {
- return "", fmt.Errorf("oauth2/google: HTTP request for URL-sourced credential failed: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: HTTP request for URL-sourced credential failed: %v", err)
}
req = req.WithContext(cs.ctx)
@@ -40,16 +40,16 @@ func (cs urlCredentialSource) subjectToken() (string, error) {
}
resp, err := client.Do(req)
if err != nil {
- return "", fmt.Errorf("oauth2/google: invalid response when retrieving subject token: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: invalid response when retrieving subject token: %v", err)
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
- return "", fmt.Errorf("oauth2/google: invalid body in subject token URL query: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: invalid body in subject token URL query: %v", err)
}
if c := resp.StatusCode; c < 200 || c > 299 {
- return "", fmt.Errorf("oauth2/google: status code %d: %s", c, respBody)
+ return "", fmt.Errorf("oauth2/google/externalaccount: status code %d: %s", c, respBody)
}
switch cs.Format.Type {
@@ -57,15 +57,15 @@ func (cs urlCredentialSource) subjectToken() (string, error) {
jsonData := make(map[string]interface{})
err = json.Unmarshal(respBody, &jsonData)
if err != nil {
- return "", fmt.Errorf("oauth2/google: failed to unmarshal subject token file: %v", err)
+ return "", fmt.Errorf("oauth2/google/externalaccount: failed to unmarshal subject token file: %v", err)
}
val, ok := jsonData[cs.Format.SubjectTokenFieldName]
if !ok {
- return "", errors.New("oauth2/google: provided subject_token_field_name not found in credentials")
+ return "", errors.New("oauth2/google/externalaccount: provided subject_token_field_name not found in credentials")
}
token, ok := val.(string)
if !ok {
- return "", errors.New("oauth2/google: improperly formatted subject token")
+ return "", errors.New("oauth2/google/externalaccount: improperly formatted subject token")
}
return token, nil
case "text":
@@ -73,7 +73,7 @@ func (cs urlCredentialSource) subjectToken() (string, error) {
case "":
return string(respBody), nil
default:
- return "", errors.New("oauth2/google: invalid credential_source file format type")
+ return "", errors.New("oauth2/google/externalaccount: invalid credential_source file format type")
}
}
diff --git a/backend/vendor/golang.org/x/oauth2/google/google.go b/backend/vendor/golang.org/x/oauth2/google/google.go
index c66c53527d..ba931c2c3d 100644
--- a/backend/vendor/golang.org/x/oauth2/google/google.go
+++ b/backend/vendor/golang.org/x/oauth2/google/google.go
@@ -15,8 +15,9 @@ import (
"cloud.google.com/go/compute/metadata"
"golang.org/x/oauth2"
- "golang.org/x/oauth2/google/internal/externalaccount"
+ "golang.org/x/oauth2/google/externalaccount"
"golang.org/x/oauth2/google/internal/externalaccountauthorizeduser"
+ "golang.org/x/oauth2/google/internal/impersonate"
"golang.org/x/oauth2/jwt"
)
@@ -200,12 +201,12 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
ServiceAccountImpersonationLifetimeSeconds: f.ServiceAccountImpersonation.TokenLifetimeSeconds,
ClientSecret: f.ClientSecret,
ClientID: f.ClientID,
- CredentialSource: f.CredentialSource,
+ CredentialSource: &f.CredentialSource,
QuotaProjectID: f.QuotaProjectID,
Scopes: params.Scopes,
WorkforcePoolUserProject: f.WorkforcePoolUserProject,
}
- return cfg.TokenSource(ctx)
+ return externalaccount.NewTokenSource(ctx, *cfg)
case externalAccountAuthorizedUserKey:
cfg := &externalaccountauthorizeduser.Config{
Audience: f.Audience,
@@ -228,7 +229,7 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
if err != nil {
return nil, err
}
- imp := externalaccount.ImpersonateTokenSource{
+ imp := impersonate.ImpersonateTokenSource{
Ctx: ctx,
URL: f.ServiceAccountImpersonationURL,
Scopes: params.Scopes,
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go b/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go
deleted file mode 100644
index 33288d3677..0000000000
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go
+++ /dev/null
@@ -1,254 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package externalaccount
-
-import (
- "context"
- "fmt"
- "net/http"
- "regexp"
- "strconv"
- "time"
-
- "golang.org/x/oauth2"
- "golang.org/x/oauth2/google/internal/stsexchange"
-)
-
-// now aliases time.Now for testing
-var now = func() time.Time {
- return time.Now().UTC()
-}
-
-// Config stores the configuration for fetching tokens with external credentials.
-type Config struct {
- // Audience is the Secure Token Service (STS) audience which contains the resource name for the workload
- // identity pool or the workforce pool and the provider identifier in that pool.
- Audience string
- // SubjectTokenType is the STS token type based on the Oauth2.0 token exchange spec
- // e.g. `urn:ietf:params:oauth:token-type:jwt`.
- SubjectTokenType string
- // TokenURL is the STS token exchange endpoint.
- TokenURL string
- // TokenInfoURL is the token_info endpoint used to retrieve the account related information (
- // user attributes like account identifier, eg. email, username, uid, etc). This is
- // needed for gCloud session account identification.
- TokenInfoURL string
- // ServiceAccountImpersonationURL is the URL for the service account impersonation request. This is only
- // required for workload identity pools when APIs to be accessed have not integrated with UberMint.
- ServiceAccountImpersonationURL string
- // ServiceAccountImpersonationLifetimeSeconds is the number of seconds the service account impersonation
- // token will be valid for.
- ServiceAccountImpersonationLifetimeSeconds int
- // ClientSecret is currently only required if token_info endpoint also
- // needs to be called with the generated GCP access token. When provided, STS will be
- // called with additional basic authentication using client_id as username and client_secret as password.
- ClientSecret string
- // ClientID is only required in conjunction with ClientSecret, as described above.
- ClientID string
- // CredentialSource contains the necessary information to retrieve the token itself, as well
- // as some environmental information.
- CredentialSource CredentialSource
- // QuotaProjectID is injected by gCloud. If the value is non-empty, the Auth libraries
- // will set the x-goog-user-project which overrides the project associated with the credentials.
- QuotaProjectID string
- // Scopes contains the desired scopes for the returned access token.
- Scopes []string
- // The optional workforce pool user project number when the credential
- // corresponds to a workforce pool and not a workload identity pool.
- // The underlying principal must still have serviceusage.services.use IAM
- // permission to use the project for billing/quota.
- WorkforcePoolUserProject string
-}
-
-var (
- validWorkforceAudiencePattern *regexp.Regexp = regexp.MustCompile(`//iam\.googleapis\.com/locations/[^/]+/workforcePools/`)
-)
-
-func validateWorkforceAudience(input string) bool {
- return validWorkforceAudiencePattern.MatchString(input)
-}
-
-// TokenSource Returns an external account TokenSource struct. This is to be called by package google to construct a google.Credentials.
-func (c *Config) TokenSource(ctx context.Context) (oauth2.TokenSource, error) {
- return c.tokenSource(ctx, "https")
-}
-
-// tokenSource is a private function that's directly called by some of the tests,
-// because the unit test URLs are mocked, and would otherwise fail the
-// validity check.
-func (c *Config) tokenSource(ctx context.Context, scheme string) (oauth2.TokenSource, error) {
- if c.WorkforcePoolUserProject != "" {
- valid := validateWorkforceAudience(c.Audience)
- if !valid {
- return nil, fmt.Errorf("oauth2/google: workforce_pool_user_project should not be set for non-workforce pool credentials")
- }
- }
-
- ts := tokenSource{
- ctx: ctx,
- conf: c,
- }
- if c.ServiceAccountImpersonationURL == "" {
- return oauth2.ReuseTokenSource(nil, ts), nil
- }
- scopes := c.Scopes
- ts.conf.Scopes = []string{"https://www.googleapis.com/auth/cloud-platform"}
- imp := ImpersonateTokenSource{
- Ctx: ctx,
- URL: c.ServiceAccountImpersonationURL,
- Scopes: scopes,
- Ts: oauth2.ReuseTokenSource(nil, ts),
- TokenLifetimeSeconds: c.ServiceAccountImpersonationLifetimeSeconds,
- }
- return oauth2.ReuseTokenSource(nil, imp), nil
-}
-
-// Subject token file types.
-const (
- fileTypeText = "text"
- fileTypeJSON = "json"
-)
-
-type format struct {
- // Type is either "text" or "json". When not provided "text" type is assumed.
- Type string `json:"type"`
- // SubjectTokenFieldName is only required for JSON format. This would be "access_token" for azure.
- SubjectTokenFieldName string `json:"subject_token_field_name"`
-}
-
-// CredentialSource stores the information necessary to retrieve the credentials for the STS exchange.
-// One field amongst File, URL, and Executable should be filled, depending on the kind of credential in question.
-// The EnvironmentID should start with AWS if being used for an AWS credential.
-type CredentialSource struct {
- File string `json:"file"`
-
- URL string `json:"url"`
- Headers map[string]string `json:"headers"`
-
- Executable *ExecutableConfig `json:"executable"`
-
- EnvironmentID string `json:"environment_id"`
- RegionURL string `json:"region_url"`
- RegionalCredVerificationURL string `json:"regional_cred_verification_url"`
- CredVerificationURL string `json:"cred_verification_url"`
- IMDSv2SessionTokenURL string `json:"imdsv2_session_token_url"`
- Format format `json:"format"`
-}
-
-type ExecutableConfig struct {
- Command string `json:"command"`
- TimeoutMillis *int `json:"timeout_millis"`
- OutputFile string `json:"output_file"`
-}
-
-// parse determines the type of CredentialSource needed.
-func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) {
- if len(c.CredentialSource.EnvironmentID) > 3 && c.CredentialSource.EnvironmentID[:3] == "aws" {
- if awsVersion, err := strconv.Atoi(c.CredentialSource.EnvironmentID[3:]); err == nil {
- if awsVersion != 1 {
- return nil, fmt.Errorf("oauth2/google: aws version '%d' is not supported in the current build", awsVersion)
- }
-
- awsCredSource := awsCredentialSource{
- EnvironmentID: c.CredentialSource.EnvironmentID,
- RegionURL: c.CredentialSource.RegionURL,
- RegionalCredVerificationURL: c.CredentialSource.RegionalCredVerificationURL,
- CredVerificationURL: c.CredentialSource.URL,
- TargetResource: c.Audience,
- ctx: ctx,
- }
- if c.CredentialSource.IMDSv2SessionTokenURL != "" {
- awsCredSource.IMDSv2SessionTokenURL = c.CredentialSource.IMDSv2SessionTokenURL
- }
-
- return awsCredSource, nil
- }
- } else if c.CredentialSource.File != "" {
- return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}, nil
- } else if c.CredentialSource.URL != "" {
- return urlCredentialSource{URL: c.CredentialSource.URL, Headers: c.CredentialSource.Headers, Format: c.CredentialSource.Format, ctx: ctx}, nil
- } else if c.CredentialSource.Executable != nil {
- return CreateExecutableCredential(ctx, c.CredentialSource.Executable, c)
- }
- return nil, fmt.Errorf("oauth2/google: unable to parse credential source")
-}
-
-type baseCredentialSource interface {
- credentialSourceType() string
- subjectToken() (string, error)
-}
-
-// tokenSource is the source that handles external credentials. It is used to retrieve Tokens.
-type tokenSource struct {
- ctx context.Context
- conf *Config
-}
-
-func getMetricsHeaderValue(conf *Config, credSource baseCredentialSource) string {
- return fmt.Sprintf("gl-go/%s auth/%s google-byoid-sdk source/%s sa-impersonation/%t config-lifetime/%t",
- goVersion(),
- "unknown",
- credSource.credentialSourceType(),
- conf.ServiceAccountImpersonationURL != "",
- conf.ServiceAccountImpersonationLifetimeSeconds != 0)
-}
-
-// Token allows tokenSource to conform to the oauth2.TokenSource interface.
-func (ts tokenSource) Token() (*oauth2.Token, error) {
- conf := ts.conf
-
- credSource, err := conf.parse(ts.ctx)
- if err != nil {
- return nil, err
- }
- subjectToken, err := credSource.subjectToken()
-
- if err != nil {
- return nil, err
- }
- stsRequest := stsexchange.TokenExchangeRequest{
- GrantType: "urn:ietf:params:oauth:grant-type:token-exchange",
- Audience: conf.Audience,
- Scope: conf.Scopes,
- RequestedTokenType: "urn:ietf:params:oauth:token-type:access_token",
- SubjectToken: subjectToken,
- SubjectTokenType: conf.SubjectTokenType,
- }
- header := make(http.Header)
- header.Add("Content-Type", "application/x-www-form-urlencoded")
- header.Add("x-goog-api-client", getMetricsHeaderValue(conf, credSource))
- clientAuth := stsexchange.ClientAuthentication{
- AuthStyle: oauth2.AuthStyleInHeader,
- ClientID: conf.ClientID,
- ClientSecret: conf.ClientSecret,
- }
- var options map[string]interface{}
- // Do not pass workforce_pool_user_project when client authentication is used.
- // The client ID is sufficient for determining the user project.
- if conf.WorkforcePoolUserProject != "" && conf.ClientID == "" {
- options = map[string]interface{}{
- "userProject": conf.WorkforcePoolUserProject,
- }
- }
- stsResp, err := stsexchange.ExchangeToken(ts.ctx, conf.TokenURL, &stsRequest, clientAuth, header, options)
- if err != nil {
- return nil, err
- }
-
- accessToken := &oauth2.Token{
- AccessToken: stsResp.AccessToken,
- TokenType: stsResp.TokenType,
- }
- if stsResp.ExpiresIn < 0 {
- return nil, fmt.Errorf("oauth2/google: got invalid expiry from security token service")
- } else if stsResp.ExpiresIn >= 0 {
- accessToken.Expiry = now().Add(time.Duration(stsResp.ExpiresIn) * time.Second)
- }
-
- if stsResp.RefreshToken != "" {
- accessToken.RefreshToken = stsResp.RefreshToken
- }
- return accessToken, nil
-}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/err.go b/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/err.go
deleted file mode 100644
index 233a78cef2..0000000000
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/err.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package externalaccount
-
-import "fmt"
-
-// Error for handling OAuth related error responses as stated in rfc6749#5.2.
-type Error struct {
- Code string
- URI string
- Description string
-}
-
-func (err *Error) Error() string {
- return fmt.Sprintf("got error code %s from %s: %s", err.Code, err.URI, err.Description)
-}
diff --git a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/impersonate.go b/backend/vendor/golang.org/x/oauth2/google/internal/impersonate/impersonate.go
similarity index 99%
rename from backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/impersonate.go
rename to backend/vendor/golang.org/x/oauth2/google/internal/impersonate/impersonate.go
index 54c8f209f3..6bc3af1103 100644
--- a/backend/vendor/golang.org/x/oauth2/google/internal/externalaccount/impersonate.go
+++ b/backend/vendor/golang.org/x/oauth2/google/internal/impersonate/impersonate.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package externalaccount
+package impersonate
import (
"bytes"
diff --git a/backend/vendor/golang.org/x/sys/unix/aliases.go b/backend/vendor/golang.org/x/sys/unix/aliases.go
index e7d3df4bd3..b0e4198575 100644
--- a/backend/vendor/golang.org/x/sys/unix/aliases.go
+++ b/backend/vendor/golang.org/x/sys/unix/aliases.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
package unix
diff --git a/backend/vendor/golang.org/x/sys/unix/mmap_nomremap.go b/backend/vendor/golang.org/x/sys/unix/mmap_nomremap.go
index 4b68e59780..7f602ffd26 100644
--- a/backend/vendor/golang.org/x/sys/unix/mmap_nomremap.go
+++ b/backend/vendor/golang.org/x/sys/unix/mmap_nomremap.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build aix || darwin || dragonfly || freebsd || openbsd || solaris
+//go:build aix || darwin || dragonfly || freebsd || openbsd || solaris || zos
package unix
diff --git a/backend/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go b/backend/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
index 16dc699379..2f0fa76e4f 100644
--- a/backend/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
+++ b/backend/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build darwin && go1.12
+//go:build darwin
package unix
diff --git a/backend/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/backend/vendor/golang.org/x/sys/unix/syscall_freebsd.go
index 64d1bb4dba..2b57e0f73b 100644
--- a/backend/vendor/golang.org/x/sys/unix/syscall_freebsd.go
+++ b/backend/vendor/golang.org/x/sys/unix/syscall_freebsd.go
@@ -13,6 +13,7 @@
package unix
import (
+ "errors"
"sync"
"unsafe"
)
@@ -169,25 +170,26 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
- if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
+ // Suppress ENOMEM errors to be compatible with the C library __xuname() implementation.
+ if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
return err
}
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
n = unsafe.Sizeof(uname.Nodename)
- if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
+ if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
return err
}
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
n = unsafe.Sizeof(uname.Release)
- if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
+ if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
return err
}
mib = []_C_int{CTL_KERN, KERN_VERSION}
n = unsafe.Sizeof(uname.Version)
- if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
+ if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
return err
}
@@ -205,7 +207,7 @@ func Uname(uname *Utsname) error {
mib = []_C_int{CTL_HW, HW_MACHINE}
n = unsafe.Sizeof(uname.Machine)
- if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
+ if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil && !errors.Is(err, ENOMEM) {
return err
}
diff --git a/backend/vendor/golang.org/x/sys/unix/syscall_linux.go b/backend/vendor/golang.org/x/sys/unix/syscall_linux.go
index 0f85e29e62..5682e2628a 100644
--- a/backend/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/backend/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -1849,6 +1849,105 @@ func Dup2(oldfd, newfd int) error {
//sys Fsmount(fd int, flags int, mountAttrs int) (fsfd int, err error)
//sys Fsopen(fsName string, flags int) (fd int, err error)
//sys Fspick(dirfd int, pathName string, flags int) (fd int, err error)
+
+//sys fsconfig(fd int, cmd uint, key *byte, value *byte, aux int) (err error)
+
+func fsconfigCommon(fd int, cmd uint, key string, value *byte, aux int) (err error) {
+ var keyp *byte
+ if keyp, err = BytePtrFromString(key); err != nil {
+ return
+ }
+ return fsconfig(fd, cmd, keyp, value, aux)
+}
+
+// FsconfigSetFlag is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_FLAG.
+//
+// fd is the filesystem context to act upon.
+// key the parameter key to set.
+func FsconfigSetFlag(fd int, key string) (err error) {
+ return fsconfigCommon(fd, FSCONFIG_SET_FLAG, key, nil, 0)
+}
+
+// FsconfigSetString is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_STRING.
+//
+// fd is the filesystem context to act upon.
+// key the parameter key to set.
+// value is the parameter value to set.
+func FsconfigSetString(fd int, key string, value string) (err error) {
+ var valuep *byte
+ if valuep, err = BytePtrFromString(value); err != nil {
+ return
+ }
+ return fsconfigCommon(fd, FSCONFIG_SET_STRING, key, valuep, 0)
+}
+
+// FsconfigSetBinary is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_BINARY.
+//
+// fd is the filesystem context to act upon.
+// key the parameter key to set.
+// value is the parameter value to set.
+func FsconfigSetBinary(fd int, key string, value []byte) (err error) {
+ if len(value) == 0 {
+ return EINVAL
+ }
+ return fsconfigCommon(fd, FSCONFIG_SET_BINARY, key, &value[0], len(value))
+}
+
+// FsconfigSetPath is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_PATH.
+//
+// fd is the filesystem context to act upon.
+// key the parameter key to set.
+// path is a non-empty path for specified key.
+// atfd is a file descriptor at which to start lookup from or AT_FDCWD.
+func FsconfigSetPath(fd int, key string, path string, atfd int) (err error) {
+ var valuep *byte
+ if valuep, err = BytePtrFromString(path); err != nil {
+ return
+ }
+ return fsconfigCommon(fd, FSCONFIG_SET_PATH, key, valuep, atfd)
+}
+
+// FsconfigSetPathEmpty is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_PATH_EMPTY. The same as
+// FconfigSetPath but with AT_PATH_EMPTY implied.
+func FsconfigSetPathEmpty(fd int, key string, path string, atfd int) (err error) {
+ var valuep *byte
+ if valuep, err = BytePtrFromString(path); err != nil {
+ return
+ }
+ return fsconfigCommon(fd, FSCONFIG_SET_PATH_EMPTY, key, valuep, atfd)
+}
+
+// FsconfigSetFd is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_SET_FD.
+//
+// fd is the filesystem context to act upon.
+// key the parameter key to set.
+// value is a file descriptor to be assigned to specified key.
+func FsconfigSetFd(fd int, key string, value int) (err error) {
+ return fsconfigCommon(fd, FSCONFIG_SET_FD, key, nil, value)
+}
+
+// FsconfigCreate is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_CMD_CREATE.
+//
+// fd is the filesystem context to act upon.
+func FsconfigCreate(fd int) (err error) {
+ return fsconfig(fd, FSCONFIG_CMD_CREATE, nil, nil, 0)
+}
+
+// FsconfigReconfigure is equivalent to fsconfig(2) called
+// with cmd == FSCONFIG_CMD_RECONFIGURE.
+//
+// fd is the filesystem context to act upon.
+func FsconfigReconfigure(fd int) (err error) {
+ return fsconfig(fd, FSCONFIG_CMD_RECONFIGURE, nil, nil, 0)
+}
+
//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
//sysnb Getpgid(pid int) (pgid int, err error)
diff --git a/backend/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/backend/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
index b473038c61..27c41b6f0a 100644
--- a/backend/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
+++ b/backend/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
@@ -1520,6 +1520,14 @@ func (m *mmapper) Munmap(data []byte) (err error) {
return nil
}
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
+ return mapper.Mmap(fd, offset, length, prot, flags)
+}
+
+func Munmap(b []byte) (err error) {
+ return mapper.Munmap(b)
+}
+
func Read(fd int, p []byte) (n int, err error) {
n, err = read(fd, p)
if raceenabled {
diff --git a/backend/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/backend/vendor/golang.org/x/sys/unix/zsyscall_linux.go
index 1488d27128..87d8612a1d 100644
--- a/backend/vendor/golang.org/x/sys/unix/zsyscall_linux.go
+++ b/backend/vendor/golang.org/x/sys/unix/zsyscall_linux.go
@@ -906,6 +906,16 @@ func Fspick(dirfd int, pathName string, flags int) (fd int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func fsconfig(fd int, cmd uint, key *byte, value *byte, aux int) (err error) {
+ _, _, e1 := Syscall6(SYS_FSCONFIG, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(value)), uintptr(aux), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getdents(fd int, buf []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
diff --git a/backend/vendor/golang.org/x/sys/unix/ztypes_linux.go b/backend/vendor/golang.org/x/sys/unix/ztypes_linux.go
index dc0c955eec..eff6bcdef8 100644
--- a/backend/vendor/golang.org/x/sys/unix/ztypes_linux.go
+++ b/backend/vendor/golang.org/x/sys/unix/ztypes_linux.go
@@ -836,6 +836,15 @@ const (
FSPICK_EMPTY_PATH = 0x8
FSMOUNT_CLOEXEC = 0x1
+
+ FSCONFIG_SET_FLAG = 0x0
+ FSCONFIG_SET_STRING = 0x1
+ FSCONFIG_SET_BINARY = 0x2
+ FSCONFIG_SET_PATH = 0x3
+ FSCONFIG_SET_PATH_EMPTY = 0x4
+ FSCONFIG_SET_FD = 0x5
+ FSCONFIG_CMD_CREATE = 0x6
+ FSCONFIG_CMD_RECONFIGURE = 0x7
)
type OpenHow struct {
@@ -1550,6 +1559,7 @@ const (
IFLA_DEVLINK_PORT = 0x3e
IFLA_GSO_IPV4_MAX_SIZE = 0x3f
IFLA_GRO_IPV4_MAX_SIZE = 0x40
+ IFLA_DPLL_PIN = 0x41
IFLA_PROTO_DOWN_REASON_UNSPEC = 0x0
IFLA_PROTO_DOWN_REASON_MASK = 0x1
IFLA_PROTO_DOWN_REASON_VALUE = 0x2
@@ -1565,6 +1575,7 @@ const (
IFLA_INET6_ICMP6STATS = 0x6
IFLA_INET6_TOKEN = 0x7
IFLA_INET6_ADDR_GEN_MODE = 0x8
+ IFLA_INET6_RA_MTU = 0x9
IFLA_BR_UNSPEC = 0x0
IFLA_BR_FORWARD_DELAY = 0x1
IFLA_BR_HELLO_TIME = 0x2
@@ -1612,6 +1623,9 @@ const (
IFLA_BR_MCAST_MLD_VERSION = 0x2c
IFLA_BR_VLAN_STATS_PER_PORT = 0x2d
IFLA_BR_MULTI_BOOLOPT = 0x2e
+ IFLA_BR_MCAST_QUERIER_STATE = 0x2f
+ IFLA_BR_FDB_N_LEARNED = 0x30
+ IFLA_BR_FDB_MAX_LEARNED = 0x31
IFLA_BRPORT_UNSPEC = 0x0
IFLA_BRPORT_STATE = 0x1
IFLA_BRPORT_PRIORITY = 0x2
@@ -1649,6 +1663,14 @@ const (
IFLA_BRPORT_BACKUP_PORT = 0x22
IFLA_BRPORT_MRP_RING_OPEN = 0x23
IFLA_BRPORT_MRP_IN_OPEN = 0x24
+ IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT = 0x25
+ IFLA_BRPORT_MCAST_EHT_HOSTS_CNT = 0x26
+ IFLA_BRPORT_LOCKED = 0x27
+ IFLA_BRPORT_MAB = 0x28
+ IFLA_BRPORT_MCAST_N_GROUPS = 0x29
+ IFLA_BRPORT_MCAST_MAX_GROUPS = 0x2a
+ IFLA_BRPORT_NEIGH_VLAN_SUPPRESS = 0x2b
+ IFLA_BRPORT_BACKUP_NHID = 0x2c
IFLA_INFO_UNSPEC = 0x0
IFLA_INFO_KIND = 0x1
IFLA_INFO_DATA = 0x2
@@ -1670,6 +1692,9 @@ const (
IFLA_MACVLAN_MACADDR = 0x4
IFLA_MACVLAN_MACADDR_DATA = 0x5
IFLA_MACVLAN_MACADDR_COUNT = 0x6
+ IFLA_MACVLAN_BC_QUEUE_LEN = 0x7
+ IFLA_MACVLAN_BC_QUEUE_LEN_USED = 0x8
+ IFLA_MACVLAN_BC_CUTOFF = 0x9
IFLA_VRF_UNSPEC = 0x0
IFLA_VRF_TABLE = 0x1
IFLA_VRF_PORT_UNSPEC = 0x0
@@ -1693,9 +1718,22 @@ const (
IFLA_XFRM_UNSPEC = 0x0
IFLA_XFRM_LINK = 0x1
IFLA_XFRM_IF_ID = 0x2
+ IFLA_XFRM_COLLECT_METADATA = 0x3
IFLA_IPVLAN_UNSPEC = 0x0
IFLA_IPVLAN_MODE = 0x1
IFLA_IPVLAN_FLAGS = 0x2
+ NETKIT_NEXT = -0x1
+ NETKIT_PASS = 0x0
+ NETKIT_DROP = 0x2
+ NETKIT_REDIRECT = 0x7
+ NETKIT_L2 = 0x0
+ NETKIT_L3 = 0x1
+ IFLA_NETKIT_UNSPEC = 0x0
+ IFLA_NETKIT_PEER_INFO = 0x1
+ IFLA_NETKIT_PRIMARY = 0x2
+ IFLA_NETKIT_POLICY = 0x3
+ IFLA_NETKIT_PEER_POLICY = 0x4
+ IFLA_NETKIT_MODE = 0x5
IFLA_VXLAN_UNSPEC = 0x0
IFLA_VXLAN_ID = 0x1
IFLA_VXLAN_GROUP = 0x2
@@ -1726,6 +1764,8 @@ const (
IFLA_VXLAN_GPE = 0x1b
IFLA_VXLAN_TTL_INHERIT = 0x1c
IFLA_VXLAN_DF = 0x1d
+ IFLA_VXLAN_VNIFILTER = 0x1e
+ IFLA_VXLAN_LOCALBYPASS = 0x1f
IFLA_GENEVE_UNSPEC = 0x0
IFLA_GENEVE_ID = 0x1
IFLA_GENEVE_REMOTE = 0x2
@@ -1740,6 +1780,7 @@ const (
IFLA_GENEVE_LABEL = 0xb
IFLA_GENEVE_TTL_INHERIT = 0xc
IFLA_GENEVE_DF = 0xd
+ IFLA_GENEVE_INNER_PROTO_INHERIT = 0xe
IFLA_BAREUDP_UNSPEC = 0x0
IFLA_BAREUDP_PORT = 0x1
IFLA_BAREUDP_ETHERTYPE = 0x2
@@ -1752,6 +1793,8 @@ const (
IFLA_GTP_FD1 = 0x2
IFLA_GTP_PDP_HASHSIZE = 0x3
IFLA_GTP_ROLE = 0x4
+ IFLA_GTP_CREATE_SOCKETS = 0x5
+ IFLA_GTP_RESTART_COUNT = 0x6
IFLA_BOND_UNSPEC = 0x0
IFLA_BOND_MODE = 0x1
IFLA_BOND_ACTIVE_SLAVE = 0x2
@@ -1781,6 +1824,9 @@ const (
IFLA_BOND_AD_ACTOR_SYSTEM = 0x1a
IFLA_BOND_TLB_DYNAMIC_LB = 0x1b
IFLA_BOND_PEER_NOTIF_DELAY = 0x1c
+ IFLA_BOND_AD_LACP_ACTIVE = 0x1d
+ IFLA_BOND_MISSED_MAX = 0x1e
+ IFLA_BOND_NS_IP6_TARGET = 0x1f
IFLA_BOND_AD_INFO_UNSPEC = 0x0
IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
@@ -1796,6 +1842,7 @@ const (
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID = 0x6
IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE = 0x7
IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE = 0x8
+ IFLA_BOND_SLAVE_PRIO = 0x9
IFLA_VF_INFO_UNSPEC = 0x0
IFLA_VF_INFO = 0x1
IFLA_VF_UNSPEC = 0x0
@@ -1854,8 +1901,16 @@ const (
IFLA_STATS_LINK_XSTATS_SLAVE = 0x3
IFLA_STATS_LINK_OFFLOAD_XSTATS = 0x4
IFLA_STATS_AF_SPEC = 0x5
+ IFLA_STATS_GETSET_UNSPEC = 0x0
+ IFLA_STATS_GET_FILTERS = 0x1
+ IFLA_STATS_SET_OFFLOAD_XSTATS_L3_STATS = 0x2
IFLA_OFFLOAD_XSTATS_UNSPEC = 0x0
IFLA_OFFLOAD_XSTATS_CPU_HIT = 0x1
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO = 0x2
+ IFLA_OFFLOAD_XSTATS_L3_STATS = 0x3
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_UNSPEC = 0x0
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_REQUEST = 0x1
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED = 0x2
IFLA_XDP_UNSPEC = 0x0
IFLA_XDP_FD = 0x1
IFLA_XDP_ATTACHED = 0x2
@@ -1885,6 +1940,11 @@ const (
IFLA_RMNET_UNSPEC = 0x0
IFLA_RMNET_MUX_ID = 0x1
IFLA_RMNET_FLAGS = 0x2
+ IFLA_MCTP_UNSPEC = 0x0
+ IFLA_MCTP_NET = 0x1
+ IFLA_DSA_UNSPEC = 0x0
+ IFLA_DSA_CONDUIT = 0x1
+ IFLA_DSA_MASTER = 0x1
)
const (
diff --git a/backend/vendor/golang.org/x/sys/windows/syscall_windows.go b/backend/vendor/golang.org/x/sys/windows/syscall_windows.go
index 6395a031d4..6525c62f3c 100644
--- a/backend/vendor/golang.org/x/sys/windows/syscall_windows.go
+++ b/backend/vendor/golang.org/x/sys/windows/syscall_windows.go
@@ -165,6 +165,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
+//sys DisconnectNamedPipe(pipe Handle) (err error)
//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
@@ -348,8 +349,19 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost
//sys GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32)
//sys SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error)
+//sys ClearCommBreak(handle Handle) (err error)
+//sys ClearCommError(handle Handle, lpErrors *uint32, lpStat *ComStat) (err error)
+//sys EscapeCommFunction(handle Handle, dwFunc uint32) (err error)
+//sys GetCommState(handle Handle, lpDCB *DCB) (err error)
+//sys GetCommModemStatus(handle Handle, lpModemStat *uint32) (err error)
//sys GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
+//sys PurgeComm(handle Handle, dwFlags uint32) (err error)
+//sys SetCommBreak(handle Handle) (err error)
+//sys SetCommMask(handle Handle, dwEvtMask uint32) (err error)
+//sys SetCommState(handle Handle, lpDCB *DCB) (err error)
//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
+//sys SetupComm(handle Handle, dwInQueue uint32, dwOutQueue uint32) (err error)
+//sys WaitCommEvent(handle Handle, lpEvtMask *uint32, lpOverlapped *Overlapped) (err error)
//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
//sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows
@@ -1834,3 +1846,73 @@ func ResizePseudoConsole(pconsole Handle, size Coord) error {
// accept arguments that can be casted to uintptr, and Coord can't.
return resizePseudoConsole(pconsole, *((*uint32)(unsafe.Pointer(&size))))
}
+
+// DCB constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-dcb.
+const (
+ CBR_110 = 110
+ CBR_300 = 300
+ CBR_600 = 600
+ CBR_1200 = 1200
+ CBR_2400 = 2400
+ CBR_4800 = 4800
+ CBR_9600 = 9600
+ CBR_14400 = 14400
+ CBR_19200 = 19200
+ CBR_38400 = 38400
+ CBR_57600 = 57600
+ CBR_115200 = 115200
+ CBR_128000 = 128000
+ CBR_256000 = 256000
+
+ DTR_CONTROL_DISABLE = 0x00000000
+ DTR_CONTROL_ENABLE = 0x00000010
+ DTR_CONTROL_HANDSHAKE = 0x00000020
+
+ RTS_CONTROL_DISABLE = 0x00000000
+ RTS_CONTROL_ENABLE = 0x00001000
+ RTS_CONTROL_HANDSHAKE = 0x00002000
+ RTS_CONTROL_TOGGLE = 0x00003000
+
+ NOPARITY = 0
+ ODDPARITY = 1
+ EVENPARITY = 2
+ MARKPARITY = 3
+ SPACEPARITY = 4
+
+ ONESTOPBIT = 0
+ ONE5STOPBITS = 1
+ TWOSTOPBITS = 2
+)
+
+// EscapeCommFunction constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-escapecommfunction.
+const (
+ SETXOFF = 1
+ SETXON = 2
+ SETRTS = 3
+ CLRRTS = 4
+ SETDTR = 5
+ CLRDTR = 6
+ SETBREAK = 8
+ CLRBREAK = 9
+)
+
+// PurgeComm constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-purgecomm.
+const (
+ PURGE_TXABORT = 0x0001
+ PURGE_RXABORT = 0x0002
+ PURGE_TXCLEAR = 0x0004
+ PURGE_RXCLEAR = 0x0008
+)
+
+// SetCommMask constants. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setcommmask.
+const (
+ EV_RXCHAR = 0x0001
+ EV_RXFLAG = 0x0002
+ EV_TXEMPTY = 0x0004
+ EV_CTS = 0x0008
+ EV_DSR = 0x0010
+ EV_RLSD = 0x0020
+ EV_BREAK = 0x0040
+ EV_ERR = 0x0080
+ EV_RING = 0x0100
+)
diff --git a/backend/vendor/golang.org/x/sys/windows/types_windows.go b/backend/vendor/golang.org/x/sys/windows/types_windows.go
index 359780f6ac..d8cb71db0a 100644
--- a/backend/vendor/golang.org/x/sys/windows/types_windows.go
+++ b/backend/vendor/golang.org/x/sys/windows/types_windows.go
@@ -3380,3 +3380,27 @@ type BLOB struct {
Size uint32
BlobData *byte
}
+
+type ComStat struct {
+ Flags uint32
+ CBInQue uint32
+ CBOutQue uint32
+}
+
+type DCB struct {
+ DCBlength uint32
+ BaudRate uint32
+ Flags uint32
+ wReserved uint16
+ XonLim uint16
+ XoffLim uint16
+ ByteSize uint8
+ Parity uint8
+ StopBits uint8
+ XonChar byte
+ XoffChar byte
+ ErrorChar byte
+ EofChar byte
+ EvtChar byte
+ wReserved1 uint16
+}
diff --git a/backend/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/backend/vendor/golang.org/x/sys/windows/zsyscall_windows.go
index e8791c82c3..5c6035ddfa 100644
--- a/backend/vendor/golang.org/x/sys/windows/zsyscall_windows.go
+++ b/backend/vendor/golang.org/x/sys/windows/zsyscall_windows.go
@@ -188,6 +188,8 @@ var (
procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
procCancelIo = modkernel32.NewProc("CancelIo")
procCancelIoEx = modkernel32.NewProc("CancelIoEx")
+ procClearCommBreak = modkernel32.NewProc("ClearCommBreak")
+ procClearCommError = modkernel32.NewProc("ClearCommError")
procCloseHandle = modkernel32.NewProc("CloseHandle")
procClosePseudoConsole = modkernel32.NewProc("ClosePseudoConsole")
procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe")
@@ -212,7 +214,9 @@ var (
procDeleteProcThreadAttributeList = modkernel32.NewProc("DeleteProcThreadAttributeList")
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
+ procDisconnectNamedPipe = modkernel32.NewProc("DisconnectNamedPipe")
procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
+ procEscapeCommFunction = modkernel32.NewProc("EscapeCommFunction")
procExitProcess = modkernel32.NewProc("ExitProcess")
procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW")
procFindClose = modkernel32.NewProc("FindClose")
@@ -236,6 +240,8 @@ var (
procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
procGetACP = modkernel32.NewProc("GetACP")
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
+ procGetCommModemStatus = modkernel32.NewProc("GetCommModemStatus")
+ procGetCommState = modkernel32.NewProc("GetCommState")
procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts")
procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
@@ -322,6 +328,7 @@ var (
procProcess32NextW = modkernel32.NewProc("Process32NextW")
procProcessIdToSessionId = modkernel32.NewProc("ProcessIdToSessionId")
procPulseEvent = modkernel32.NewProc("PulseEvent")
+ procPurgeComm = modkernel32.NewProc("PurgeComm")
procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
procQueryFullProcessImageNameW = modkernel32.NewProc("QueryFullProcessImageNameW")
procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
@@ -335,6 +342,9 @@ var (
procResetEvent = modkernel32.NewProc("ResetEvent")
procResizePseudoConsole = modkernel32.NewProc("ResizePseudoConsole")
procResumeThread = modkernel32.NewProc("ResumeThread")
+ procSetCommBreak = modkernel32.NewProc("SetCommBreak")
+ procSetCommMask = modkernel32.NewProc("SetCommMask")
+ procSetCommState = modkernel32.NewProc("SetCommState")
procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
@@ -342,7 +352,6 @@ var (
procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories")
procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW")
procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
- procSetFileValidData = modkernel32.NewProc("SetFileValidData")
procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
procSetErrorMode = modkernel32.NewProc("SetErrorMode")
procSetEvent = modkernel32.NewProc("SetEvent")
@@ -351,6 +360,7 @@ var (
procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle")
procSetFilePointer = modkernel32.NewProc("SetFilePointer")
procSetFileTime = modkernel32.NewProc("SetFileTime")
+ procSetFileValidData = modkernel32.NewProc("SetFileValidData")
procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
procSetNamedPipeHandleState = modkernel32.NewProc("SetNamedPipeHandleState")
@@ -361,6 +371,7 @@ var (
procSetStdHandle = modkernel32.NewProc("SetStdHandle")
procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
+ procSetupComm = modkernel32.NewProc("SetupComm")
procSizeofResource = modkernel32.NewProc("SizeofResource")
procSleepEx = modkernel32.NewProc("SleepEx")
procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
@@ -379,6 +390,7 @@ var (
procVirtualQueryEx = modkernel32.NewProc("VirtualQueryEx")
procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
procWTSGetActiveConsoleSessionId = modkernel32.NewProc("WTSGetActiveConsoleSessionId")
+ procWaitCommEvent = modkernel32.NewProc("WaitCommEvent")
procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
@@ -1641,6 +1653,22 @@ func CancelIoEx(s Handle, o *Overlapped) (err error) {
return
}
+func ClearCommBreak(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procClearCommBreak.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ClearCommError(handle Handle, lpErrors *uint32, lpStat *ComStat) (err error) {
+ r1, _, e1 := syscall.Syscall(procClearCommError.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(lpErrors)), uintptr(unsafe.Pointer(lpStat)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func CloseHandle(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
@@ -1845,6 +1873,14 @@ func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBuff
return
}
+func DisconnectNamedPipe(pipe Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procDisconnectNamedPipe.Addr(), 1, uintptr(pipe), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
var _p0 uint32
if bInheritHandle {
@@ -1857,6 +1893,14 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
return
}
+func EscapeCommFunction(handle Handle, dwFunc uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procEscapeCommFunction.Addr(), 2, uintptr(handle), uintptr(dwFunc), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func ExitProcess(exitcode uint32) {
syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
return
@@ -2058,6 +2102,22 @@ func GetActiveProcessorCount(groupNumber uint16) (ret uint32) {
return
}
+func GetCommModemStatus(handle Handle, lpModemStat *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetCommModemStatus.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpModemStat)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetCommState(handle Handle, lpDCB *DCB) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpDCB)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
if r1 == 0 {
@@ -2810,6 +2870,14 @@ func PulseEvent(event Handle) (err error) {
return
}
+func PurgeComm(handle Handle, dwFlags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procPurgeComm.Addr(), 2, uintptr(handle), uintptr(dwFlags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
n = uint32(r0)
@@ -2924,6 +2992,30 @@ func ResumeThread(thread Handle) (ret uint32, err error) {
return
}
+func SetCommBreak(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetCommBreak.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetCommMask(handle Handle, dwEvtMask uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetCommMask.Addr(), 2, uintptr(handle), uintptr(dwEvtMask), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetCommState(handle Handle, lpDCB *DCB) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpDCB)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
r1, _, e1 := syscall.Syscall(procSetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
if r1 == 0 {
@@ -2989,14 +3081,6 @@ func SetEndOfFile(handle Handle) (err error) {
return
}
-func SetFileValidData(handle Handle, validDataLength int64) (err error) {
- r1, _, e1 := syscall.Syscall(procSetFileValidData.Addr(), 2, uintptr(handle), uintptr(validDataLength), 0)
- if r1 == 0 {
- err = errnoErr(e1)
- }
- return
-}
-
func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
if r1 == 0 {
@@ -3060,6 +3144,14 @@ func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetim
return
}
+func SetFileValidData(handle Handle, validDataLength int64) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetFileValidData.Addr(), 2, uintptr(handle), uintptr(validDataLength), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
if r1 == 0 {
@@ -3145,6 +3237,14 @@ func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err erro
return
}
+func SetupComm(handle Handle, dwInQueue uint32, dwOutQueue uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetupComm.Addr(), 3, uintptr(handle), uintptr(dwInQueue), uintptr(dwOutQueue))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func SizeofResource(module Handle, resInfo Handle) (size uint32, err error) {
r0, _, e1 := syscall.Syscall(procSizeofResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
size = uint32(r0)
@@ -3291,6 +3391,14 @@ func WTSGetActiveConsoleSessionId() (sessionID uint32) {
return
}
+func WaitCommEvent(handle Handle, lpEvtMask *uint32, lpOverlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall(procWaitCommEvent.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(lpEvtMask)), uintptr(unsafe.Pointer(lpOverlapped)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
var _p0 uint32
if waitAll {
diff --git a/backend/vendor/modules.txt b/backend/vendor/modules.txt
index 70574bdc36..a60935e5b8 100644
--- a/backend/vendor/modules.txt
+++ b/backend/vendor/modules.txt
@@ -1,4 +1,4 @@
-# cloud.google.com/go/compute v1.23.3
+# cloud.google.com/go/compute v1.25.1
## explicit; go 1.19
cloud.google.com/go/compute/internal
# cloud.google.com/go/compute/metadata v0.2.3
@@ -7,13 +7,13 @@ cloud.google.com/go/compute/metadata
# github.com/Depado/bfchroma/v2 v2.0.0
## explicit; go 1.18
github.com/Depado/bfchroma/v2
-# github.com/PuerkitoBio/goquery v1.8.1
-## explicit; go 1.13
+# github.com/PuerkitoBio/goquery v1.9.1
+## explicit; go 1.18
github.com/PuerkitoBio/goquery
# github.com/ajg/form v1.5.1
## explicit
github.com/ajg/form
-# github.com/alecthomas/chroma/v2 v2.12.0
+# github.com/alecthomas/chroma/v2 v2.13.0
## explicit; go 1.19
github.com/alecthomas/chroma/v2
github.com/alecthomas/chroma/v2/formatters/html
@@ -32,8 +32,8 @@ github.com/cespare/xxhash/v2
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
-# github.com/dghubble/oauth1 v0.7.2
-## explicit; go 1.18
+# github.com/dghubble/oauth1 v0.7.3
+## explicit; go 1.19
github.com/dghubble/oauth1
github.com/dghubble/oauth1/twitter
# github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
@@ -49,7 +49,7 @@ github.com/didip/tollbooth/v7/limiter
# github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f
## explicit; go 1.14
github.com/didip/tollbooth_chi
-# github.com/dlclark/regexp2 v1.10.0
+# github.com/dlclark/regexp2 v1.11.0
## explicit; go 1.13
github.com/dlclark/regexp2
github.com/dlclark/regexp2/syntax
@@ -68,7 +68,7 @@ github.com/go-chi/render
github.com/go-oauth2/oauth2/v4
github.com/go-oauth2/oauth2/v4/errors
github.com/go-oauth2/oauth2/v4/server
-# github.com/go-pkgz/auth v1.22.2-0.20240117071454-f721b8c33b05
+# github.com/go-pkgz/auth v1.23.0
## explicit; go 1.21
github.com/go-pkgz/auth
github.com/go-pkgz/auth/avatar
@@ -111,8 +111,8 @@ github.com/go-pkgz/syncs
# github.com/golang-jwt/jwt v3.2.2+incompatible
## explicit
github.com/golang-jwt/jwt
-# github.com/golang/protobuf v1.5.3
-## explicit; go 1.9
+# github.com/golang/protobuf v1.5.4
+## explicit; go 1.17
github.com/golang/protobuf/proto
# github.com/golang/snappy v0.0.4
## explicit
@@ -144,8 +144,8 @@ github.com/hashicorp/golang-lru/v2/simplelru
# github.com/jessevdk/go-flags v1.5.0
## explicit; go 1.15
github.com/jessevdk/go-flags
-# github.com/klauspost/compress v1.17.4
-## explicit; go 1.19
+# github.com/klauspost/compress v1.17.7
+## explicit; go 1.20
github.com/klauspost/compress
github.com/klauspost/compress/fse
github.com/klauspost/compress/huff0
@@ -197,8 +197,8 @@ github.com/slack-go/slack/internal/backoff
github.com/slack-go/slack/internal/errorsx
github.com/slack-go/slack/internal/timex
github.com/slack-go/slack/slackutilsx
-# github.com/stretchr/testify v1.8.4
-## explicit; go 1.20
+# github.com/stretchr/testify v1.9.0
+## explicit; go 1.17
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
# github.com/xdg-go/pbkdf2 v1.0.0
@@ -213,11 +213,11 @@ github.com/xdg-go/stringprep
# github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
## explicit; go 1.12
github.com/youmark/pkcs8
-# go.etcd.io/bbolt v1.3.8
+# go.etcd.io/bbolt v1.3.9
## explicit; go 1.17
go.etcd.io/bbolt
-# go.mongodb.org/mongo-driver v1.13.1
-## explicit; go 1.13
+# go.mongodb.org/mongo-driver v1.14.0
+## explicit; go 1.18
go.mongodb.org/mongo-driver/bson
go.mongodb.org/mongo-driver/bson/bsoncodec
go.mongodb.org/mongo-driver/bson/bsonoptions
@@ -270,7 +270,7 @@ go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage
## explicit; go 1.20
go.uber.org/goleak
go.uber.org/goleak/internal/stack
-# golang.org/x/crypto v0.19.0
+# golang.org/x/crypto v0.22.0
## explicit; go 1.18
golang.org/x/crypto/acme
golang.org/x/crypto/acme/autocert
@@ -281,14 +281,14 @@ golang.org/x/crypto/scrypt
## explicit; go 1.18
golang.org/x/image/draw
golang.org/x/image/math/f64
-# golang.org/x/net v0.21.0
+# golang.org/x/net v0.24.0
## explicit; go 1.18
golang.org/x/net/html
golang.org/x/net/html/atom
golang.org/x/net/idna
golang.org/x/net/internal/socks
golang.org/x/net/proxy
-# golang.org/x/oauth2 v0.17.0
+# golang.org/x/oauth2 v0.18.0
## explicit; go 1.18
golang.org/x/oauth2
golang.org/x/oauth2/authhandler
@@ -296,8 +296,9 @@ golang.org/x/oauth2/endpoints
golang.org/x/oauth2/facebook
golang.org/x/oauth2/github
golang.org/x/oauth2/google
-golang.org/x/oauth2/google/internal/externalaccount
+golang.org/x/oauth2/google/externalaccount
golang.org/x/oauth2/google/internal/externalaccountauthorizeduser
+golang.org/x/oauth2/google/internal/impersonate
golang.org/x/oauth2/google/internal/stsexchange
golang.org/x/oauth2/internal
golang.org/x/oauth2/jws
@@ -308,7 +309,7 @@ golang.org/x/oauth2/yandex
## explicit; go 1.18
golang.org/x/sync/errgroup
golang.org/x/sync/singleflight
-# golang.org/x/sys v0.17.0
+# golang.org/x/sys v0.19.0
## explicit; go 1.18
golang.org/x/sys/unix
golang.org/x/sys/windows