From 5028417f3f1be7b9da9f83cbece810d0b443d9c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:57:44 +0000 Subject: [PATCH] Bump the go-modules-updates group in /backend with 4 updates Bumps the go-modules-updates group in /backend with 4 updates: [github.com/alecthomas/chroma/v2](https://github.com/alecthomas/chroma), [github.com/go-pkgz/jrpc](https://github.com/go-pkgz/jrpc), [golang.org/x/crypto](https://github.com/golang/crypto) and [golang.org/x/net](https://github.com/golang/net). Updates `github.com/alecthomas/chroma/v2` from 2.14.0 to 2.15.0 - [Release notes](https://github.com/alecthomas/chroma/releases) - [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml) - [Commits](https://github.com/alecthomas/chroma/compare/v2.14.0...v2.15.0) Updates `github.com/go-pkgz/jrpc` from 0.3.0 to 0.3.1 - [Release notes](https://github.com/go-pkgz/jrpc/releases) - [Commits](https://github.com/go-pkgz/jrpc/compare/v0.3.0...v0.3.1) Updates `golang.org/x/crypto` from 0.31.0 to 0.32.0 - [Commits](https://github.com/golang/crypto/compare/v0.31.0...v0.32.0) Updates `golang.org/x/net` from 0.33.0 to 0.34.0 - [Commits](https://github.com/golang/net/compare/v0.33.0...v0.34.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/chroma/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: github.com/go-pkgz/jrpc dependency-type: direct:production update-type: version-update:semver-patch dependency-group: go-modules-updates - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates ... Signed-off-by: dependabot[bot] --- backend/go.mod | 11 +- backend/go.sum | 34 +- .../alecthomas/chroma/v2/.golangci.yml | 3 + .../github.com/alecthomas/chroma/v2/README.md | 14 +- .../github.com/alecthomas/chroma/v2/colour.go | 8 +- .../v2/lexers/embedded/arangodb_aql.xml | 2 +- .../chroma/v2/lexers/embedded/atl.xml | 165 ++++ .../chroma/v2/lexers/embedded/beef.xml | 120 +++ .../chroma/v2/lexers/embedded/csv.xml | 53 ++ .../chroma/v2/lexers/embedded/gleam.xml | 4 +- .../chroma/v2/lexers/embedded/hare.xml | 2 +- .../chroma/v2/lexers/embedded/haskell.xml | 13 +- .../chroma/v2/lexers/embedded/json.xml | 3 +- .../chroma/v2/lexers/embedded/jsonata.xml | 83 ++ .../chroma/v2/lexers/embedded/jsonnet.xml | 138 +++ .../embedded/materialize_sql_dialect.xml | 154 ++-- .../chroma/v2/lexers/embedded/mcfunction.xml | 300 +++---- .../chroma/v2/lexers/embedded/nix.xml | 2 +- .../chroma/v2/lexers/embedded/nsis.xml | 59 ++ .../chroma/v2/lexers/embedded/snbt.xml | 58 ++ .../chroma/v2/lexers/embedded/typescript.xml | 20 +- .../chroma/v2/lexers/embedded/typst.xml | 108 +++ .../chroma/v2/lexers/embedded/webvtt.xml | 283 ++++++ .../chroma/v2/lexers/embedded/yaml.xml | 2 +- .../alecthomas/chroma/v2/lexers/go.go | 5 +- .../alecthomas/chroma/v2/lexers/markdown.go | 1 - .../github.com/alecthomas/chroma/v2/regexp.go | 6 + .../chroma/v2/styles/evergarden.xml | 33 + .../alecthomas/chroma/v2/styles/github.xml | 73 +- .../alecthomas/chroma/v2/styles/nordic.xml | 46 + .../alecthomas/chroma/v2/tokentype_enumer.go | 808 +++++++++--------- .../github.com/alecthomas/chroma/v2/types.go | 3 + .../github.com/didip/tollbooth/v8/.gitignore | 3 + .../didip/tollbooth/v8/.golangci.yml | 33 + .../github.com/didip/tollbooth/v8/LICENSE | 21 + .../github.com/didip/tollbooth/v8/README.md | 217 +++++ .../didip/tollbooth/v8/errors/errors.go | 15 + .../didip/tollbooth/v8/internal/time/AUTHORS | 3 + .../tollbooth/v8/internal/time/CONTRIBUTORS | 3 + .../didip/tollbooth/v8/internal/time/LICENSE | 27 + .../didip/tollbooth/v8/internal/time/PATENTS | 22 + .../tollbooth/v8/internal/time/rate/rate.go | 396 +++++++++ .../didip/tollbooth/v8/libstring/libstring.go | 100 +++ .../didip/tollbooth/v8/limiter/limiter.go | 624 ++++++++++++++ .../tollbooth/v8/limiter/limiter_options.go | 14 + .../didip/tollbooth/v8/tollbooth.go | 375 ++++++++ .../github.com/go-pkgz/jrpc/.golangci.yml | 73 +- .../vendor/github.com/go-pkgz/jrpc/server.go | 10 +- .../vendor/golang.org/x/crypto/acme/types.go | 2 +- .../x/sys/unix/syscall_dragonfly.go | 12 + .../golang.org/x/sys/windows/dll_windows.go | 11 +- backend/vendor/modules.txt | 19 +- 52 files changed, 3820 insertions(+), 774 deletions(-) create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/atl.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/beef.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/csv.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonata.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonnet.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nsis.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/snbt.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typst.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/webvtt.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/styles/evergarden.xml create mode 100644 backend/vendor/github.com/alecthomas/chroma/v2/styles/nordic.xml create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/.gitignore create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/.golangci.yml create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/LICENSE create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/README.md create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/errors/errors.go create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/internal/time/AUTHORS create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/internal/time/CONTRIBUTORS create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/internal/time/LICENSE create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/internal/time/PATENTS create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/internal/time/rate/rate.go create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/libstring/libstring.go create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter.go create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter_options.go create mode 100644 backend/vendor/github.com/didip/tollbooth/v8/tollbooth.go diff --git a/backend/go.mod b/backend/go.mod index 2363259654..bed9183aa5 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -7,14 +7,14 @@ toolchain go1.23.3 require ( github.com/Depado/bfchroma/v2 v2.0.0 github.com/PuerkitoBio/goquery v1.10.1 - github.com/alecthomas/chroma/v2 v2.14.0 + github.com/alecthomas/chroma/v2 v2.15.0 github.com/didip/tollbooth/v7 v7.0.2 github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f github.com/go-chi/chi/v5 v5.2.0 github.com/go-chi/cors v1.2.1 github.com/go-chi/render v1.0.3 github.com/go-pkgz/auth/v2 v2.0.0-20241221172452-ba01339372ba - github.com/go-pkgz/jrpc v0.3.0 + github.com/go-pkgz/jrpc v0.3.1 github.com/go-pkgz/lcw/v2 v2.0.0 github.com/go-pkgz/lgr v0.11.1 github.com/go-pkgz/notify v1.2.0 @@ -34,9 +34,9 @@ require ( github.com/stretchr/testify v1.10.0 go.etcd.io/bbolt v1.3.11 go.uber.org/goleak v1.3.0 - golang.org/x/crypto v0.31.0 + golang.org/x/crypto v0.32.0 golang.org/x/image v0.23.0 - golang.org/x/net v0.33.0 + golang.org/x/net v0.34.0 ) require ( @@ -48,6 +48,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dghubble/oauth1 v0.7.3 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/didip/tollbooth/v8 v8.0.1 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect github.com/go-oauth2/oauth2/v4 v4.5.2 // indirect github.com/go-pkgz/email v0.5.0 // indirect @@ -70,7 +71,7 @@ require ( go.mongodb.org/mongo-driver v1.17.1 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/backend/go.sum b/backend/go.sum index 801825598b..e6e73ed4a1 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -7,10 +7,10 @@ github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8W github.com/PuerkitoBio/goquery v1.10.1/go.mod h1:IYiHrOMps66ag56LEH7QYDDupKXyo5A8qrjIx3ZtujY= 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.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= -github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= -github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= +github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= +github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/chroma/v2 v2.15.0 h1:LxXTQHFoYrstG2nnV9y2X5O94sOBzf0CIUpSTbpxvMc= +github.com/alecthomas/chroma/v2 v2.15.0/go.mod h1:gUhVLrPDXPtp/f+L1jo9xepo9gL4eLwRuGAunSZMkio= 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= @@ -39,6 +39,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/didip/tollbooth/v7 v7.0.0/go.mod h1:VZhDSGl5bDSPj4wPsih3PFa4Uh9Ghv8hgacaTm5PRT4= github.com/didip/tollbooth/v7 v7.0.2 h1:WYEfusYI6g64cN0qbZgekDrYfuYBZjUZd5+RlWi69p4= github.com/didip/tollbooth/v7 v7.0.2/go.mod h1:RtRYfEmFGX70+ike5kSndSvLtQ3+F2EAmTI4Un/VXNc= +github.com/didip/tollbooth/v8 v8.0.1 h1:VAAapTo1t4Bn6bbpcHjuovwoa9u3JH++wgjbpWv+rB8= +github.com/didip/tollbooth/v8 v8.0.1/go.mod h1:oEd9l+ep373d7DmvKLc0a5gasPOev2mTewi6KPQBGJ4= 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.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= @@ -50,12 +52,10 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= -github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0= github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= -github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns= 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= @@ -67,8 +67,8 @@ github.com/go-pkgz/email v0.5.0/go.mod h1:BdxglsQnymzhfdbnncEE72a6DrucZHy6I+42LK github.com/go-pkgz/expirable-cache v0.1.0/go.mod h1:GTrEl0X+q0mPNqN6dtcQXksACnzCBQ5k/k1SwXJsZKs= github.com/go-pkgz/expirable-cache/v3 v3.0.0 h1:u3/gcu3sabLYiTCevoRKv+WzjIn5oo7P8XtiXBeRDLw= github.com/go-pkgz/expirable-cache/v3 v3.0.0/go.mod h1:2OQiDyEGQalYecLWmXprm3maPXeVb5/6/X7yRPYTzec= -github.com/go-pkgz/jrpc v0.3.0 h1:Fls38KqPsHzvp0FWfivr6cGnncC+iFBodHBqvUPY+0U= -github.com/go-pkgz/jrpc v0.3.0/go.mod h1:MFtKs75JESiSqVicsQkgN2iDFFuCd3gVT1/vKiwRi00= +github.com/go-pkgz/jrpc v0.3.1 h1:jRxnO5ppOookkL9PuOWw/IloevmzqbsKaGImTR3iALQ= +github.com/go-pkgz/jrpc v0.3.1/go.mod h1:DJg1RfhwvJpVT3YXtk8LxowB7DN5jUoZ3U4MbHnm76M= github.com/go-pkgz/lcw/v2 v2.0.0 h1:gTwXpiJBhQeA1rXuqkRuLcV79uATFna8CckH8ZBBrH0= github.com/go-pkgz/lcw/v2 v2.0.0/go.mod h1:yxJHOn+IbQBQHxUqkCtMrbGjIfdYcsBAZcVCBaL1Va8= github.com/go-pkgz/lgr v0.11.1 h1:hXFhZcznehI6imLhEa379oMOKFz7TQUmisAqb3oLOSM= @@ -77,7 +77,6 @@ github.com/go-pkgz/notify v1.2.0 h1:jqbsbWkodCDB9ffyI9fCG1bTSgidWJRS5UWD/twjU44= github.com/go-pkgz/notify v1.2.0/go.mod h1:BTHj9ly7xZpaxg91lBdxCxSmkpVQ9R6q5QviX/upeYo= github.com/go-pkgz/repeater v1.2.0 h1:oJFvjyKdTDd5RCzpzxlzYIZFFj6Zfl17rE1aUfu6UjQ= github.com/go-pkgz/repeater v1.2.0/go.mod h1:vypP6xamA53MFmafnGUucqOmALKk36xgKu2hSG73LHM= -github.com/go-pkgz/rest v1.15.6/go.mod h1:KUWAqbDteYGS/CiXftomQsKjtEOifXsJ36Ka0skYbmk= github.com/go-pkgz/rest v1.20.2 h1:6wYWo85H7xFU09FadVKKc5LKIfIpCStBXJj9F/P4COc= github.com/go-pkgz/rest v1.20.2/go.mod h1:NC2xNN/y1rIs0PY13FowKoH8rk9RhJNJ0tTbkBg8Yks= github.com/go-pkgz/syncs v1.3.2 h1:gmioASlJNy3gNosPlgvWOM2QP0Hdjzn2u+/sUShgd8E= @@ -161,7 +160,6 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= @@ -184,14 +182,11 @@ github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/btree v0.0.0-20191029221954-400434d76274/go.mod h1:huei1BkDWJ3/sLXmO+bsCNELL+Bp2Kks9OLyQFkzvA8= @@ -261,8 +256,9 @@ golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -286,8 +282,9 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= @@ -322,8 +319,9 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= 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= @@ -364,9 +362,9 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml b/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml index 668be374ab..7e98a22376 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/.golangci.yml @@ -51,6 +51,9 @@ linters: - musttag - depguard - goconst + - perfsprint + - mnd + - predeclared 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 775d3af2f8..735b556714 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/README.md +++ b/backend/vendor/github.com/alecthomas/chroma/v2/README.md @@ -39,20 +39,20 @@ translators for Pygments lexers and styles. | 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 | +| G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, Gleam, 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 | +| J | J, Java, JavaScript, JSON, Jsonnet, 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 | +| 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, NSIS | | 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 | +| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, SNBT, 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, Typst | | V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue | | W | WDTE, WebGPU Shading Language, Whiley | | X | XML, Xorg | @@ -272,7 +272,7 @@ for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`. If you edit some lexers and want to try it, open a shell in `cmd/chromad` and run: ```shell -go run . +go run . --csrf-key=securekey ``` A Link will be printed. Open it in your Browser. Now you can test on the Playground with your local changes. diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/colour.go b/backend/vendor/github.com/alecthomas/chroma/v2/colour.go index b7fd6e0e34..e33d010609 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/colour.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/colour.go @@ -141,7 +141,7 @@ func ParseColour(colour string) Colour { if err != nil { return 0 } - return Colour(n + 1) + return Colour(n + 1) //nolint:gosec } // MustParseColour is like ParseColour except it panics if the colour is invalid. @@ -162,13 +162,13 @@ func (c Colour) String() string { return fmt.Sprintf("#%06x", int(c-1)) } func (c Colour) GoString() string { return fmt.Sprintf("Colour(0x%06x)", int(c-1)) } // Red component of colour. -func (c Colour) Red() uint8 { return uint8(((c - 1) >> 16) & 0xff) } +func (c Colour) Red() uint8 { return uint8(((c - 1) >> 16) & 0xff) } //nolint:gosec // Green component of colour. -func (c Colour) Green() uint8 { return uint8(((c - 1) >> 8) & 0xff) } +func (c Colour) Green() uint8 { return uint8(((c - 1) >> 8) & 0xff) } //nolint:gosec // Blue component of colour. -func (c Colour) Blue() uint8 { return uint8((c - 1) & 0xff) } +func (c Colour) Blue() uint8 { return uint8((c - 1) & 0xff) } //nolint:gosec // Colours is an orderable set of colours. type Colours []Colour diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/arangodb_aql.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/arangodb_aql.xml index e7119737e1..434b395a11 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/arangodb_aql.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/arangodb_aql.xml @@ -152,7 +152,7 @@ - + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/atl.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/atl.xml new file mode 100644 index 0000000000..623dc205e7 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/atl.xml @@ -0,0 +1,165 @@ + + + ATL + atl + *.atl + text/x-atl + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/beef.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/beef.xml new file mode 100644 index 0000000000..031a220f29 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/beef.xml @@ -0,0 +1,120 @@ + + + Beef + beef + *.bf + text/x-beef + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/csv.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/csv.xml new file mode 100644 index 0000000000..b70c2f8b1d --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/csv.xml @@ -0,0 +1,53 @@ + + + + + CSV + csv + *.csv + text/csv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/gleam.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/gleam.xml index c706e96202..6205aa15ce 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/gleam.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/gleam.xml @@ -1,7 +1,7 @@ Gleam - gleam> + gleam *.gleam text/x-gleam @@ -114,4 +114,4 @@ - \ No newline at end of file + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/hare.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/hare.xml index ea63642284..c1f7e9433c 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/hare.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/hare.xml @@ -84,7 +84,7 @@ - + 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 5f805d6da0..1fad082316 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 @@ -95,19 +95,22 @@ - + - + - + - + - + + + + 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 3473cfd14f..a34abfa498 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 + *.jsonc *.avsc application/json true @@ -108,4 +109,4 @@ - \ No newline at end of file + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonata.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonata.xml new file mode 100644 index 0000000000..c0eafabe34 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonata.xml @@ -0,0 +1,83 @@ + + + JSONata + jsonata + *.jsonata + true + + + + + + + + + + // Spread operator + + + // Sort operator + + + // Descendant | Wildcard | Multiplication + + + // Division + + + // Comparison operators + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonnet.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonnet.xml new file mode 100644 index 0000000000..1633a5e403 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/jsonnet.xml @@ -0,0 +1,138 @@ + + + + Jsonnet + jsonnet + *.jsonnet + *.libsonnet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 index 7b22a46c60..7094ddc3ee 100644 --- 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 @@ -1,154 +1,154 @@ Materialize SQL dialect - materialize - mzsql text/x-materializesql true true + materialize + mzsql - + - + - - + + - + - + 6 12 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - - + + - + - + - - + + - + - + 12 4 - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - + + - + - - + + - - + + - + - + - - + + - - + + - - - + + + - - + + - - + + - - - + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/mcfunction.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/mcfunction.xml index 331052036d..a6aa6dbe8c 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/mcfunction.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/mcfunction.xml @@ -1,182 +1,138 @@ + - mcfunction + MCFunction mcfunction + mcf *.mcfunction - true - true + text/mcfunction - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nix.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nix.xml index 0ed040ca63..dd54d36fd5 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nix.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nix.xml @@ -106,7 +106,7 @@ - + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nsis.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nsis.xml new file mode 100644 index 0000000000..6c3a7be966 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nsis.xml @@ -0,0 +1,59 @@ + + + NSIS + nsis + nsi + nsh + *.nsi + *.nsh + text/x-nsis + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/snbt.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/snbt.xml new file mode 100644 index 0000000000..fdb12d0fe8 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/snbt.xml @@ -0,0 +1,58 @@ + + + + SNBT + snbt + *.snbt + text/snbt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typescript.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typescript.xml index 9828e92f5e..7d541cb6ce 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typescript.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typescript.xml @@ -51,6 +51,22 @@ + + + + + + + + + + + + + + + + @@ -171,7 +187,7 @@ - + @@ -276,4 +292,4 @@ - \ No newline at end of file + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typst.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typst.xml new file mode 100644 index 0000000000..330dc40fa2 --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/typst.xml @@ -0,0 +1,108 @@ + + + + Typst + typst + *.typ + text/x-typst + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/webvtt.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/webvtt.xml new file mode 100644 index 0000000000..08a7efc3ae --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/webvtt.xml @@ -0,0 +1,283 @@ + + + WebVTT + vtt + *.vtt + text/vtt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/yaml.xml b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/yaml.xml index 97a0b6ed9b..0707554164 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/yaml.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/yaml.xml @@ -53,7 +53,7 @@ - + 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 266289b7c7..60b1f71198 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/go.go @@ -13,7 +13,6 @@ var Go = Register(MustNewLexer( Aliases: []string{"go", "golang"}, Filenames: []string{"*.go"}, MimeTypes: []string{"text/x-gosrc"}, - EnsureNL: true, }, goRules, ).SetAnalyser(func(text string) float32 { @@ -32,14 +31,14 @@ func goRules() Rules { {`\n`, Text, nil}, {`\s+`, Text, nil}, {`\\\n`, Text, nil}, - {`//(.*?)\n`, CommentSingle, nil}, + {`//[^\n\r]*`, CommentSingle, nil}, {`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, {`(import|package)\b`, KeywordNamespace, nil}, {`(var|func|struct|map|chan|type|interface|const)\b`, KeywordDeclaration, nil}, {Words(``, `\b`, `break`, `default`, `select`, `case`, `defer`, `go`, `else`, `goto`, `switch`, `fallthrough`, `if`, `range`, `continue`, `for`, `return`), Keyword, nil}, {`(true|false|iota|nil)\b`, KeywordConstant, nil}, {Words(``, `\b(\()`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `int`, `int8`, `int16`, `int32`, `int64`, `float`, `float32`, `float64`, `complex64`, `complex128`, `byte`, `rune`, `string`, `bool`, `error`, `uintptr`, `print`, `println`, `panic`, `recover`, `close`, `complex`, `real`, `imag`, `len`, `cap`, `append`, `copy`, `delete`, `new`, `make`, `clear`, `min`, `max`), ByGroups(NameBuiltin, Punctuation), nil}, - {Words(``, `\b`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `int`, `int8`, `int16`, `int32`, `int64`, `float`, `float32`, `float64`, `complex64`, `complex128`, `byte`, `rune`, `string`, `bool`, `error`, `uintptr`), KeywordType, nil}, + {Words(``, `\b`, `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `int`, `int8`, `int16`, `int32`, `int64`, `float`, `float32`, `float64`, `complex64`, `complex128`, `byte`, `rune`, `string`, `bool`, `error`, `uintptr`, `any`), KeywordType, nil}, {`\d+i`, LiteralNumber, nil}, {`\d+\.\d*([Ee][-+]\d+)?i`, LiteralNumber, nil}, {`\.\d+([Ee][-+]\d+)?i`, LiteralNumber, nil}, diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go index 1fb9f5bf38..db5a89484f 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go @@ -40,7 +40,6 @@ func markdownRules() Rules { {"`[^`]+`", LiteralStringBacktick, nil}, {`[@#][\w/:]+`, NameEntity, nil}, {`(!?\[)([^]]+)(\])(\()([^)]+)(\))`, ByGroups(Text, NameTag, Text, Text, NameAttribute, Text), nil}, - {`[^\\\s]+`, Other, nil}, {`.|\n`, Other, nil}, }, } diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/regexp.go b/backend/vendor/github.com/alecthomas/chroma/v2/regexp.go index 0dcb077feb..5796726862 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/regexp.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/regexp.go @@ -194,6 +194,9 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit for len(l.iteratorStack) > 0 { n := len(l.iteratorStack) - 1 t := l.iteratorStack[n]() + if t.Type == Ignore { + continue + } if t == EOF { l.iteratorStack = l.iteratorStack[:n] continue @@ -243,6 +246,9 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit for len(l.iteratorStack) > 0 { n := len(l.iteratorStack) - 1 t := l.iteratorStack[n]() + if t.Type == Ignore { + continue + } if t == EOF { l.iteratorStack = l.iteratorStack[:n] continue diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/evergarden.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/evergarden.xml new file mode 100644 index 0000000000..da1d9b843b --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/evergarden.xml @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/github.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/github.xml index e7caee7b66..d747f65383 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/styles/github.xml +++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/github.xml @@ -1,44 +1,39 @@ \ No newline at end of file diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/styles/nordic.xml b/backend/vendor/github.com/alecthomas/chroma/v2/styles/nordic.xml new file mode 100644 index 0000000000..4c36b8e4ae --- /dev/null +++ b/backend/vendor/github.com/alecthomas/chroma/v2/styles/nordic.xml @@ -0,0 +1,46 @@ + diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/tokentype_enumer.go b/backend/vendor/github.com/alecthomas/chroma/v2/tokentype_enumer.go index 696e9ce5e9..3024264a9e 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/tokentype_enumer.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/tokentype_enumer.go @@ -7,109 +7,111 @@ import ( "strings" ) -const _TokenTypeName = "NoneOtherErrorCodeLineLineLinkLineTableTDLineTableLineHighlightLineNumbersTableLineNumbersLinePreWrapperBackgroundEOFTypeKeywordKeywordConstantKeywordDeclarationKeywordNamespaceKeywordPseudoKeywordReservedKeywordTypeNameNameAttributeNameBuiltinNameBuiltinPseudoNameClassNameConstantNameDecoratorNameEntityNameExceptionNameFunctionNameFunctionMagicNameKeywordNameLabelNameNamespaceNameOperatorNameOtherNamePseudoNamePropertyNameTagNameVariableNameVariableAnonymousNameVariableClassNameVariableGlobalNameVariableInstanceNameVariableMagicLiteralLiteralDateLiteralOtherLiteralStringLiteralStringAffixLiteralStringAtomLiteralStringBacktickLiteralStringBooleanLiteralStringCharLiteralStringDelimiterLiteralStringDocLiteralStringDoubleLiteralStringEscapeLiteralStringHeredocLiteralStringInterpolLiteralStringNameLiteralStringOtherLiteralStringRegexLiteralStringSingleLiteralStringSymbolLiteralNumberLiteralNumberBinLiteralNumberFloatLiteralNumberHexLiteralNumberIntegerLiteralNumberIntegerLongLiteralNumberOctOperatorOperatorWordPunctuationCommentCommentHashbangCommentMultilineCommentSingleCommentSpecialCommentPreprocCommentPreprocFileGenericGenericDeletedGenericEmphGenericErrorGenericHeadingGenericInsertedGenericOutputGenericPromptGenericStrongGenericSubheadingGenericTracebackGenericUnderlineTextTextWhitespaceTextSymbolTextPunctuation" -const _TokenTypeLowerName = "noneothererrorcodelinelinelinklinetabletdlinetablelinehighlightlinenumberstablelinenumberslineprewrapperbackgroundeoftypekeywordkeywordconstantkeyworddeclarationkeywordnamespacekeywordpseudokeywordreservedkeywordtypenamenameattributenamebuiltinnamebuiltinpseudonameclassnameconstantnamedecoratornameentitynameexceptionnamefunctionnamefunctionmagicnamekeywordnamelabelnamenamespacenameoperatornameothernamepseudonamepropertynametagnamevariablenamevariableanonymousnamevariableclassnamevariableglobalnamevariableinstancenamevariablemagicliteralliteraldateliteralotherliteralstringliteralstringaffixliteralstringatomliteralstringbacktickliteralstringbooleanliteralstringcharliteralstringdelimiterliteralstringdocliteralstringdoubleliteralstringescapeliteralstringheredocliteralstringinterpolliteralstringnameliteralstringotherliteralstringregexliteralstringsingleliteralstringsymbolliteralnumberliteralnumberbinliteralnumberfloatliteralnumberhexliteralnumberintegerliteralnumberintegerlongliteralnumberoctoperatoroperatorwordpunctuationcommentcommenthashbangcommentmultilinecommentsinglecommentspecialcommentpreproccommentpreprocfilegenericgenericdeletedgenericemphgenericerrorgenericheadinggenericinsertedgenericoutputgenericpromptgenericstronggenericsubheadinggenerictracebackgenericunderlinetexttextwhitespacetextsymboltextpunctuation" +const _TokenTypeName = "IgnoreNoneOtherErrorCodeLineLineLinkLineTableTDLineTableLineHighlightLineNumbersTableLineNumbersLinePreWrapperBackgroundEOFTypeKeywordKeywordConstantKeywordDeclarationKeywordNamespaceKeywordPseudoKeywordReservedKeywordTypeNameNameAttributeNameBuiltinNameBuiltinPseudoNameClassNameConstantNameDecoratorNameEntityNameExceptionNameFunctionNameFunctionMagicNameKeywordNameLabelNameNamespaceNameOperatorNameOtherNamePseudoNamePropertyNameTagNameVariableNameVariableAnonymousNameVariableClassNameVariableGlobalNameVariableInstanceNameVariableMagicLiteralLiteralDateLiteralOtherLiteralStringLiteralStringAffixLiteralStringAtomLiteralStringBacktickLiteralStringBooleanLiteralStringCharLiteralStringDelimiterLiteralStringDocLiteralStringDoubleLiteralStringEscapeLiteralStringHeredocLiteralStringInterpolLiteralStringNameLiteralStringOtherLiteralStringRegexLiteralStringSingleLiteralStringSymbolLiteralNumberLiteralNumberBinLiteralNumberFloatLiteralNumberHexLiteralNumberIntegerLiteralNumberIntegerLongLiteralNumberOctLiteralNumberByteOperatorOperatorWordPunctuationCommentCommentHashbangCommentMultilineCommentSingleCommentSpecialCommentPreprocCommentPreprocFileGenericGenericDeletedGenericEmphGenericErrorGenericHeadingGenericInsertedGenericOutputGenericPromptGenericStrongGenericSubheadingGenericTracebackGenericUnderlineTextTextWhitespaceTextSymbolTextPunctuation" +const _TokenTypeLowerName = "ignorenoneothererrorcodelinelinelinklinetabletdlinetablelinehighlightlinenumberstablelinenumberslineprewrapperbackgroundeoftypekeywordkeywordconstantkeyworddeclarationkeywordnamespacekeywordpseudokeywordreservedkeywordtypenamenameattributenamebuiltinnamebuiltinpseudonameclassnameconstantnamedecoratornameentitynameexceptionnamefunctionnamefunctionmagicnamekeywordnamelabelnamenamespacenameoperatornameothernamepseudonamepropertynametagnamevariablenamevariableanonymousnamevariableclassnamevariableglobalnamevariableinstancenamevariablemagicliteralliteraldateliteralotherliteralstringliteralstringaffixliteralstringatomliteralstringbacktickliteralstringbooleanliteralstringcharliteralstringdelimiterliteralstringdocliteralstringdoubleliteralstringescapeliteralstringheredocliteralstringinterpolliteralstringnameliteralstringotherliteralstringregexliteralstringsingleliteralstringsymbolliteralnumberliteralnumberbinliteralnumberfloatliteralnumberhexliteralnumberintegerliteralnumberintegerlongliteralnumberoctliteralnumberbyteoperatoroperatorwordpunctuationcommentcommenthashbangcommentmultilinecommentsinglecommentspecialcommentpreproccommentpreprocfilegenericgenericdeletedgenericemphgenericerrorgenericheadinggenericinsertedgenericoutputgenericpromptgenericstronggenericsubheadinggenerictracebackgenericunderlinetexttextwhitespacetextsymboltextpunctuation" var _TokenTypeMap = map[TokenType]string{ - -13: _TokenTypeName[0:4], - -12: _TokenTypeName[4:9], - -11: _TokenTypeName[9:14], - -10: _TokenTypeName[14:22], - -9: _TokenTypeName[22:30], - -8: _TokenTypeName[30:41], - -7: _TokenTypeName[41:50], - -6: _TokenTypeName[50:63], - -5: _TokenTypeName[63:79], - -4: _TokenTypeName[79:90], - -3: _TokenTypeName[90:94], - -2: _TokenTypeName[94:104], - -1: _TokenTypeName[104:114], - 0: _TokenTypeName[114:121], - 1000: _TokenTypeName[121:128], - 1001: _TokenTypeName[128:143], - 1002: _TokenTypeName[143:161], - 1003: _TokenTypeName[161:177], - 1004: _TokenTypeName[177:190], - 1005: _TokenTypeName[190:205], - 1006: _TokenTypeName[205:216], - 2000: _TokenTypeName[216:220], - 2001: _TokenTypeName[220:233], - 2002: _TokenTypeName[233:244], - 2003: _TokenTypeName[244:261], - 2004: _TokenTypeName[261:270], - 2005: _TokenTypeName[270:282], - 2006: _TokenTypeName[282:295], - 2007: _TokenTypeName[295:305], - 2008: _TokenTypeName[305:318], - 2009: _TokenTypeName[318:330], - 2010: _TokenTypeName[330:347], - 2011: _TokenTypeName[347:358], - 2012: _TokenTypeName[358:367], - 2013: _TokenTypeName[367:380], - 2014: _TokenTypeName[380:392], - 2015: _TokenTypeName[392:401], - 2016: _TokenTypeName[401:411], - 2017: _TokenTypeName[411:423], - 2018: _TokenTypeName[423:430], - 2019: _TokenTypeName[430:442], - 2020: _TokenTypeName[442:463], - 2021: _TokenTypeName[463:480], - 2022: _TokenTypeName[480:498], - 2023: _TokenTypeName[498:518], - 2024: _TokenTypeName[518:535], - 3000: _TokenTypeName[535:542], - 3001: _TokenTypeName[542:553], - 3002: _TokenTypeName[553:565], - 3100: _TokenTypeName[565:578], - 3101: _TokenTypeName[578:596], - 3102: _TokenTypeName[596:613], - 3103: _TokenTypeName[613:634], - 3104: _TokenTypeName[634:654], - 3105: _TokenTypeName[654:671], - 3106: _TokenTypeName[671:693], - 3107: _TokenTypeName[693:709], - 3108: _TokenTypeName[709:728], - 3109: _TokenTypeName[728:747], - 3110: _TokenTypeName[747:767], - 3111: _TokenTypeName[767:788], - 3112: _TokenTypeName[788:805], - 3113: _TokenTypeName[805:823], - 3114: _TokenTypeName[823:841], - 3115: _TokenTypeName[841:860], - 3116: _TokenTypeName[860:879], - 3200: _TokenTypeName[879:892], - 3201: _TokenTypeName[892:908], - 3202: _TokenTypeName[908:926], - 3203: _TokenTypeName[926:942], - 3204: _TokenTypeName[942:962], - 3205: _TokenTypeName[962:986], - 3206: _TokenTypeName[986:1002], - 4000: _TokenTypeName[1002:1010], - 4001: _TokenTypeName[1010:1022], - 5000: _TokenTypeName[1022:1033], - 6000: _TokenTypeName[1033:1040], - 6001: _TokenTypeName[1040:1055], - 6002: _TokenTypeName[1055:1071], - 6003: _TokenTypeName[1071:1084], - 6004: _TokenTypeName[1084:1098], - 6100: _TokenTypeName[1098:1112], - 6101: _TokenTypeName[1112:1130], - 7000: _TokenTypeName[1130:1137], - 7001: _TokenTypeName[1137:1151], - 7002: _TokenTypeName[1151:1162], - 7003: _TokenTypeName[1162:1174], - 7004: _TokenTypeName[1174:1188], - 7005: _TokenTypeName[1188:1203], - 7006: _TokenTypeName[1203:1216], - 7007: _TokenTypeName[1216:1229], - 7008: _TokenTypeName[1229:1242], - 7009: _TokenTypeName[1242:1259], - 7010: _TokenTypeName[1259:1275], - 7011: _TokenTypeName[1275:1291], - 8000: _TokenTypeName[1291:1295], - 8001: _TokenTypeName[1295:1309], - 8002: _TokenTypeName[1309:1319], - 8003: _TokenTypeName[1319:1334], + -14: _TokenTypeName[0:6], + -13: _TokenTypeName[6:10], + -12: _TokenTypeName[10:15], + -11: _TokenTypeName[15:20], + -10: _TokenTypeName[20:28], + -9: _TokenTypeName[28:36], + -8: _TokenTypeName[36:47], + -7: _TokenTypeName[47:56], + -6: _TokenTypeName[56:69], + -5: _TokenTypeName[69:85], + -4: _TokenTypeName[85:96], + -3: _TokenTypeName[96:100], + -2: _TokenTypeName[100:110], + -1: _TokenTypeName[110:120], + 0: _TokenTypeName[120:127], + 1000: _TokenTypeName[127:134], + 1001: _TokenTypeName[134:149], + 1002: _TokenTypeName[149:167], + 1003: _TokenTypeName[167:183], + 1004: _TokenTypeName[183:196], + 1005: _TokenTypeName[196:211], + 1006: _TokenTypeName[211:222], + 2000: _TokenTypeName[222:226], + 2001: _TokenTypeName[226:239], + 2002: _TokenTypeName[239:250], + 2003: _TokenTypeName[250:267], + 2004: _TokenTypeName[267:276], + 2005: _TokenTypeName[276:288], + 2006: _TokenTypeName[288:301], + 2007: _TokenTypeName[301:311], + 2008: _TokenTypeName[311:324], + 2009: _TokenTypeName[324:336], + 2010: _TokenTypeName[336:353], + 2011: _TokenTypeName[353:364], + 2012: _TokenTypeName[364:373], + 2013: _TokenTypeName[373:386], + 2014: _TokenTypeName[386:398], + 2015: _TokenTypeName[398:407], + 2016: _TokenTypeName[407:417], + 2017: _TokenTypeName[417:429], + 2018: _TokenTypeName[429:436], + 2019: _TokenTypeName[436:448], + 2020: _TokenTypeName[448:469], + 2021: _TokenTypeName[469:486], + 2022: _TokenTypeName[486:504], + 2023: _TokenTypeName[504:524], + 2024: _TokenTypeName[524:541], + 3000: _TokenTypeName[541:548], + 3001: _TokenTypeName[548:559], + 3002: _TokenTypeName[559:571], + 3100: _TokenTypeName[571:584], + 3101: _TokenTypeName[584:602], + 3102: _TokenTypeName[602:619], + 3103: _TokenTypeName[619:640], + 3104: _TokenTypeName[640:660], + 3105: _TokenTypeName[660:677], + 3106: _TokenTypeName[677:699], + 3107: _TokenTypeName[699:715], + 3108: _TokenTypeName[715:734], + 3109: _TokenTypeName[734:753], + 3110: _TokenTypeName[753:773], + 3111: _TokenTypeName[773:794], + 3112: _TokenTypeName[794:811], + 3113: _TokenTypeName[811:829], + 3114: _TokenTypeName[829:847], + 3115: _TokenTypeName[847:866], + 3116: _TokenTypeName[866:885], + 3200: _TokenTypeName[885:898], + 3201: _TokenTypeName[898:914], + 3202: _TokenTypeName[914:932], + 3203: _TokenTypeName[932:948], + 3204: _TokenTypeName[948:968], + 3205: _TokenTypeName[968:992], + 3206: _TokenTypeName[992:1008], + 3207: _TokenTypeName[1008:1025], + 4000: _TokenTypeName[1025:1033], + 4001: _TokenTypeName[1033:1045], + 5000: _TokenTypeName[1045:1056], + 6000: _TokenTypeName[1056:1063], + 6001: _TokenTypeName[1063:1078], + 6002: _TokenTypeName[1078:1094], + 6003: _TokenTypeName[1094:1107], + 6004: _TokenTypeName[1107:1121], + 6100: _TokenTypeName[1121:1135], + 6101: _TokenTypeName[1135:1153], + 7000: _TokenTypeName[1153:1160], + 7001: _TokenTypeName[1160:1174], + 7002: _TokenTypeName[1174:1185], + 7003: _TokenTypeName[1185:1197], + 7004: _TokenTypeName[1197:1211], + 7005: _TokenTypeName[1211:1226], + 7006: _TokenTypeName[1226:1239], + 7007: _TokenTypeName[1239:1252], + 7008: _TokenTypeName[1252:1265], + 7009: _TokenTypeName[1265:1282], + 7010: _TokenTypeName[1282:1298], + 7011: _TokenTypeName[1298:1314], + 8000: _TokenTypeName[1314:1318], + 8001: _TokenTypeName[1318:1332], + 8002: _TokenTypeName[1332:1342], + 8003: _TokenTypeName[1342:1357], } func (i TokenType) String() string { @@ -123,6 +125,7 @@ func (i TokenType) String() string { // Re-run the stringer command to generate them again. func _TokenTypeNoOp() { var x [1]struct{} + _ = x[Ignore-(-14)] _ = x[None-(-13)] _ = x[Other-(-12)] _ = x[Error-(-11)] @@ -196,6 +199,7 @@ func _TokenTypeNoOp() { _ = x[LiteralNumberInteger-(3204)] _ = x[LiteralNumberIntegerLong-(3205)] _ = x[LiteralNumberOct-(3206)] + _ = x[LiteralNumberByte-(3207)] _ = x[Operator-(4000)] _ = x[OperatorWord-(4001)] _ = x[Punctuation-(5000)] @@ -224,309 +228,315 @@ func _TokenTypeNoOp() { _ = x[TextPunctuation-(8003)] } -var _TokenTypeValues = []TokenType{None, Other, Error, CodeLine, LineLink, LineTableTD, LineTable, LineHighlight, LineNumbersTable, LineNumbers, Line, PreWrapper, Background, EOFType, Keyword, KeywordConstant, KeywordDeclaration, KeywordNamespace, KeywordPseudo, KeywordReserved, KeywordType, Name, NameAttribute, NameBuiltin, NameBuiltinPseudo, NameClass, NameConstant, NameDecorator, NameEntity, NameException, NameFunction, NameFunctionMagic, NameKeyword, NameLabel, NameNamespace, NameOperator, NameOther, NamePseudo, NameProperty, NameTag, NameVariable, NameVariableAnonymous, NameVariableClass, NameVariableGlobal, NameVariableInstance, NameVariableMagic, Literal, LiteralDate, LiteralOther, LiteralString, LiteralStringAffix, LiteralStringAtom, LiteralStringBacktick, LiteralStringBoolean, LiteralStringChar, LiteralStringDelimiter, LiteralStringDoc, LiteralStringDouble, LiteralStringEscape, LiteralStringHeredoc, LiteralStringInterpol, LiteralStringName, LiteralStringOther, LiteralStringRegex, LiteralStringSingle, LiteralStringSymbol, LiteralNumber, LiteralNumberBin, LiteralNumberFloat, LiteralNumberHex, LiteralNumberInteger, LiteralNumberIntegerLong, LiteralNumberOct, Operator, OperatorWord, Punctuation, Comment, CommentHashbang, CommentMultiline, CommentSingle, CommentSpecial, CommentPreproc, CommentPreprocFile, Generic, GenericDeleted, GenericEmph, GenericError, GenericHeading, GenericInserted, GenericOutput, GenericPrompt, GenericStrong, GenericSubheading, GenericTraceback, GenericUnderline, Text, TextWhitespace, TextSymbol, TextPunctuation} +var _TokenTypeValues = []TokenType{Ignore, None, Other, Error, CodeLine, LineLink, LineTableTD, LineTable, LineHighlight, LineNumbersTable, LineNumbers, Line, PreWrapper, Background, EOFType, Keyword, KeywordConstant, KeywordDeclaration, KeywordNamespace, KeywordPseudo, KeywordReserved, KeywordType, Name, NameAttribute, NameBuiltin, NameBuiltinPseudo, NameClass, NameConstant, NameDecorator, NameEntity, NameException, NameFunction, NameFunctionMagic, NameKeyword, NameLabel, NameNamespace, NameOperator, NameOther, NamePseudo, NameProperty, NameTag, NameVariable, NameVariableAnonymous, NameVariableClass, NameVariableGlobal, NameVariableInstance, NameVariableMagic, Literal, LiteralDate, LiteralOther, LiteralString, LiteralStringAffix, LiteralStringAtom, LiteralStringBacktick, LiteralStringBoolean, LiteralStringChar, LiteralStringDelimiter, LiteralStringDoc, LiteralStringDouble, LiteralStringEscape, LiteralStringHeredoc, LiteralStringInterpol, LiteralStringName, LiteralStringOther, LiteralStringRegex, LiteralStringSingle, LiteralStringSymbol, LiteralNumber, LiteralNumberBin, LiteralNumberFloat, LiteralNumberHex, LiteralNumberInteger, LiteralNumberIntegerLong, LiteralNumberOct, LiteralNumberByte, Operator, OperatorWord, Punctuation, Comment, CommentHashbang, CommentMultiline, CommentSingle, CommentSpecial, CommentPreproc, CommentPreprocFile, Generic, GenericDeleted, GenericEmph, GenericError, GenericHeading, GenericInserted, GenericOutput, GenericPrompt, GenericStrong, GenericSubheading, GenericTraceback, GenericUnderline, Text, TextWhitespace, TextSymbol, TextPunctuation} var _TokenTypeNameToValueMap = map[string]TokenType{ - _TokenTypeName[0:4]: None, - _TokenTypeLowerName[0:4]: None, - _TokenTypeName[4:9]: Other, - _TokenTypeLowerName[4:9]: Other, - _TokenTypeName[9:14]: Error, - _TokenTypeLowerName[9:14]: Error, - _TokenTypeName[14:22]: CodeLine, - _TokenTypeLowerName[14:22]: CodeLine, - _TokenTypeName[22:30]: LineLink, - _TokenTypeLowerName[22:30]: LineLink, - _TokenTypeName[30:41]: LineTableTD, - _TokenTypeLowerName[30:41]: LineTableTD, - _TokenTypeName[41:50]: LineTable, - _TokenTypeLowerName[41:50]: LineTable, - _TokenTypeName[50:63]: LineHighlight, - _TokenTypeLowerName[50:63]: LineHighlight, - _TokenTypeName[63:79]: LineNumbersTable, - _TokenTypeLowerName[63:79]: LineNumbersTable, - _TokenTypeName[79:90]: LineNumbers, - _TokenTypeLowerName[79:90]: LineNumbers, - _TokenTypeName[90:94]: Line, - _TokenTypeLowerName[90:94]: Line, - _TokenTypeName[94:104]: PreWrapper, - _TokenTypeLowerName[94:104]: PreWrapper, - _TokenTypeName[104:114]: Background, - _TokenTypeLowerName[104:114]: Background, - _TokenTypeName[114:121]: EOFType, - _TokenTypeLowerName[114:121]: EOFType, - _TokenTypeName[121:128]: Keyword, - _TokenTypeLowerName[121:128]: Keyword, - _TokenTypeName[128:143]: KeywordConstant, - _TokenTypeLowerName[128:143]: KeywordConstant, - _TokenTypeName[143:161]: KeywordDeclaration, - _TokenTypeLowerName[143:161]: KeywordDeclaration, - _TokenTypeName[161:177]: KeywordNamespace, - _TokenTypeLowerName[161:177]: KeywordNamespace, - _TokenTypeName[177:190]: KeywordPseudo, - _TokenTypeLowerName[177:190]: KeywordPseudo, - _TokenTypeName[190:205]: KeywordReserved, - _TokenTypeLowerName[190:205]: KeywordReserved, - _TokenTypeName[205:216]: KeywordType, - _TokenTypeLowerName[205:216]: KeywordType, - _TokenTypeName[216:220]: Name, - _TokenTypeLowerName[216:220]: Name, - _TokenTypeName[220:233]: NameAttribute, - _TokenTypeLowerName[220:233]: NameAttribute, - _TokenTypeName[233:244]: NameBuiltin, - _TokenTypeLowerName[233:244]: NameBuiltin, - _TokenTypeName[244:261]: NameBuiltinPseudo, - _TokenTypeLowerName[244:261]: NameBuiltinPseudo, - _TokenTypeName[261:270]: NameClass, - _TokenTypeLowerName[261:270]: NameClass, - _TokenTypeName[270:282]: NameConstant, - _TokenTypeLowerName[270:282]: NameConstant, - _TokenTypeName[282:295]: NameDecorator, - _TokenTypeLowerName[282:295]: NameDecorator, - _TokenTypeName[295:305]: NameEntity, - _TokenTypeLowerName[295:305]: NameEntity, - _TokenTypeName[305:318]: NameException, - _TokenTypeLowerName[305:318]: NameException, - _TokenTypeName[318:330]: NameFunction, - _TokenTypeLowerName[318:330]: NameFunction, - _TokenTypeName[330:347]: NameFunctionMagic, - _TokenTypeLowerName[330:347]: NameFunctionMagic, - _TokenTypeName[347:358]: NameKeyword, - _TokenTypeLowerName[347:358]: NameKeyword, - _TokenTypeName[358:367]: NameLabel, - _TokenTypeLowerName[358:367]: NameLabel, - _TokenTypeName[367:380]: NameNamespace, - _TokenTypeLowerName[367:380]: NameNamespace, - _TokenTypeName[380:392]: NameOperator, - _TokenTypeLowerName[380:392]: NameOperator, - _TokenTypeName[392:401]: NameOther, - _TokenTypeLowerName[392:401]: NameOther, - _TokenTypeName[401:411]: NamePseudo, - _TokenTypeLowerName[401:411]: NamePseudo, - _TokenTypeName[411:423]: NameProperty, - _TokenTypeLowerName[411:423]: NameProperty, - _TokenTypeName[423:430]: NameTag, - _TokenTypeLowerName[423:430]: NameTag, - _TokenTypeName[430:442]: NameVariable, - _TokenTypeLowerName[430:442]: NameVariable, - _TokenTypeName[442:463]: NameVariableAnonymous, - _TokenTypeLowerName[442:463]: NameVariableAnonymous, - _TokenTypeName[463:480]: NameVariableClass, - _TokenTypeLowerName[463:480]: NameVariableClass, - _TokenTypeName[480:498]: NameVariableGlobal, - _TokenTypeLowerName[480:498]: NameVariableGlobal, - _TokenTypeName[498:518]: NameVariableInstance, - _TokenTypeLowerName[498:518]: NameVariableInstance, - _TokenTypeName[518:535]: NameVariableMagic, - _TokenTypeLowerName[518:535]: NameVariableMagic, - _TokenTypeName[535:542]: Literal, - _TokenTypeLowerName[535:542]: Literal, - _TokenTypeName[542:553]: LiteralDate, - _TokenTypeLowerName[542:553]: LiteralDate, - _TokenTypeName[553:565]: LiteralOther, - _TokenTypeLowerName[553:565]: LiteralOther, - _TokenTypeName[565:578]: LiteralString, - _TokenTypeLowerName[565:578]: LiteralString, - _TokenTypeName[578:596]: LiteralStringAffix, - _TokenTypeLowerName[578:596]: LiteralStringAffix, - _TokenTypeName[596:613]: LiteralStringAtom, - _TokenTypeLowerName[596:613]: LiteralStringAtom, - _TokenTypeName[613:634]: LiteralStringBacktick, - _TokenTypeLowerName[613:634]: LiteralStringBacktick, - _TokenTypeName[634:654]: LiteralStringBoolean, - _TokenTypeLowerName[634:654]: LiteralStringBoolean, - _TokenTypeName[654:671]: LiteralStringChar, - _TokenTypeLowerName[654:671]: LiteralStringChar, - _TokenTypeName[671:693]: LiteralStringDelimiter, - _TokenTypeLowerName[671:693]: LiteralStringDelimiter, - _TokenTypeName[693:709]: LiteralStringDoc, - _TokenTypeLowerName[693:709]: LiteralStringDoc, - _TokenTypeName[709:728]: LiteralStringDouble, - _TokenTypeLowerName[709:728]: LiteralStringDouble, - _TokenTypeName[728:747]: LiteralStringEscape, - _TokenTypeLowerName[728:747]: LiteralStringEscape, - _TokenTypeName[747:767]: LiteralStringHeredoc, - _TokenTypeLowerName[747:767]: LiteralStringHeredoc, - _TokenTypeName[767:788]: LiteralStringInterpol, - _TokenTypeLowerName[767:788]: LiteralStringInterpol, - _TokenTypeName[788:805]: LiteralStringName, - _TokenTypeLowerName[788:805]: LiteralStringName, - _TokenTypeName[805:823]: LiteralStringOther, - _TokenTypeLowerName[805:823]: LiteralStringOther, - _TokenTypeName[823:841]: LiteralStringRegex, - _TokenTypeLowerName[823:841]: LiteralStringRegex, - _TokenTypeName[841:860]: LiteralStringSingle, - _TokenTypeLowerName[841:860]: LiteralStringSingle, - _TokenTypeName[860:879]: LiteralStringSymbol, - _TokenTypeLowerName[860:879]: LiteralStringSymbol, - _TokenTypeName[879:892]: LiteralNumber, - _TokenTypeLowerName[879:892]: LiteralNumber, - _TokenTypeName[892:908]: LiteralNumberBin, - _TokenTypeLowerName[892:908]: LiteralNumberBin, - _TokenTypeName[908:926]: LiteralNumberFloat, - _TokenTypeLowerName[908:926]: LiteralNumberFloat, - _TokenTypeName[926:942]: LiteralNumberHex, - _TokenTypeLowerName[926:942]: LiteralNumberHex, - _TokenTypeName[942:962]: LiteralNumberInteger, - _TokenTypeLowerName[942:962]: LiteralNumberInteger, - _TokenTypeName[962:986]: LiteralNumberIntegerLong, - _TokenTypeLowerName[962:986]: LiteralNumberIntegerLong, - _TokenTypeName[986:1002]: LiteralNumberOct, - _TokenTypeLowerName[986:1002]: LiteralNumberOct, - _TokenTypeName[1002:1010]: Operator, - _TokenTypeLowerName[1002:1010]: Operator, - _TokenTypeName[1010:1022]: OperatorWord, - _TokenTypeLowerName[1010:1022]: OperatorWord, - _TokenTypeName[1022:1033]: Punctuation, - _TokenTypeLowerName[1022:1033]: Punctuation, - _TokenTypeName[1033:1040]: Comment, - _TokenTypeLowerName[1033:1040]: Comment, - _TokenTypeName[1040:1055]: CommentHashbang, - _TokenTypeLowerName[1040:1055]: CommentHashbang, - _TokenTypeName[1055:1071]: CommentMultiline, - _TokenTypeLowerName[1055:1071]: CommentMultiline, - _TokenTypeName[1071:1084]: CommentSingle, - _TokenTypeLowerName[1071:1084]: CommentSingle, - _TokenTypeName[1084:1098]: CommentSpecial, - _TokenTypeLowerName[1084:1098]: CommentSpecial, - _TokenTypeName[1098:1112]: CommentPreproc, - _TokenTypeLowerName[1098:1112]: CommentPreproc, - _TokenTypeName[1112:1130]: CommentPreprocFile, - _TokenTypeLowerName[1112:1130]: CommentPreprocFile, - _TokenTypeName[1130:1137]: Generic, - _TokenTypeLowerName[1130:1137]: Generic, - _TokenTypeName[1137:1151]: GenericDeleted, - _TokenTypeLowerName[1137:1151]: GenericDeleted, - _TokenTypeName[1151:1162]: GenericEmph, - _TokenTypeLowerName[1151:1162]: GenericEmph, - _TokenTypeName[1162:1174]: GenericError, - _TokenTypeLowerName[1162:1174]: GenericError, - _TokenTypeName[1174:1188]: GenericHeading, - _TokenTypeLowerName[1174:1188]: GenericHeading, - _TokenTypeName[1188:1203]: GenericInserted, - _TokenTypeLowerName[1188:1203]: GenericInserted, - _TokenTypeName[1203:1216]: GenericOutput, - _TokenTypeLowerName[1203:1216]: GenericOutput, - _TokenTypeName[1216:1229]: GenericPrompt, - _TokenTypeLowerName[1216:1229]: GenericPrompt, - _TokenTypeName[1229:1242]: GenericStrong, - _TokenTypeLowerName[1229:1242]: GenericStrong, - _TokenTypeName[1242:1259]: GenericSubheading, - _TokenTypeLowerName[1242:1259]: GenericSubheading, - _TokenTypeName[1259:1275]: GenericTraceback, - _TokenTypeLowerName[1259:1275]: GenericTraceback, - _TokenTypeName[1275:1291]: GenericUnderline, - _TokenTypeLowerName[1275:1291]: GenericUnderline, - _TokenTypeName[1291:1295]: Text, - _TokenTypeLowerName[1291:1295]: Text, - _TokenTypeName[1295:1309]: TextWhitespace, - _TokenTypeLowerName[1295:1309]: TextWhitespace, - _TokenTypeName[1309:1319]: TextSymbol, - _TokenTypeLowerName[1309:1319]: TextSymbol, - _TokenTypeName[1319:1334]: TextPunctuation, - _TokenTypeLowerName[1319:1334]: TextPunctuation, + _TokenTypeName[0:6]: Ignore, + _TokenTypeLowerName[0:6]: Ignore, + _TokenTypeName[6:10]: None, + _TokenTypeLowerName[6:10]: None, + _TokenTypeName[10:15]: Other, + _TokenTypeLowerName[10:15]: Other, + _TokenTypeName[15:20]: Error, + _TokenTypeLowerName[15:20]: Error, + _TokenTypeName[20:28]: CodeLine, + _TokenTypeLowerName[20:28]: CodeLine, + _TokenTypeName[28:36]: LineLink, + _TokenTypeLowerName[28:36]: LineLink, + _TokenTypeName[36:47]: LineTableTD, + _TokenTypeLowerName[36:47]: LineTableTD, + _TokenTypeName[47:56]: LineTable, + _TokenTypeLowerName[47:56]: LineTable, + _TokenTypeName[56:69]: LineHighlight, + _TokenTypeLowerName[56:69]: LineHighlight, + _TokenTypeName[69:85]: LineNumbersTable, + _TokenTypeLowerName[69:85]: LineNumbersTable, + _TokenTypeName[85:96]: LineNumbers, + _TokenTypeLowerName[85:96]: LineNumbers, + _TokenTypeName[96:100]: Line, + _TokenTypeLowerName[96:100]: Line, + _TokenTypeName[100:110]: PreWrapper, + _TokenTypeLowerName[100:110]: PreWrapper, + _TokenTypeName[110:120]: Background, + _TokenTypeLowerName[110:120]: Background, + _TokenTypeName[120:127]: EOFType, + _TokenTypeLowerName[120:127]: EOFType, + _TokenTypeName[127:134]: Keyword, + _TokenTypeLowerName[127:134]: Keyword, + _TokenTypeName[134:149]: KeywordConstant, + _TokenTypeLowerName[134:149]: KeywordConstant, + _TokenTypeName[149:167]: KeywordDeclaration, + _TokenTypeLowerName[149:167]: KeywordDeclaration, + _TokenTypeName[167:183]: KeywordNamespace, + _TokenTypeLowerName[167:183]: KeywordNamespace, + _TokenTypeName[183:196]: KeywordPseudo, + _TokenTypeLowerName[183:196]: KeywordPseudo, + _TokenTypeName[196:211]: KeywordReserved, + _TokenTypeLowerName[196:211]: KeywordReserved, + _TokenTypeName[211:222]: KeywordType, + _TokenTypeLowerName[211:222]: KeywordType, + _TokenTypeName[222:226]: Name, + _TokenTypeLowerName[222:226]: Name, + _TokenTypeName[226:239]: NameAttribute, + _TokenTypeLowerName[226:239]: NameAttribute, + _TokenTypeName[239:250]: NameBuiltin, + _TokenTypeLowerName[239:250]: NameBuiltin, + _TokenTypeName[250:267]: NameBuiltinPseudo, + _TokenTypeLowerName[250:267]: NameBuiltinPseudo, + _TokenTypeName[267:276]: NameClass, + _TokenTypeLowerName[267:276]: NameClass, + _TokenTypeName[276:288]: NameConstant, + _TokenTypeLowerName[276:288]: NameConstant, + _TokenTypeName[288:301]: NameDecorator, + _TokenTypeLowerName[288:301]: NameDecorator, + _TokenTypeName[301:311]: NameEntity, + _TokenTypeLowerName[301:311]: NameEntity, + _TokenTypeName[311:324]: NameException, + _TokenTypeLowerName[311:324]: NameException, + _TokenTypeName[324:336]: NameFunction, + _TokenTypeLowerName[324:336]: NameFunction, + _TokenTypeName[336:353]: NameFunctionMagic, + _TokenTypeLowerName[336:353]: NameFunctionMagic, + _TokenTypeName[353:364]: NameKeyword, + _TokenTypeLowerName[353:364]: NameKeyword, + _TokenTypeName[364:373]: NameLabel, + _TokenTypeLowerName[364:373]: NameLabel, + _TokenTypeName[373:386]: NameNamespace, + _TokenTypeLowerName[373:386]: NameNamespace, + _TokenTypeName[386:398]: NameOperator, + _TokenTypeLowerName[386:398]: NameOperator, + _TokenTypeName[398:407]: NameOther, + _TokenTypeLowerName[398:407]: NameOther, + _TokenTypeName[407:417]: NamePseudo, + _TokenTypeLowerName[407:417]: NamePseudo, + _TokenTypeName[417:429]: NameProperty, + _TokenTypeLowerName[417:429]: NameProperty, + _TokenTypeName[429:436]: NameTag, + _TokenTypeLowerName[429:436]: NameTag, + _TokenTypeName[436:448]: NameVariable, + _TokenTypeLowerName[436:448]: NameVariable, + _TokenTypeName[448:469]: NameVariableAnonymous, + _TokenTypeLowerName[448:469]: NameVariableAnonymous, + _TokenTypeName[469:486]: NameVariableClass, + _TokenTypeLowerName[469:486]: NameVariableClass, + _TokenTypeName[486:504]: NameVariableGlobal, + _TokenTypeLowerName[486:504]: NameVariableGlobal, + _TokenTypeName[504:524]: NameVariableInstance, + _TokenTypeLowerName[504:524]: NameVariableInstance, + _TokenTypeName[524:541]: NameVariableMagic, + _TokenTypeLowerName[524:541]: NameVariableMagic, + _TokenTypeName[541:548]: Literal, + _TokenTypeLowerName[541:548]: Literal, + _TokenTypeName[548:559]: LiteralDate, + _TokenTypeLowerName[548:559]: LiteralDate, + _TokenTypeName[559:571]: LiteralOther, + _TokenTypeLowerName[559:571]: LiteralOther, + _TokenTypeName[571:584]: LiteralString, + _TokenTypeLowerName[571:584]: LiteralString, + _TokenTypeName[584:602]: LiteralStringAffix, + _TokenTypeLowerName[584:602]: LiteralStringAffix, + _TokenTypeName[602:619]: LiteralStringAtom, + _TokenTypeLowerName[602:619]: LiteralStringAtom, + _TokenTypeName[619:640]: LiteralStringBacktick, + _TokenTypeLowerName[619:640]: LiteralStringBacktick, + _TokenTypeName[640:660]: LiteralStringBoolean, + _TokenTypeLowerName[640:660]: LiteralStringBoolean, + _TokenTypeName[660:677]: LiteralStringChar, + _TokenTypeLowerName[660:677]: LiteralStringChar, + _TokenTypeName[677:699]: LiteralStringDelimiter, + _TokenTypeLowerName[677:699]: LiteralStringDelimiter, + _TokenTypeName[699:715]: LiteralStringDoc, + _TokenTypeLowerName[699:715]: LiteralStringDoc, + _TokenTypeName[715:734]: LiteralStringDouble, + _TokenTypeLowerName[715:734]: LiteralStringDouble, + _TokenTypeName[734:753]: LiteralStringEscape, + _TokenTypeLowerName[734:753]: LiteralStringEscape, + _TokenTypeName[753:773]: LiteralStringHeredoc, + _TokenTypeLowerName[753:773]: LiteralStringHeredoc, + _TokenTypeName[773:794]: LiteralStringInterpol, + _TokenTypeLowerName[773:794]: LiteralStringInterpol, + _TokenTypeName[794:811]: LiteralStringName, + _TokenTypeLowerName[794:811]: LiteralStringName, + _TokenTypeName[811:829]: LiteralStringOther, + _TokenTypeLowerName[811:829]: LiteralStringOther, + _TokenTypeName[829:847]: LiteralStringRegex, + _TokenTypeLowerName[829:847]: LiteralStringRegex, + _TokenTypeName[847:866]: LiteralStringSingle, + _TokenTypeLowerName[847:866]: LiteralStringSingle, + _TokenTypeName[866:885]: LiteralStringSymbol, + _TokenTypeLowerName[866:885]: LiteralStringSymbol, + _TokenTypeName[885:898]: LiteralNumber, + _TokenTypeLowerName[885:898]: LiteralNumber, + _TokenTypeName[898:914]: LiteralNumberBin, + _TokenTypeLowerName[898:914]: LiteralNumberBin, + _TokenTypeName[914:932]: LiteralNumberFloat, + _TokenTypeLowerName[914:932]: LiteralNumberFloat, + _TokenTypeName[932:948]: LiteralNumberHex, + _TokenTypeLowerName[932:948]: LiteralNumberHex, + _TokenTypeName[948:968]: LiteralNumberInteger, + _TokenTypeLowerName[948:968]: LiteralNumberInteger, + _TokenTypeName[968:992]: LiteralNumberIntegerLong, + _TokenTypeLowerName[968:992]: LiteralNumberIntegerLong, + _TokenTypeName[992:1008]: LiteralNumberOct, + _TokenTypeLowerName[992:1008]: LiteralNumberOct, + _TokenTypeName[1008:1025]: LiteralNumberByte, + _TokenTypeLowerName[1008:1025]: LiteralNumberByte, + _TokenTypeName[1025:1033]: Operator, + _TokenTypeLowerName[1025:1033]: Operator, + _TokenTypeName[1033:1045]: OperatorWord, + _TokenTypeLowerName[1033:1045]: OperatorWord, + _TokenTypeName[1045:1056]: Punctuation, + _TokenTypeLowerName[1045:1056]: Punctuation, + _TokenTypeName[1056:1063]: Comment, + _TokenTypeLowerName[1056:1063]: Comment, + _TokenTypeName[1063:1078]: CommentHashbang, + _TokenTypeLowerName[1063:1078]: CommentHashbang, + _TokenTypeName[1078:1094]: CommentMultiline, + _TokenTypeLowerName[1078:1094]: CommentMultiline, + _TokenTypeName[1094:1107]: CommentSingle, + _TokenTypeLowerName[1094:1107]: CommentSingle, + _TokenTypeName[1107:1121]: CommentSpecial, + _TokenTypeLowerName[1107:1121]: CommentSpecial, + _TokenTypeName[1121:1135]: CommentPreproc, + _TokenTypeLowerName[1121:1135]: CommentPreproc, + _TokenTypeName[1135:1153]: CommentPreprocFile, + _TokenTypeLowerName[1135:1153]: CommentPreprocFile, + _TokenTypeName[1153:1160]: Generic, + _TokenTypeLowerName[1153:1160]: Generic, + _TokenTypeName[1160:1174]: GenericDeleted, + _TokenTypeLowerName[1160:1174]: GenericDeleted, + _TokenTypeName[1174:1185]: GenericEmph, + _TokenTypeLowerName[1174:1185]: GenericEmph, + _TokenTypeName[1185:1197]: GenericError, + _TokenTypeLowerName[1185:1197]: GenericError, + _TokenTypeName[1197:1211]: GenericHeading, + _TokenTypeLowerName[1197:1211]: GenericHeading, + _TokenTypeName[1211:1226]: GenericInserted, + _TokenTypeLowerName[1211:1226]: GenericInserted, + _TokenTypeName[1226:1239]: GenericOutput, + _TokenTypeLowerName[1226:1239]: GenericOutput, + _TokenTypeName[1239:1252]: GenericPrompt, + _TokenTypeLowerName[1239:1252]: GenericPrompt, + _TokenTypeName[1252:1265]: GenericStrong, + _TokenTypeLowerName[1252:1265]: GenericStrong, + _TokenTypeName[1265:1282]: GenericSubheading, + _TokenTypeLowerName[1265:1282]: GenericSubheading, + _TokenTypeName[1282:1298]: GenericTraceback, + _TokenTypeLowerName[1282:1298]: GenericTraceback, + _TokenTypeName[1298:1314]: GenericUnderline, + _TokenTypeLowerName[1298:1314]: GenericUnderline, + _TokenTypeName[1314:1318]: Text, + _TokenTypeLowerName[1314:1318]: Text, + _TokenTypeName[1318:1332]: TextWhitespace, + _TokenTypeLowerName[1318:1332]: TextWhitespace, + _TokenTypeName[1332:1342]: TextSymbol, + _TokenTypeLowerName[1332:1342]: TextSymbol, + _TokenTypeName[1342:1357]: TextPunctuation, + _TokenTypeLowerName[1342:1357]: TextPunctuation, } var _TokenTypeNames = []string{ - _TokenTypeName[0:4], - _TokenTypeName[4:9], - _TokenTypeName[9:14], - _TokenTypeName[14:22], - _TokenTypeName[22:30], - _TokenTypeName[30:41], - _TokenTypeName[41:50], - _TokenTypeName[50:63], - _TokenTypeName[63:79], - _TokenTypeName[79:90], - _TokenTypeName[90:94], - _TokenTypeName[94:104], - _TokenTypeName[104:114], - _TokenTypeName[114:121], - _TokenTypeName[121:128], - _TokenTypeName[128:143], - _TokenTypeName[143:161], - _TokenTypeName[161:177], - _TokenTypeName[177:190], - _TokenTypeName[190:205], - _TokenTypeName[205:216], - _TokenTypeName[216:220], - _TokenTypeName[220:233], - _TokenTypeName[233:244], - _TokenTypeName[244:261], - _TokenTypeName[261:270], - _TokenTypeName[270:282], - _TokenTypeName[282:295], - _TokenTypeName[295:305], - _TokenTypeName[305:318], - _TokenTypeName[318:330], - _TokenTypeName[330:347], - _TokenTypeName[347:358], - _TokenTypeName[358:367], - _TokenTypeName[367:380], - _TokenTypeName[380:392], - _TokenTypeName[392:401], - _TokenTypeName[401:411], - _TokenTypeName[411:423], - _TokenTypeName[423:430], - _TokenTypeName[430:442], - _TokenTypeName[442:463], - _TokenTypeName[463:480], - _TokenTypeName[480:498], - _TokenTypeName[498:518], - _TokenTypeName[518:535], - _TokenTypeName[535:542], - _TokenTypeName[542:553], - _TokenTypeName[553:565], - _TokenTypeName[565:578], - _TokenTypeName[578:596], - _TokenTypeName[596:613], - _TokenTypeName[613:634], - _TokenTypeName[634:654], - _TokenTypeName[654:671], - _TokenTypeName[671:693], - _TokenTypeName[693:709], - _TokenTypeName[709:728], - _TokenTypeName[728:747], - _TokenTypeName[747:767], - _TokenTypeName[767:788], - _TokenTypeName[788:805], - _TokenTypeName[805:823], - _TokenTypeName[823:841], - _TokenTypeName[841:860], - _TokenTypeName[860:879], - _TokenTypeName[879:892], - _TokenTypeName[892:908], - _TokenTypeName[908:926], - _TokenTypeName[926:942], - _TokenTypeName[942:962], - _TokenTypeName[962:986], - _TokenTypeName[986:1002], - _TokenTypeName[1002:1010], - _TokenTypeName[1010:1022], - _TokenTypeName[1022:1033], - _TokenTypeName[1033:1040], - _TokenTypeName[1040:1055], - _TokenTypeName[1055:1071], - _TokenTypeName[1071:1084], - _TokenTypeName[1084:1098], - _TokenTypeName[1098:1112], - _TokenTypeName[1112:1130], - _TokenTypeName[1130:1137], - _TokenTypeName[1137:1151], - _TokenTypeName[1151:1162], - _TokenTypeName[1162:1174], - _TokenTypeName[1174:1188], - _TokenTypeName[1188:1203], - _TokenTypeName[1203:1216], - _TokenTypeName[1216:1229], - _TokenTypeName[1229:1242], - _TokenTypeName[1242:1259], - _TokenTypeName[1259:1275], - _TokenTypeName[1275:1291], - _TokenTypeName[1291:1295], - _TokenTypeName[1295:1309], - _TokenTypeName[1309:1319], - _TokenTypeName[1319:1334], + _TokenTypeName[0:6], + _TokenTypeName[6:10], + _TokenTypeName[10:15], + _TokenTypeName[15:20], + _TokenTypeName[20:28], + _TokenTypeName[28:36], + _TokenTypeName[36:47], + _TokenTypeName[47:56], + _TokenTypeName[56:69], + _TokenTypeName[69:85], + _TokenTypeName[85:96], + _TokenTypeName[96:100], + _TokenTypeName[100:110], + _TokenTypeName[110:120], + _TokenTypeName[120:127], + _TokenTypeName[127:134], + _TokenTypeName[134:149], + _TokenTypeName[149:167], + _TokenTypeName[167:183], + _TokenTypeName[183:196], + _TokenTypeName[196:211], + _TokenTypeName[211:222], + _TokenTypeName[222:226], + _TokenTypeName[226:239], + _TokenTypeName[239:250], + _TokenTypeName[250:267], + _TokenTypeName[267:276], + _TokenTypeName[276:288], + _TokenTypeName[288:301], + _TokenTypeName[301:311], + _TokenTypeName[311:324], + _TokenTypeName[324:336], + _TokenTypeName[336:353], + _TokenTypeName[353:364], + _TokenTypeName[364:373], + _TokenTypeName[373:386], + _TokenTypeName[386:398], + _TokenTypeName[398:407], + _TokenTypeName[407:417], + _TokenTypeName[417:429], + _TokenTypeName[429:436], + _TokenTypeName[436:448], + _TokenTypeName[448:469], + _TokenTypeName[469:486], + _TokenTypeName[486:504], + _TokenTypeName[504:524], + _TokenTypeName[524:541], + _TokenTypeName[541:548], + _TokenTypeName[548:559], + _TokenTypeName[559:571], + _TokenTypeName[571:584], + _TokenTypeName[584:602], + _TokenTypeName[602:619], + _TokenTypeName[619:640], + _TokenTypeName[640:660], + _TokenTypeName[660:677], + _TokenTypeName[677:699], + _TokenTypeName[699:715], + _TokenTypeName[715:734], + _TokenTypeName[734:753], + _TokenTypeName[753:773], + _TokenTypeName[773:794], + _TokenTypeName[794:811], + _TokenTypeName[811:829], + _TokenTypeName[829:847], + _TokenTypeName[847:866], + _TokenTypeName[866:885], + _TokenTypeName[885:898], + _TokenTypeName[898:914], + _TokenTypeName[914:932], + _TokenTypeName[932:948], + _TokenTypeName[948:968], + _TokenTypeName[968:992], + _TokenTypeName[992:1008], + _TokenTypeName[1008:1025], + _TokenTypeName[1025:1033], + _TokenTypeName[1033:1045], + _TokenTypeName[1045:1056], + _TokenTypeName[1056:1063], + _TokenTypeName[1063:1078], + _TokenTypeName[1078:1094], + _TokenTypeName[1094:1107], + _TokenTypeName[1107:1121], + _TokenTypeName[1121:1135], + _TokenTypeName[1135:1153], + _TokenTypeName[1153:1160], + _TokenTypeName[1160:1174], + _TokenTypeName[1174:1185], + _TokenTypeName[1185:1197], + _TokenTypeName[1197:1211], + _TokenTypeName[1211:1226], + _TokenTypeName[1226:1239], + _TokenTypeName[1239:1252], + _TokenTypeName[1252:1265], + _TokenTypeName[1265:1282], + _TokenTypeName[1282:1298], + _TokenTypeName[1298:1314], + _TokenTypeName[1314:1318], + _TokenTypeName[1318:1332], + _TokenTypeName[1332:1342], + _TokenTypeName[1342:1357], } // TokenTypeString retrieves an enum value from the enum constants string name. diff --git a/backend/vendor/github.com/alecthomas/chroma/v2/types.go b/backend/vendor/github.com/alecthomas/chroma/v2/types.go index 3d12310a0e..a576293755 100644 --- a/backend/vendor/github.com/alecthomas/chroma/v2/types.go +++ b/backend/vendor/github.com/alecthomas/chroma/v2/types.go @@ -41,6 +41,8 @@ const ( Other // No highlighting. None + // Don't emit this token to the output. + Ignore // Used as an EOF marker / nil token EOFType TokenType = 0 ) @@ -122,6 +124,7 @@ const ( LiteralNumberInteger LiteralNumberIntegerLong LiteralNumberOct + LiteralNumberByte ) // Operators. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/.gitignore b/backend/vendor/github.com/didip/tollbooth/v8/.gitignore new file mode 100644 index 0000000000..91ea4d7145 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/.gitignore @@ -0,0 +1,3 @@ +/debug +/.vscode +/.idea \ No newline at end of file diff --git a/backend/vendor/github.com/didip/tollbooth/v8/.golangci.yml b/backend/vendor/github.com/didip/tollbooth/v8/.golangci.yml new file mode 100644 index 0000000000..5d0a4b64fe --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/.golangci.yml @@ -0,0 +1,33 @@ +linters: + enable: + - revive + - govet + - unconvert + - megacheck + - gas + - gocyclo + - dupl + - misspell + - unparam + - unused + - typecheck + - ineffassign + - stylecheck + - gochecknoinits + - exportloopref + - gocritic + - nakedret + - gosimple + - prealloc + fast: false + disable-all: true + +issues: + exclude-rules: + - path: _test\.go + linters: + - dupl + - text: "Errors unhandled" + linters: + - gosec + exclude-use-default: false diff --git a/backend/vendor/github.com/didip/tollbooth/v8/LICENSE b/backend/vendor/github.com/didip/tollbooth/v8/LICENSE new file mode 100644 index 0000000000..349ee1c29e --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Didip Kerabat + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/README.md b/backend/vendor/github.com/didip/tollbooth/v8/README.md new file mode 100644 index 0000000000..e08fe4a6e4 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/README.md @@ -0,0 +1,217 @@ +[![GoDoc](https://godoc.org/github.com/didip/tollbooth?status.svg)](http://godoc.org/github.com/didip/tollbooth) +[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/didip/tollbooth/master/LICENSE) + +## Tollbooth + +This is a generic middleware to rate-limit HTTP requests. + +**NOTE 1:** This library is considered finished. + +**NOTE 2:** Major version changes are backward-incompatible. `v2.0.0` streamlines the ugliness of the old API. + +## Versions + +**v1.0.0:** This version maintains the old API but all the thirdparty modules are moved to their own repo. + +**v2.x.x:** Brand-new API for the sake of code cleanup, thread safety, & auto-expiring data structures. + +**v3.x.x:** Apparently we have been using golang.org/x/time/rate incorrectly. See issue #48. It always limits X number per 1 second. The time duration is not changeable, so it does not make sense to pass TTL to tollbooth. + +**v4.x.x:** Float64 for max requests per second + +**v5.x.x:** go.mod and go.sum + +**v6.x.x:** Replaced `go-cache` with `github.com/go-pkgz/expirable-cache` because `go-cache` leaks goroutines. + +**v7.x.x:** Replaced `time/rate` with `embedded time/rate` so that we can support more rate limit headers. + +**v8.x.x:** Address `RemoteIP` vulnerability concern by replacing `SetIPLookups` with `SetIPLookup`, an explicit way to pick the IP address. + + +## Five Minute Tutorial + +```go +package main + +import ( + "net/http" + + "github.com/didip/tollbooth/v8" + "github.com/didip/tollbooth/v8/limiter" +) + +func HelloHandler(w http.ResponseWriter, req *http.Request) { + w.Write([]byte("Hello, World!")) +} + +func main() { + // Create a request limiter per handler. + lmt := tollbooth.NewLimiter(1, nil) + + // New in version >= 8, you must explicitly define how to pick the IP address. + lmt.SetIPLookup(limiter.IPLookup{ + Name: "X-Real-IP", + IndexFromRight: 0, + }) + + http.Handle("/", tollbooth.LimitFuncHandler(lmt, HelloHandler)) + http.ListenAndServe(":12345", nil) +} +``` + +## Features + +1. Rate-limit by request's remote IP, path, methods, custom headers, & basic auth usernames. + ```go + import ( + "time" + + "github.com/didip/tollbooth/v8" + "github.com/didip/tollbooth/v8/limiter" + ) + + lmt := tollbooth.NewLimiter(1, nil) + + // or create a limiter with expirable token buckets + // This setting means: + // create a 1 request/second limiter and + // every token bucket in it will expire 1 hour after it was initially set. + lmt = tollbooth.NewLimiter(1, &limiter.ExpirableOptions{DefaultExpirationTTL: time.Hour}) + + // New in version >= 8, you must explicitly define how to pick the IP address. + // If IP address cannot be found, rate limiter will not be activated. + lmt.SetIPLookup(limiter.IPLookup{ + // The name of lookup method. + // Possible options are: RemoteAddr, X-Forwarded-For, X-Real-IP, CF-Connecting-IP + // All other headers are considered unknown and will be ignored. + Name: "X-Real-IP", + + // The index position to pick the ip address from a comma separated list. + // The index goes from right to left. + // + // When there are multiple of the same headers, + // we will concat them together in the order of first to last seen. + // And then we pick the IP using this index position. + IndexFromRight: 0, + }) + + // In version >= 8, lmt.SetIPLookups and lmt.GetIPLookups are removed. + + // Limit only GET and POST requests. + lmt.SetMethods([]string{"GET", "POST"}) + + // Limit based on basic auth usernames. + // You add them on-load, or later as you handle requests. + lmt.SetBasicAuthUsers([]string{"bob", "jane", "didip", "vip"}) + // You can remove them later as well. + lmt.RemoveBasicAuthUsers([]string{"vip"}) + + // Limit request headers containing certain values. + // You add them on-load, or later as you handle requests. + lmt.SetHeader("X-Access-Token", []string{"abc123", "xyz098"}) + // You can remove all entries at once. + lmt.RemoveHeader("X-Access-Token") + // Or remove specific ones. + lmt.RemoveHeaderEntries("X-Access-Token", []string{"limitless-token"}) + + // By the way, the setters are chainable. Example: + lmt.SetMethods([]string{"GET", "POST"}). + SetBasicAuthUsers([]string{"sansa"}). + SetBasicAuthUsers([]string{"tyrion"}) + ``` + +2. Compose your own middleware by using `LimitByKeys()`. + +3. Header entries and basic auth users can expire over time (to conserve memory). + + ```go + import "time" + + lmt := tollbooth.NewLimiter(1, nil) + + // Set a custom expiration TTL for token bucket. + lmt.SetTokenBucketExpirationTTL(time.Hour) + + // Set a custom expiration TTL for basic auth users. + lmt.SetBasicAuthExpirationTTL(time.Hour) + + // Set a custom expiration TTL for header entries. + lmt.SetHeaderEntryExpirationTTL(time.Hour) + ``` + +4. Upon rejection, the following HTTP response headers are available to users: + + * `X-Rate-Limit-Limit` The maximum request limit. + + * `X-Rate-Limit-Duration` The rate-limiter duration. + + * `X-Rate-Limit-Request-Forwarded-For` The rejected request `X-Forwarded-For`. + + * `X-Rate-Limit-Request-Remote-Addr` The rejected request `RemoteAddr`. + + Upon both success and rejection [RateLimit](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers) headers are sent: + + * `RateLimit-Limit` The maximum request limit within the time window (1s). + + * `RateLimit-Reset` The rate-limiter time window duration in seconds (always 1s). + + * `RateLimit-Remaining` The remaining tokens. + +5. Customize your own message or function when limit is reached. + + ```go + lmt := tollbooth.NewLimiter(1, nil) + + // New in version >= 8, you must explicitly define how to pick the IP address. + lmt.SetIPLookup(limiter.IPLookup{ + Name: "X-Forwarded-For", + IndexFromRight: 0, + }) + + // Set a custom message. + lmt.SetMessage("You have reached maximum request limit.") + + // Set a custom content-type. + lmt.SetMessageContentType("text/plain; charset=utf-8") + + // Set a custom function for rejection. + lmt.SetOnLimitReached(func(w http.ResponseWriter, r *http.Request) { fmt.Println("A request was rejected") }) + ``` + +6. Tollbooth does not require external storage since it uses an algorithm called [Token Bucket](http://en.wikipedia.org/wiki/Token_bucket) [(Go library: golang.org/x/time/rate)](https://godoc.org/golang.org/x/time/rate). + +## Other Web Frameworks + +Sometimes, other frameworks require a little bit of shim to use Tollbooth. These shims below are contributed by the community, so I make no promises on how well they work. The one I am familiar with are: Chi, Gin, and Negroni. + +* [Chi](https://github.com/didip/tollbooth_chi) + +* [Echo](https://github.com/didip/tollbooth_echo) + +* [FastHTTP](https://github.com/didip/tollbooth_fasthttp) + +* [Gin](https://github.com/didip/tollbooth_gin) + +* [GoRestful](https://github.com/didip/tollbooth_gorestful) + +* [HTTPRouter](https://github.com/didip/tollbooth_httprouter) + +* [Iris](https://github.com/didip/tollbooth_iris) + +* [Negroni](https://github.com/didip/tollbooth_negroni) + +## My other Go libraries + +* [ErrStack](https://github.com/didip/errstack): A small library to combine errors and also display filename and line number. + +* [Stopwatch](https://github.com/didip/stopwatch): A small library to measure latency of things. Useful if you want to report latency data to Graphite. + +* [LaborUnion](https://github.com/didip/laborunion): A dynamic worker pool library. + +* [Gomet](https://github.com/didip/gomet): Simple HTTP client & server long poll library for Go. Useful for receiving live updates without needing Websocket. + +## Contributions + +Before sending a PR with code changes, please make sure altered code is covered with tests which are passing, and that golangci-lint shows no errors. + +To check the linter output, [install it](https://golangci-lint.run/usage/install/#local-installation) and then run `golangci-lint run` in the root directory of the repository. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/errors/errors.go b/backend/vendor/github.com/didip/tollbooth/v8/errors/errors.go new file mode 100644 index 0000000000..149bc5a161 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/errors/errors.go @@ -0,0 +1,15 @@ +// Package errors provide data structure for errors. +package errors + +import "fmt" + +// HTTPError is an error struct that returns both message and status code. +type HTTPError struct { + Message string + StatusCode int +} + +// Error returns error message. +func (httperror *HTTPError) Error() string { + return fmt.Sprintf("%v: %v", httperror.StatusCode, httperror.Message) +} diff --git a/backend/vendor/github.com/didip/tollbooth/v8/internal/time/AUTHORS b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/AUTHORS new file mode 100644 index 0000000000..15167cd746 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/internal/time/CONTRIBUTORS b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/CONTRIBUTORS new file mode 100644 index 0000000000..1c4577e968 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/internal/time/LICENSE b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/internal/time/PATENTS b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/PATENTS new file mode 100644 index 0000000000..733099041f --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/backend/vendor/github.com/didip/tollbooth/v8/internal/time/rate/rate.go b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/rate/rate.go new file mode 100644 index 0000000000..6c3b442d7b --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/internal/time/rate/rate.go @@ -0,0 +1,396 @@ +// Copyright 2015 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 rate provides a rate limiter. +package rate + +import ( + "context" + "fmt" + "math" + "sync" + "time" +) + +// Limit defines the maximum frequency of some events. +// Limit is represented as number of events per second. +// A zero Limit allows no events. +type Limit float64 + +// Inf is the infinite rate limit; it allows all events (even if burst is zero). +const Inf = Limit(math.MaxFloat64) + +// Every converts a minimum time interval between events to a Limit. +func Every(interval time.Duration) Limit { + if interval <= 0 { + return Inf + } + return 1 / Limit(interval.Seconds()) +} + +// A Limiter controls how frequently events are allowed to happen. +// It implements a "token bucket" of size b, initially full and refilled +// at rate r tokens per second. +// Informally, in any large enough time interval, the Limiter limits the +// rate to r tokens per second, with a maximum burst size of b events. +// As a special case, if r == Inf (the infinite rate), b is ignored. +// See https://en.wikipedia.org/wiki/Token_bucket for more about token buckets. +// +// The zero value is a valid Limiter, but it will reject all events. +// Use NewLimiter to create non-zero Limiters. +// +// Limiter has three main methods, Allow, Reserve, and Wait. +// Most callers should use Wait. +// +// Each of the three methods consumes a single token. +// They differ in their behavior when no token is available. +// If no token is available, Allow returns false. +// If no token is available, Reserve returns a reservation for a future token +// and the amount of time the caller must wait before using it. +// If no token is available, Wait blocks until one can be obtained +// or its associated context.Context is canceled. +// +// The methods AllowN, ReserveN, and WaitN consume n tokens. +type Limiter struct { + mu sync.Mutex + limit Limit + burst int + tokens float64 + // last is the last time the limiter's tokens field was updated + last time.Time + // lastEvent is the latest time of a rate-limited event (past or future) + lastEvent time.Time +} + +// Limit returns the maximum overall event rate. +func (lim *Limiter) Limit() Limit { + lim.mu.Lock() + defer lim.mu.Unlock() + return lim.limit +} + +// Burst returns the maximum burst size. Burst is the maximum number of tokens +// that can be consumed in a single call to Allow, Reserve, or Wait, so higher +// Burst values allow more events to happen at once. +// A zero Burst allows no events, unless limit == Inf. +func (lim *Limiter) Burst() int { + lim.mu.Lock() + defer lim.mu.Unlock() + return lim.burst +} + +// NewLimiter returns a new Limiter that allows events up to rate r and permits +// bursts of at most b tokens. +func NewLimiter(r Limit, b int) *Limiter { + return &Limiter{ + limit: r, + burst: b, + } +} + +// Allow is shorthand for AllowN(time.Now(), 1). +func (lim *Limiter) Allow() bool { + return lim.AllowN(time.Now(), 1) +} + +// TokensAt returns the number of tokens available for the given time. +func (lim *Limiter) TokensAt(t time.Time) float64 { + lim.mu.Lock() + _, _, tokens := lim.advance(t) // does not mutate lim + lim.mu.Unlock() + return tokens +} + +// AllowN reports whether n events may happen at time now. +// Use this method if you intend to drop / skip events that exceed the rate limit. +// Otherwise use Reserve or Wait. +func (lim *Limiter) AllowN(now time.Time, n int) bool { + return lim.reserveN(now, n, 0).ok +} + +// A Reservation holds information about events that are permitted by a Limiter to happen after a delay. +// A Reservation may be canceled, which may enable the Limiter to permit additional events. +type Reservation struct { + ok bool + lim *Limiter + tokens int + timeToAct time.Time + // This is the Limit at reservation time, it can change later. + limit Limit +} + +// OK returns whether the limiter can provide the requested number of tokens +// within the maximum wait time. If OK is false, Delay returns InfDuration, and +// Cancel does nothing. +func (r *Reservation) OK() bool { + return r.ok +} + +// Delay is shorthand for DelayFrom(time.Now()). +func (r *Reservation) Delay() time.Duration { + return r.DelayFrom(time.Now()) +} + +// InfDuration is the duration returned by Delay when a Reservation is not OK. +const InfDuration = time.Duration(1<<63 - 1) + +// DelayFrom returns the duration for which the reservation holder must wait +// before taking the reserved action. Zero duration means act immediately. +// InfDuration means the limiter cannot grant the tokens requested in this +// Reservation within the maximum wait time. +func (r *Reservation) DelayFrom(now time.Time) time.Duration { + if !r.ok { + return InfDuration + } + delay := r.timeToAct.Sub(now) + if delay < 0 { + return 0 + } + return delay +} + +// Cancel is shorthand for CancelAt(time.Now()). +func (r *Reservation) Cancel() { + r.CancelAt(time.Now()) +} + +// CancelAt indicates that the reservation holder will not perform the reserved action +// and reverses the effects of this Reservation on the rate limit as much as possible, +// considering that other reservations may have already been made. +func (r *Reservation) CancelAt(now time.Time) { + if !r.ok { + return + } + + r.lim.mu.Lock() + defer r.lim.mu.Unlock() + + if r.lim.limit == Inf || r.tokens == 0 || r.timeToAct.Before(now) { + return + } + + // calculate tokens to restore + // The duration between lim.lastEvent and r.timeToAct tells us how many tokens were reserved + // after r was obtained. These tokens should not be restored. + restoreTokens := float64(r.tokens) - r.limit.tokensFromDuration(r.lim.lastEvent.Sub(r.timeToAct)) + if restoreTokens <= 0 { + return + } + // advance time to now + now, _, tokens := r.lim.advance(now) + // calculate new number of tokens + tokens += restoreTokens + if burst := float64(r.lim.burst); tokens > burst { + tokens = burst + } + // update state + r.lim.last = now + r.lim.tokens = tokens + if r.timeToAct == r.lim.lastEvent { + prevEvent := r.timeToAct.Add(r.limit.durationFromTokens(float64(-r.tokens))) + if !prevEvent.Before(now) { + r.lim.lastEvent = prevEvent + } + } +} + +// Reserve is shorthand for ReserveN(time.Now(), 1). +func (lim *Limiter) Reserve() *Reservation { + return lim.ReserveN(time.Now(), 1) +} + +// ReserveN returns a Reservation that indicates how long the caller must wait before n events happen. +// The Limiter takes this Reservation into account when allowing future events. +// The returned Reservation’s OK() method returns false if n exceeds the Limiter's burst size. +// Usage example: +// r := lim.ReserveN(time.Now(), 1) +// if !r.OK() { +// // Not allowed to act! Did you remember to set lim.burst to be > 0 ? +// return +// } +// time.Sleep(r.Delay()) +// Act() +// Use this method if you wish to wait and slow down in accordance with the rate limit without dropping events. +// If you need to respect a deadline or cancel the delay, use Wait instead. +// To drop or skip events exceeding rate limit, use Allow instead. +func (lim *Limiter) ReserveN(now time.Time, n int) *Reservation { + r := lim.reserveN(now, n, InfDuration) + return &r +} + +// Wait is shorthand for WaitN(ctx, 1). +func (lim *Limiter) Wait(ctx context.Context) (err error) { + return lim.WaitN(ctx, 1) +} + +// WaitN blocks until lim permits n events to happen. +// It returns an error if n exceeds the Limiter's burst size, the Context is +// canceled, or the expected wait time exceeds the Context's Deadline. +// The burst limit is ignored if the rate limit is Inf. +func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { + lim.mu.Lock() + burst := lim.burst + limit := lim.limit + lim.mu.Unlock() + + if n > burst && limit != Inf { + return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, burst) + } + // Check if ctx is already cancelled + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + // Determine wait limit + now := time.Now() + waitLimit := InfDuration + if deadline, ok := ctx.Deadline(); ok { + waitLimit = deadline.Sub(now) + } + // Reserve + r := lim.reserveN(now, n, waitLimit) + if !r.ok { + return fmt.Errorf("rate: Wait(n=%d) would exceed context deadline", n) + } + // Wait if necessary + delay := r.DelayFrom(now) + if delay == 0 { + return nil + } + t := time.NewTimer(delay) + defer t.Stop() + select { + case <-t.C: + // We can proceed. + return nil + case <-ctx.Done(): + // Context was canceled before we could proceed. Cancel the + // reservation, which may permit other events to proceed sooner. + r.Cancel() + return ctx.Err() + } +} + +// SetLimit is shorthand for SetLimitAt(time.Now(), newLimit). +func (lim *Limiter) SetLimit(newLimit Limit) { + lim.SetLimitAt(time.Now(), newLimit) +} + +// SetLimitAt sets a new Limit for the limiter. The new Limit, and Burst, may be violated +// or underutilized by those which reserved (using Reserve or Wait) but did not yet act +// before SetLimitAt was called. +func (lim *Limiter) SetLimitAt(now time.Time, newLimit Limit) { + lim.mu.Lock() + defer lim.mu.Unlock() + + now, _, tokens := lim.advance(now) + + lim.last = now + lim.tokens = tokens + lim.limit = newLimit +} + +// SetBurst is shorthand for SetBurstAt(time.Now(), newBurst). +func (lim *Limiter) SetBurst(newBurst int) { + lim.SetBurstAt(time.Now(), newBurst) +} + +// SetBurstAt sets a new burst size for the limiter. +func (lim *Limiter) SetBurstAt(now time.Time, newBurst int) { + lim.mu.Lock() + defer lim.mu.Unlock() + + now, _, tokens := lim.advance(now) + + lim.last = now + lim.tokens = tokens + lim.burst = newBurst +} + +// reserveN is a helper method for AllowN, ReserveN, and WaitN. +// maxFutureReserve specifies the maximum reservation wait duration allowed. +// reserveN returns Reservation, not *Reservation, to avoid allocation in AllowN and WaitN. +func (lim *Limiter) reserveN(now time.Time, n int, maxFutureReserve time.Duration) Reservation { + lim.mu.Lock() + + if lim.limit == Inf { + lim.mu.Unlock() + return Reservation{ + ok: true, + lim: lim, + tokens: n, + timeToAct: now, + } + } + + now, last, tokens := lim.advance(now) + + // Calculate the remaining number of tokens resulting from the request. + tokens -= float64(n) + + // Calculate the wait duration + var waitDuration time.Duration + if tokens < 0 { + waitDuration = lim.limit.durationFromTokens(-tokens) + } + + // Decide result + ok := n <= lim.burst && waitDuration <= maxFutureReserve + + // Prepare reservation + r := Reservation{ + ok: ok, + lim: lim, + limit: lim.limit, + } + if ok { + r.tokens = n + r.timeToAct = now.Add(waitDuration) + } + + // Update state + if ok { + lim.last = now + lim.tokens = tokens + lim.lastEvent = r.timeToAct + } else { + lim.last = last + } + + lim.mu.Unlock() + return r +} + +// advance calculates and returns an updated state for lim resulting from the passage of time. +// lim is not changed. +// advance requires that lim.mu is held. +func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time, newTokens float64) { + last := lim.last + if now.Before(last) { + last = now + } + + // Calculate the new number of tokens, due to time that passed. + elapsed := now.Sub(last) + delta := lim.limit.tokensFromDuration(elapsed) + tokens := lim.tokens + delta + if burst := float64(lim.burst); tokens > burst { + tokens = burst + } + return now, last, tokens +} + +// durationFromTokens is a unit conversion function from the number of tokens to the duration +// of time it takes to accumulate them at a rate of limit tokens per second. +func (limit Limit) durationFromTokens(tokens float64) time.Duration { + seconds := tokens / float64(limit) + return time.Duration(float64(time.Second) * seconds) +} + +// tokensFromDuration is a unit conversion function from a time duration to the number of tokens +// which could be accumulated during that duration at a rate of limit tokens per second. +func (limit Limit) tokensFromDuration(d time.Duration) float64 { + return d.Seconds() * float64(limit) +} diff --git a/backend/vendor/github.com/didip/tollbooth/v8/libstring/libstring.go b/backend/vendor/github.com/didip/tollbooth/v8/libstring/libstring.go new file mode 100644 index 0000000000..5ca875f15b --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/libstring/libstring.go @@ -0,0 +1,100 @@ +// Package libstring provides various string related functions. +package libstring + +import ( + "net" + "net/http" + "strings" + + "github.com/didip/tollbooth/v8/limiter" +) + +// StringInSlice finds needle in a slice of strings. +func StringInSlice(sliceString []string, needle string) bool { + for _, b := range sliceString { + if b == needle { + return true + } + } + return false +} + +// RemoteIPFromIPLookup picks an ip address explicitly from limiter.IPLookup criteria. +// This function is intended to replace RemoteIP function. +func RemoteIPFromIPLookup(ipLookup limiter.IPLookup, r *http.Request) string { + switch ipLookup.Name { + case "RemoteAddr": + // 1. Cover the basic use cases for both ipv4 and ipv6 + ip, _, err := net.SplitHostPort(r.RemoteAddr) + if err != nil { + // 2. Upon error, just return the remote addr. + return r.RemoteAddr + } + return ip + + case "X-Forwarded-For", "X-Real-IP", "CF-Connecting-IP": + ipAddrListCommaSeparated := r.Header.Values(ipLookup.Name) + + ipAddrCommaSeparated := strings.Join(ipAddrListCommaSeparated, ",") + + ips := strings.Split(ipAddrCommaSeparated, ",") + for i, p := range ips { + ips[i] = strings.TrimSpace(p) + } + + ipIndex := len(ips) - 1 - ipLookup.IndexFromRight + if ipIndex < 0 { + ipIndex = 0 + } + + return ips[ipIndex] + } + + return "" +} + +// CanonicalizeIP returns a form of ip suitable for comparison to other IPs. +// For IPv4 addresses, this is simply the whole string. +// For IPv6 addresses, this is the /64 prefix. +func CanonicalizeIP(ip string) string { + isIPv6 := false + // This is how net.ParseIP decides if an address is IPv6 + // https://cs.opensource.google/go/go/+/refs/tags/go1.17.7:src/net/ip.go;l=704 + for i := 0; !isIPv6 && i < len(ip); i++ { + switch ip[i] { + case '.': + // IPv4 + return ip + case ':': + // IPv6 + isIPv6 = true + } + } + if !isIPv6 { + // Not an IP address at all + return ip + } + + // By default, the string representation of a net.IPNet (masked IP address) is just + // "full_address/mask_bits". But using that will result in different addresses with + // the same /64 prefix comparing differently. So we need to zero out the last 64 bits + // so that all IPs in the same prefix will be the same. + // + // Note: When 1.18 is the minimum Go version, this can be written more cleanly like: + // netip.PrefixFrom(netip.MustParseAddr(ipv6), 64).Masked().Addr().String() + // (With appropriate error checking.) + + ipv6 := net.ParseIP(ip) + if ipv6 == nil { + return ip + } + + const bytesToZero = (128 - 64) / 8 + for i := len(ipv6) - bytesToZero; i < len(ipv6); i++ { + ipv6[i] = 0 + } + + // Note that this doesn't have the "/64" suffix customary with a CIDR representation, + // but those three bytes add nothing for us. + return ipv6.String() +} diff --git a/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter.go b/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter.go new file mode 100644 index 0000000000..b5b56d6fe1 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter.go @@ -0,0 +1,624 @@ +// Package limiter provides data structure to configure rate-limiter. +package limiter + +import ( + "net/http" + "sync" + "time" + + cache "github.com/go-pkgz/expirable-cache/v3" + + "github.com/didip/tollbooth/v8/internal/time/rate" +) + +// New is a constructor for Limiter. +func New(generalExpirableOptions *ExpirableOptions) *Limiter { + lmt := &Limiter{} + + lmt.SetMessageContentType("text/plain; charset=utf-8"). + SetMessage("You have reached maximum request limit."). + SetStatusCode(429). + SetOnLimitReached(nil). + SetForwardedForIndexFromBehind(0). + SetHeaders(make(map[string][]string)). + SetContextValues(make(map[string][]string)). + SetIgnoreURL(false) + + if generalExpirableOptions != nil { + lmt.generalExpirableOptions = generalExpirableOptions + } else { + lmt.generalExpirableOptions = &ExpirableOptions{} + } + + // Default for DefaultExpirationTTL is 10 years. + if lmt.generalExpirableOptions.DefaultExpirationTTL <= 0 { + lmt.generalExpirableOptions.DefaultExpirationTTL = 87600 * time.Hour + } + + lmt.tokenBuckets = cache.NewCache[string, *rate.Limiter]().WithTTL(lmt.generalExpirableOptions.DefaultExpirationTTL) + + lmt.basicAuthUsers = cache.NewCache[string, bool]().WithTTL(lmt.generalExpirableOptions.DefaultExpirationTTL) + + return lmt +} + +// IPLookup is a config struct to define how users want to pick the remote IP address. +type IPLookup struct { + // The name of lookup method. + // Possible options are: RemoteAddr, X-Forwarded-For, X-Real-IP, CF-Connecting-IP + // All other headers are considered unknown and will be ignored. + Name string + + // The index position to pick the ip address from a comma separated list. + // The index goes from right to left. + IndexFromRight int +} + +// Limiter is a config struct to limit a particular request handler. +type Limiter struct { + // Maximum number of requests to limit per second. + max float64 + + // Limiter burst size + burst int + + // HTTP message when limit is reached. + message string + + // Content-Type for Message + messageContentType string + + // HTTP status code when limit is reached. + statusCode int + + // A function to call when a request is rejected. + onLimitReached func(w http.ResponseWriter, r *http.Request) + + // An option to write back what you want upon reaching a limit. + overrideDefaultResponseWriter bool + + // Explicitly define how to look up IP address. + // This is intended to replace ipLookups + explicitIPLookup IPLookup + + forwardedForIndex int + + // List of HTTP Methods to limit (GET, POST, PUT, etc.). + // Empty means limit all methods. + methods []string + + // Able to configure token bucket expirations. + generalExpirableOptions *ExpirableOptions + + // List of basic auth usernames to limit. + basicAuthUsers cache.Cache[string, bool] + + // Map of HTTP headers to limit. + // Empty means skip headers checking. + headers map[string]cache.Cache[string, bool] + + // Map of Context values to limit. + contextValues map[string]cache.Cache[string, bool] + + // Map of limiters with TTL + tokenBuckets cache.Cache[string, *rate.Limiter] + + // Ignore URL on the rate limiter keys + ignoreURL bool + + tokenBucketExpirationTTL time.Duration + basicAuthExpirationTTL time.Duration + headerEntryExpirationTTL time.Duration + contextEntryExpirationTTL time.Duration + + sync.RWMutex +} + +// SetTokenBucketExpirationTTL is thread-safe way of setting custom token bucket expiration TTL. +func (l *Limiter) SetTokenBucketExpirationTTL(ttl time.Duration) *Limiter { + l.Lock() + l.tokenBucketExpirationTTL = ttl + l.Unlock() + + return l +} + +// GetTokenBucketExpirationTTL is thread-safe way of getting custom token bucket expiration TTL. +func (l *Limiter) GetTokenBucketExpirationTTL() time.Duration { + l.RLock() + defer l.RUnlock() + return l.tokenBucketExpirationTTL +} + +// SetBasicAuthExpirationTTL is thread-safe way of setting custom basic auth expiration TTL. +func (l *Limiter) SetBasicAuthExpirationTTL(ttl time.Duration) *Limiter { + l.Lock() + l.basicAuthExpirationTTL = ttl + l.Unlock() + + return l +} + +// GetBasicAuthExpirationTTL is thread-safe way of getting custom basic auth expiration TTL. +func (l *Limiter) GetBasicAuthExpirationTTL() time.Duration { + l.RLock() + defer l.RUnlock() + return l.basicAuthExpirationTTL +} + +// SetHeaderEntryExpirationTTL is thread-safe way of setting custom basic auth expiration TTL. +func (l *Limiter) SetHeaderEntryExpirationTTL(ttl time.Duration) *Limiter { + l.Lock() + l.headerEntryExpirationTTL = ttl + l.Unlock() + + return l +} + +// GetHeaderEntryExpirationTTL is thread-safe way of getting custom basic auth expiration TTL. +func (l *Limiter) GetHeaderEntryExpirationTTL() time.Duration { + l.RLock() + defer l.RUnlock() + return l.headerEntryExpirationTTL +} + +// SetContextValueEntryExpirationTTL is thread-safe way of setting custom Context value expiration TTL. +func (l *Limiter) SetContextValueEntryExpirationTTL(ttl time.Duration) *Limiter { + l.Lock() + l.contextEntryExpirationTTL = ttl + l.Unlock() + + return l +} + +// GetContextValueEntryExpirationTTL is thread-safe way of getting custom Context value expiration TTL. +func (l *Limiter) GetContextValueEntryExpirationTTL() time.Duration { + l.RLock() + defer l.RUnlock() + return l.contextEntryExpirationTTL +} + +// SetMax is thread-safe way of setting maximum number of requests to limit per second. +func (l *Limiter) SetMax(max float64) *Limiter { + l.Lock() + l.max = max + l.Unlock() + + return l +} + +// GetMax is thread-safe way of getting maximum number of requests to limit per second. +func (l *Limiter) GetMax() float64 { + l.RLock() + defer l.RUnlock() + return l.max +} + +// SetBurst is thread-safe way of setting maximum burst size. +func (l *Limiter) SetBurst(burst int) *Limiter { + l.Lock() + l.burst = burst + l.Unlock() + + return l +} + +// GetBurst is thread-safe way of setting maximum burst size. +func (l *Limiter) GetBurst() int { + l.RLock() + defer l.RUnlock() + + return l.burst +} + +// SetMessage is thread-safe way of setting HTTP message when limit is reached. +func (l *Limiter) SetMessage(msg string) *Limiter { + l.Lock() + l.message = msg + l.Unlock() + + return l +} + +// GetMessage is thread-safe way of getting HTTP message when limit is reached. +func (l *Limiter) GetMessage() string { + l.RLock() + defer l.RUnlock() + return l.message +} + +// SetMessageContentType is thread-safe way of setting HTTP message Content-Type when limit is reached. +func (l *Limiter) SetMessageContentType(contentType string) *Limiter { + l.Lock() + l.messageContentType = contentType + l.Unlock() + + return l +} + +// GetMessageContentType is thread-safe way of getting HTTP message Content-Type when limit is reached. +func (l *Limiter) GetMessageContentType() string { + l.RLock() + defer l.RUnlock() + return l.messageContentType +} + +// SetStatusCode is thread-safe way of setting HTTP status code when limit is reached. +func (l *Limiter) SetStatusCode(statusCode int) *Limiter { + l.Lock() + l.statusCode = statusCode + l.Unlock() + + return l +} + +// GetStatusCode is thread-safe way of getting HTTP status code when limit is reached. +func (l *Limiter) GetStatusCode() int { + l.RLock() + defer l.RUnlock() + return l.statusCode +} + +// SetOnLimitReached is thread-safe way of setting after-rejection function when limit is reached. +func (l *Limiter) SetOnLimitReached(fn func(w http.ResponseWriter, r *http.Request)) *Limiter { + l.Lock() + l.onLimitReached = fn + l.Unlock() + + return l +} + +// ExecOnLimitReached is thread-safe way of executing after-rejection function when limit is reached. +func (l *Limiter) ExecOnLimitReached(w http.ResponseWriter, r *http.Request) { + l.RLock() + fn := l.onLimitReached + l.RUnlock() + + if fn != nil { + fn(w, r) + } +} + +// SetOverrideDefaultResponseWriter is a thread-safe way of setting the response writer override variable. +func (l *Limiter) SetOverrideDefaultResponseWriter(override bool) *Limiter { + l.Lock() + l.overrideDefaultResponseWriter = override + l.Unlock() + + return l +} + +// GetOverrideDefaultResponseWriter is a thread-safe way of getting the response writer override variable. +func (l *Limiter) GetOverrideDefaultResponseWriter() bool { + l.RLock() + defer l.RUnlock() + return l.overrideDefaultResponseWriter +} + +// SetIPLookup is thread-safe way of setting an explicit way to look up IP address. +// This method is intended to replace SetIPLookups (version 6 or older). +func (l *Limiter) SetIPLookup(lookup IPLookup) *Limiter { + l.Lock() + l.explicitIPLookup = lookup + l.Unlock() + + return l +} + +// GetIPLookup is thread-safe way of getting an explicit way to look up IP address. +// This method is intended to replace the old GetIPLookups (version 6 or older). +func (l *Limiter) GetIPLookup() IPLookup { + l.RLock() + defer l.RUnlock() + return l.explicitIPLookup +} + +// SetIgnoreURL is thread-safe way of setting whenever ignore the URL on rate limit keys +func (l *Limiter) SetIgnoreURL(enabled bool) *Limiter { + l.Lock() + l.ignoreURL = enabled + l.Unlock() + + return l +} + +// GetIgnoreURL returns whether the URL is ignored in the rate limit key set +func (l *Limiter) GetIgnoreURL() bool { + l.RLock() + defer l.RUnlock() + return l.ignoreURL +} + +// SetForwardedForIndexFromBehind is thread-safe way of setting which X-Forwarded-For index to choose. +func (l *Limiter) SetForwardedForIndexFromBehind(forwardedForIndex int) *Limiter { + l.Lock() + l.forwardedForIndex = forwardedForIndex + l.Unlock() + + return l +} + +// GetForwardedForIndexFromBehind is thread-safe way of getting which X-Forwarded-For index to choose. +func (l *Limiter) GetForwardedForIndexFromBehind() int { + l.RLock() + defer l.RUnlock() + return l.forwardedForIndex +} + +// SetMethods is thread-safe way of setting list of HTTP Methods to limit (GET, POST, PUT, etc.). +func (l *Limiter) SetMethods(methods []string) *Limiter { + l.Lock() + l.methods = methods + l.Unlock() + + return l +} + +// GetMethods is thread-safe way of getting list of HTTP Methods to limit (GET, POST, PUT, etc.). +func (l *Limiter) GetMethods() []string { + l.RLock() + defer l.RUnlock() + return l.methods +} + +// SetBasicAuthUsers is thread-safe way of setting list of basic auth usernames to limit. +func (l *Limiter) SetBasicAuthUsers(basicAuthUsers []string) *Limiter { + ttl := l.GetBasicAuthExpirationTTL() + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + for _, basicAuthUser := range basicAuthUsers { + l.basicAuthUsers.Set(basicAuthUser, true, ttl) + } + + return l +} + +// GetBasicAuthUsers is thread-safe way of getting list of basic auth usernames to limit. +func (l *Limiter) GetBasicAuthUsers() []string { + return l.basicAuthUsers.Keys() +} + +// RemoveBasicAuthUsers is thread-safe way of removing basic auth usernames from existing list. +func (l *Limiter) RemoveBasicAuthUsers(basicAuthUsers []string) *Limiter { + for _, toBeRemoved := range basicAuthUsers { + l.basicAuthUsers.Invalidate(toBeRemoved) + } + + return l +} + +// DeleteExpiredTokenBuckets is thread-safe way of deleting expired token buckets +func (l *Limiter) DeleteExpiredTokenBuckets() { + l.tokenBuckets.DeleteExpired() +} + +// SetHeaders is thread-safe way of setting map of HTTP headers to limit. +func (l *Limiter) SetHeaders(headers map[string][]string) *Limiter { + if l.headers == nil { + l.headers = make(map[string]cache.Cache[string, bool]) + } + + for header, entries := range headers { + l.SetHeader(header, entries) + } + + return l +} + +// GetHeaders is thread-safe way of getting map of HTTP headers to limit. +func (l *Limiter) GetHeaders() map[string][]string { + results := make(map[string][]string) + + l.RLock() + defer l.RUnlock() + + for header, entriesAsGoCache := range l.headers { + results[header] = entriesAsGoCache.Keys() + } + + return results +} + +// SetHeader is thread-safe way of setting entries of 1 HTTP header. +func (l *Limiter) SetHeader(header string, entries []string) *Limiter { + l.RLock() + existing, found := l.headers[header] + l.RUnlock() + + ttl := l.GetHeaderEntryExpirationTTL() + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + if !found { + existing = cache.NewCache[string, bool]().WithTTL(ttl) + } + + for _, entry := range entries { + existing.Set(entry, true, ttl) + } + + l.Lock() + l.headers[header] = existing + l.Unlock() + + return l +} + +// GetHeader is thread-safe way of getting entries of 1 HTTP header. +func (l *Limiter) GetHeader(header string) []string { + l.RLock() + entriesAsGoCache := l.headers[header] + l.RUnlock() + + return entriesAsGoCache.Keys() +} + +// RemoveHeader is thread-safe way of removing entries of 1 HTTP header. +func (l *Limiter) RemoveHeader(header string) *Limiter { + ttl := l.GetHeaderEntryExpirationTTL() + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + l.Lock() + l.headers[header] = cache.NewCache[string, bool]().WithTTL(ttl) + l.Unlock() + + return l +} + +// RemoveHeaderEntries is thread-safe way of removing new entries to 1 HTTP header rule. +func (l *Limiter) RemoveHeaderEntries(header string, entriesForRemoval []string) *Limiter { + l.RLock() + entries, found := l.headers[header] + l.RUnlock() + + if !found { + return l + } + + for _, toBeRemoved := range entriesForRemoval { + entries.Invalidate(toBeRemoved) + } + + return l +} + +// SetContextValues is thread-safe way of setting map of HTTP headers to limit. +func (l *Limiter) SetContextValues(contextValues map[string][]string) *Limiter { + if l.contextValues == nil { + l.contextValues = make(map[string]cache.Cache[string, bool]) + } + + for contextValue, entries := range contextValues { + l.SetContextValue(contextValue, entries) + } + + return l +} + +// GetContextValues is thread-safe way of getting a map of Context values to limit. +func (l *Limiter) GetContextValues() map[string][]string { + results := make(map[string][]string) + + l.RLock() + defer l.RUnlock() + + for contextValue, entriesAsGoCache := range l.contextValues { + results[contextValue] = entriesAsGoCache.Keys() + } + + return results +} + +// SetContextValue is thread-safe way of setting entries of 1 Context value. +func (l *Limiter) SetContextValue(contextValue string, entries []string) *Limiter { + l.RLock() + existing, found := l.contextValues[contextValue] + l.RUnlock() + + ttl := l.GetContextValueEntryExpirationTTL() + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + if !found { + existing = cache.NewCache[string, bool]().WithTTL(ttl) + } + + for _, entry := range entries { + existing.Set(entry, true, ttl) + } + + l.Lock() + l.contextValues[contextValue] = existing + l.Unlock() + + return l +} + +// GetContextValue is thread-safe way of getting 1 Context value entry. +func (l *Limiter) GetContextValue(contextValue string) []string { + l.RLock() + entriesAsGoCache := l.contextValues[contextValue] + l.RUnlock() + + return entriesAsGoCache.Keys() +} + +// RemoveContextValue is thread-safe way of removing entries of 1 Context value. +func (l *Limiter) RemoveContextValue(contextValue string) *Limiter { + ttl := l.GetContextValueEntryExpirationTTL() + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + l.Lock() + l.contextValues[contextValue] = cache.NewCache[string, bool]().WithTTL(ttl) + l.Unlock() + + return l +} + +// RemoveContextValuesEntries is thread-safe way of removing entries to a ContextValue. +func (l *Limiter) RemoveContextValuesEntries(contextValue string, entriesForRemoval []string) *Limiter { + l.RLock() + entries, found := l.contextValues[contextValue] + l.RUnlock() + + if !found { + return l + } + + for _, toBeRemoved := range entriesForRemoval { + entries.Invalidate(toBeRemoved) + } + + return l +} + +func (l *Limiter) limitReachedWithTokenBucketTTL(key string, tokenBucketTTL time.Duration) bool { + lmtMax := l.GetMax() + lmtBurst := l.GetBurst() + l.Lock() + defer l.Unlock() + + if _, found := l.tokenBuckets.Get(key); !found { + l.tokenBuckets.Set( + key, + rate.NewLimiter(rate.Limit(lmtMax), lmtBurst), + tokenBucketTTL, + ) + } + + expiringMap, found := l.tokenBuckets.Get(key) + if !found { + return false + } + + return !expiringMap.Allow() +} + +// LimitReached returns a bool indicating if the Bucket identified by key ran out of tokens. +func (l *Limiter) LimitReached(key string) bool { + ttl := l.GetTokenBucketExpirationTTL() + + if ttl <= 0 { + ttl = l.generalExpirableOptions.DefaultExpirationTTL + } + + return l.limitReachedWithTokenBucketTTL(key, ttl) +} + +// Tokens returns current amount of tokens left in the Bucket identified by key. +func (l *Limiter) Tokens(key string) int { + expiringMap, found := l.tokenBuckets.Get(key) + if !found { + return 0 + } + + return int(expiringMap.TokensAt(time.Now())) +} diff --git a/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter_options.go b/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter_options.go new file mode 100644 index 0000000000..e5f537b531 --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/limiter/limiter_options.go @@ -0,0 +1,14 @@ +package limiter + +import ( + "time" +) + +// ExpirableOptions are options used for new limiter creation +type ExpirableOptions struct { + DefaultExpirationTTL time.Duration + + // How frequently expire job triggers + // Deprecated: not used anymore + ExpireJobInterval time.Duration +} diff --git a/backend/vendor/github.com/didip/tollbooth/v8/tollbooth.go b/backend/vendor/github.com/didip/tollbooth/v8/tollbooth.go new file mode 100644 index 0000000000..27e008c48b --- /dev/null +++ b/backend/vendor/github.com/didip/tollbooth/v8/tollbooth.go @@ -0,0 +1,375 @@ +// Package tollbooth provides rate-limiting logic to HTTP request handler. +package tollbooth + +import ( + "fmt" + "math" + "net/http" + "strings" + + "github.com/didip/tollbooth/v8/errors" + "github.com/didip/tollbooth/v8/libstring" + "github.com/didip/tollbooth/v8/limiter" +) + +// setResponseHeaders configures X-Rate-Limit-Limit and X-Rate-Limit-Duration +func setResponseHeaders(lmt *limiter.Limiter, w http.ResponseWriter, r *http.Request) { + w.Header().Add("X-Rate-Limit-Limit", fmt.Sprintf("%.2f", lmt.GetMax())) + w.Header().Add("X-Rate-Limit-Duration", "1") + + xForwardedFor := r.Header.Get("X-Forwarded-For") + if strings.TrimSpace(xForwardedFor) != "" { + w.Header().Add("X-Rate-Limit-Request-Forwarded-For", xForwardedFor) + } + + w.Header().Add("X-Rate-Limit-Request-Remote-Addr", r.RemoteAddr) +} + +// setRateLimitResponseHeaders configures RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset +// as seen at https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers +func setRateLimitResponseHeaders(lmt *limiter.Limiter, w http.ResponseWriter, tokensLeft int) { + w.Header().Add("RateLimit-Limit", fmt.Sprintf("%d", int(math.Round(lmt.GetMax())))) + w.Header().Add("RateLimit-Reset", "1") + w.Header().Add("RateLimit-Remaining", fmt.Sprintf("%d", tokensLeft)) +} + +// NewLimiter is a convenience function to limiter.New. +func NewLimiter(max float64, tbOptions *limiter.ExpirableOptions) *limiter.Limiter { + return limiter.New(tbOptions). + SetMax(max). + SetBurst(int(math.Max(1, max))) +} + +// LimitByKeys keeps track number of request made by keys separated by pipe. +// It returns HTTPError when limit is exceeded. +func LimitByKeys(lmt *limiter.Limiter, keys []string) *errors.HTTPError { + err, _ := LimitByKeysAndReturn(lmt, keys) + return err +} + +// LimitByKeysAndReturn keeps track number of request made by keys separated by pipe. +// It returns HTTPError when limit is exceeded, and also returns the current limit value. +func LimitByKeysAndReturn(lmt *limiter.Limiter, keys []string) (*errors.HTTPError, int) { + if lmt.LimitReached(strings.Join(keys, "|")) { + return &errors.HTTPError{Message: lmt.GetMessage(), StatusCode: lmt.GetStatusCode()}, 0 + } + + return nil, lmt.Tokens(strings.Join(keys, "|")) +} + +// ShouldSkipLimiter is a series of filter that decides if request should be limited or not. +func ShouldSkipLimiter(lmt *limiter.Limiter, r *http.Request) bool { + // --------------------------------- + // Filter by remote ip + // If we are unable to find remoteIP, skip limiter + remoteIP := libstring.RemoteIPFromIPLookup(lmt.GetIPLookup(), r) + remoteIP = libstring.CanonicalizeIP(remoteIP) + if remoteIP == "" { + return true + } + + // --------------------------------- + // Filter by request method + lmtMethods := lmt.GetMethods() + lmtMethodsIsSet := len(lmtMethods) > 0 + + if lmtMethodsIsSet { + // If request does not contain all of the methods in limiter, + // skip limiter + requestMethodDefinedInLimiter := libstring.StringInSlice(lmtMethods, r.Method) + + if !requestMethodDefinedInLimiter { + return true + } + } + + // --------------------------------- + // Filter by request headers + lmtHeaders := lmt.GetHeaders() + lmtHeadersIsSet := len(lmtHeaders) > 0 + + if lmtHeadersIsSet { + // If request does not contain all of the headers in limiter, + // skip limiter + requestHeadersDefinedInLimiter := false + + for headerKey := range lmtHeaders { + reqHeaderValue := r.Header.Get(headerKey) + if reqHeaderValue != "" { + requestHeadersDefinedInLimiter = true + break + } + } + + if !requestHeadersDefinedInLimiter { + return true + } + + // ------------------------------ + // If request contains the header key but not the values, + // skip limiter + requestHeadersDefinedInLimiter = false + + for headerKey, headerValues := range lmtHeaders { + if len(headerValues) == 0 { + requestHeadersDefinedInLimiter = true + continue + } + for _, headerValue := range headerValues { + if r.Header.Get(headerKey) == headerValue { + requestHeadersDefinedInLimiter = true + break + } + } + } + + if !requestHeadersDefinedInLimiter { + return true + } + } + + // --------------------------------- + // Filter by context values + lmtContextValues := lmt.GetContextValues() + lmtContextValuesIsSet := len(lmtContextValues) > 0 + + if lmtContextValuesIsSet { + // If request does not contain all of the contexts in limiter, + // skip limiter + requestContextValuesDefinedInLimiter := false + + for contextKey := range lmtContextValues { + reqContextValue := fmt.Sprintf("%v", r.Context().Value(contextKey)) + if reqContextValue != "" { + requestContextValuesDefinedInLimiter = true + break + } + } + + if !requestContextValuesDefinedInLimiter { + return true + } + + // ------------------------------ + // If request contains the context key but not the values, + // skip limiter + requestContextValuesDefinedInLimiter = false + + for contextKey, contextValues := range lmtContextValues { + for _, contextValue := range contextValues { + if r.Header.Get(contextKey) == contextValue { + requestContextValuesDefinedInLimiter = true + break + } + } + } + + if !requestContextValuesDefinedInLimiter { + return true + } + } + + // --------------------------------- + // Filter by basic auth usernames + lmtBasicAuthUsers := lmt.GetBasicAuthUsers() + lmtBasicAuthUsersIsSet := len(lmtBasicAuthUsers) > 0 + + if lmtBasicAuthUsersIsSet { + // If request does not contain all of the basic auth users in limiter, + // skip limiter + requestAuthUsernameDefinedInLimiter := false + + username, _, ok := r.BasicAuth() + if ok && libstring.StringInSlice(lmtBasicAuthUsers, username) { + requestAuthUsernameDefinedInLimiter = true + } + + if !requestAuthUsernameDefinedInLimiter { + return true + } + } + + return false +} + +// BuildKeys generates a slice of keys to rate-limit by given limiter and request structs. +func BuildKeys(lmt *limiter.Limiter, r *http.Request) [][]string { + remoteIP := libstring.RemoteIPFromIPLookup(lmt.GetIPLookup(), r) + remoteIP = libstring.CanonicalizeIP(remoteIP) + path := r.URL.Path + sliceKeys := make([][]string, 0) + + lmtMethods := lmt.GetMethods() + lmtHeaders := lmt.GetHeaders() + lmtContextValues := lmt.GetContextValues() + lmtBasicAuthUsers := lmt.GetBasicAuthUsers() + lmtIgnoreURL := lmt.GetIgnoreURL() + + lmtHeadersIsSet := len(lmtHeaders) > 0 + lmtContextValuesIsSet := len(lmtContextValues) > 0 + lmtBasicAuthUsersIsSet := len(lmtBasicAuthUsers) > 0 + + usernameToLimit := "" + if lmtBasicAuthUsersIsSet { + username, _, ok := r.BasicAuth() + if ok && libstring.StringInSlice(lmtBasicAuthUsers, username) { + usernameToLimit = username + } + } + + headerValuesToLimit := [][]string{} + if lmtHeadersIsSet { + for headerKey, headerValues := range lmtHeaders { + reqHeaderValue := r.Header.Get(headerKey) + if reqHeaderValue == "" { + continue + } + + if len(headerValues) == 0 { + // If header values are empty, rate-limit all request containing headerKey. + headerValuesToLimit = append(headerValuesToLimit, []string{headerKey, reqHeaderValue}) + + } else { + // If header values are not empty, rate-limit all request with headerKey and headerValues. + for _, headerValue := range headerValues { + if r.Header.Get(headerKey) == headerValue { + headerValuesToLimit = append(headerValuesToLimit, []string{headerKey, headerValue}) + break + } + } + } + } + } + + contextValuesToLimit := [][]string{} + if lmtContextValuesIsSet { + for contextKey, contextValues := range lmtContextValues { + reqContextValue := fmt.Sprintf("%v", r.Context().Value(contextKey)) + if reqContextValue == "" { + continue + } + + if len(contextValues) == 0 { + // If context values are empty, rate-limit all request containing contextKey. + contextValuesToLimit = append(contextValuesToLimit, []string{contextKey, reqContextValue}) + + } else { + // If context values are not empty, rate-limit all request with contextKey and contextValues. + for _, contextValue := range contextValues { + if reqContextValue == contextValue { + contextValuesToLimit = append(contextValuesToLimit, []string{contextKey, contextValue}) + break + } + } + } + } + } + + sliceKey := []string{remoteIP} + if !lmtIgnoreURL { + sliceKey = append(sliceKey, path) + } + + sliceKey = append(sliceKey, lmtMethods...) + + for _, header := range headerValuesToLimit { + sliceKey = append(sliceKey, header[0], header[1]) + } + + for _, contextValue := range contextValuesToLimit { + sliceKey = append(sliceKey, contextValue[0], contextValue[1]) + } + + sliceKey = append(sliceKey, usernameToLimit) + + sliceKeys = append(sliceKeys, sliceKey) + + return sliceKeys +} + +// LimitByRequest builds keys based on http.Request struct, +// loops through all the keys, and check if any one of them returns HTTPError. +func LimitByRequest(lmt *limiter.Limiter, w http.ResponseWriter, r *http.Request) *errors.HTTPError { + setResponseHeaders(lmt, w, r) + + shouldSkip := ShouldSkipLimiter(lmt, r) + if shouldSkip { + return nil + } + + sliceKeys := BuildKeys(lmt, r) + + // Get the lowest value over all keys to return in headers. + // Start with high arbitrary number so that any limit returned would be lower and would + // overwrite the value we start with. + var tokensLeft = math.MaxInt32 + + // Loop sliceKeys and check if one of them has error. + for _, keys := range sliceKeys { + httpError, keysLimit := LimitByKeysAndReturn(lmt, keys) + if tokensLeft > keysLimit { + tokensLeft = keysLimit + } + if httpError != nil { + setRateLimitResponseHeaders(lmt, w, tokensLeft) + return httpError + } + } + + setRateLimitResponseHeaders(lmt, w, tokensLeft) + return nil +} + +// LimitHandler is a middleware that performs rate-limiting given http.Handler struct. +func LimitHandler(lmt *limiter.Limiter, next http.Handler) http.Handler { + middle := func(w http.ResponseWriter, r *http.Request) { + httpError := LimitByRequest(lmt, w, r) + if httpError != nil { + lmt.ExecOnLimitReached(w, r) + if lmt.GetOverrideDefaultResponseWriter() { + return + } + w.Header().Add("Content-Type", lmt.GetMessageContentType()) + w.WriteHeader(httpError.StatusCode) + w.Write([]byte(httpError.Message)) + return + } + + // There's no rate-limit error, serve the next handler. + next.ServeHTTP(w, r) + } + + return http.HandlerFunc(middle) +} + +// LimitFuncHandler is a middleware that performs rate-limiting given request handler function. +func LimitFuncHandler(lmt *limiter.Limiter, nextFunc func(http.ResponseWriter, *http.Request)) http.Handler { + return LimitHandler(lmt, http.HandlerFunc(nextFunc)) +} + +// HTTPMiddleware wraps http.Handler with tollbooth limiter +func HTTPMiddleware(lmt *limiter.Limiter) func(http.Handler) http.Handler { + // // set IP lookup only if not set + if lmt.GetIPLookup().Name == "" { + lmt.SetIPLookup(limiter.IPLookup{Name: "RemoteAddr"}) + } + + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + select { + case <-r.Context().Done(): + http.Error(w, "Context was canceled", http.StatusServiceUnavailable) + return + default: + if httpError := LimitByRequest(lmt, w, r); httpError != nil { + lmt.ExecOnLimitReached(w, r) + w.Header().Add("Content-Type", lmt.GetMessageContentType()) + w.WriteHeader(httpError.StatusCode) + w.Write([]byte(httpError.Message)) //nolint:gosec // not much we can do here with failed write + return + } + next.ServeHTTP(w, r) + } + }) + } +} diff --git a/backend/vendor/github.com/go-pkgz/jrpc/.golangci.yml b/backend/vendor/github.com/go-pkgz/jrpc/.golangci.yml index 6b6e1c2ff4..c90a0281d7 100644 --- a/backend/vendor/github.com/go-pkgz/jrpc/.golangci.yml +++ b/backend/vendor/github.com/go-pkgz/jrpc/.golangci.yml @@ -1,8 +1,8 @@ linters-settings: govet: - check-shadowing: true + shadow: true golint: - min-confidence: 0 + min-confidence: 0.6 gocyclo: min-complexity: 15 maligned: @@ -23,44 +23,81 @@ linters-settings: - experimental disabled-checks: - wrapperFunc + - hugeParam + - rangeValCopy linters: + disable-all: true enable: - - megacheck - revive - govet - unconvert - - megacheck - - structcheck - - gas - - gocyclo - - dupl - - misspell + - gosec - unparam - - varcheck - - deadcode + - unused - typecheck - ineffassign - - varcheck - stylecheck - gochecknoinits - - exportloopref - gocritic - nakedret - gosimple - prealloc + fast: false - disable-all: true + run: - output: - format: tab - skip-dirs: - - vendor + concurrency: 4 issues: + exclude-dirs: + - vendor exclude-rules: - text: "should have a package comment, unless it's in another file for this package" linters: - golint + - text: "exitAfterDefer:" + linters: + - gocritic + - text: "whyNoLint: include an explanation for nolint directive" + linters: + - gocritic + - text: "go.mongodb.org/mongo-driver/bson/primitive.E" + linters: + - govet + - text: "weak cryptographic primitive" + linters: + - gosec + - text: "integer overflow conversion" + linters: + - gosec + - text: "should have a package comment" + linters: + - revive + - text: "at least one file in a package should have a package comment" + linters: + - stylecheck + - text: "commentedOutCode: may want to remove commented-out code" + linters: + - gocritic + - text: "unnamedResult: consider giving a name to these results" + linters: + - gocritic + - text: "var-naming: don't use an underscore in package name" + linters: + - revive + - text: "should not use underscores in package names" + linters: + - stylecheck + - text: "struct literal uses unkeyed fields" + linters: + - govet + - linters: + - unparam + - unused + - revive + path: _test\.go$ + text: "unused-parameter" exclude-use-default: false + diff --git a/backend/vendor/github.com/go-pkgz/jrpc/server.go b/backend/vendor/github.com/go-pkgz/jrpc/server.go index 78b4322f9b..8e0e8c25ce 100644 --- a/backend/vendor/github.com/go-pkgz/jrpc/server.go +++ b/backend/vendor/github.com/go-pkgz/jrpc/server.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/didip/tollbooth/v7" - "github.com/didip/tollbooth_chi" + "github.com/didip/tollbooth/v8" + "github.com/didip/tollbooth/v8/limiter" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/render" @@ -116,7 +116,9 @@ func (s *Server) Run(port int) error { router.Use(logInfoWithBody) if s.limits.clientLimit > 0 { - router.Use(tollbooth_chi.LimitHandler(tollbooth.NewLimiter(s.limits.clientLimit, nil))) + lmt := tollbooth.NewLimiter(s.limits.clientLimit, nil) + lmt.SetIPLookup(limiter.IPLookup{Name: "X-Real-IP"}) + router.Use(tollbooth.HTTPMiddleware(lmt)) } router.Use(middleware.NoCache) @@ -243,4 +245,4 @@ type LoggerFunc func(format string, args ...interface{}) func (f LoggerFunc) Logf(format string, args ...interface{}) { f(format, args...) } // NoOpLogger logger does nothing -var NoOpLogger = LoggerFunc(func(format string, args ...interface{}) {}) +var NoOpLogger = LoggerFunc(func(format string, args ...interface{}) {}) //nolint diff --git a/backend/vendor/golang.org/x/crypto/acme/types.go b/backend/vendor/golang.org/x/crypto/acme/types.go index 4888726fec..23a4d6517d 100644 --- a/backend/vendor/golang.org/x/crypto/acme/types.go +++ b/backend/vendor/golang.org/x/crypto/acme/types.go @@ -288,7 +288,7 @@ type Directory struct { // KeyChangeURL allows to perform account key rollover flow. KeyChangeURL string - // Term is a URI identifying the current terms of service. + // Terms is a URI identifying the current terms of service. Terms string // Website is an HTTP or HTTPS URL locating a website diff --git a/backend/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/backend/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 97cb916f2c..be8c002070 100644 --- a/backend/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/backend/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return sendfile(outfd, infd, offset, count) } +func Dup3(oldfd, newfd, flags int) error { + if oldfd == newfd || flags&^O_CLOEXEC != 0 { + return EINVAL + } + how := F_DUP2FD + if flags&O_CLOEXEC != 0 { + how = F_DUP2FD_CLOEXEC + } + _, err := fcntl(oldfd, how, newfd) + return err +} + /* * Exposed directly */ diff --git a/backend/vendor/golang.org/x/sys/windows/dll_windows.go b/backend/vendor/golang.org/x/sys/windows/dll_windows.go index 4e613cf633..3ca814f54d 100644 --- a/backend/vendor/golang.org/x/sys/windows/dll_windows.go +++ b/backend/vendor/golang.org/x/sys/windows/dll_windows.go @@ -43,8 +43,8 @@ type DLL struct { // LoadDLL loads DLL file into memory. // // Warning: using LoadDLL without an absolute path name is subject to -// DLL preloading attacks. To safely load a system DLL, use LazyDLL -// with System set to true, or use LoadLibraryEx directly. +// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL], +// or use [LoadLibraryEx] directly. func LoadDLL(name string) (dll *DLL, err error) { namep, err := UTF16PtrFromString(name) if err != nil { @@ -271,6 +271,9 @@ func (d *LazyDLL) NewProc(name string) *LazyProc { } // NewLazyDLL creates new LazyDLL associated with DLL file. +// +// Warning: using NewLazyDLL without an absolute path name is subject to +// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL]. func NewLazyDLL(name string) *LazyDLL { return &LazyDLL{Name: name} } @@ -410,7 +413,3 @@ func loadLibraryEx(name string, system bool) (*DLL, error) { } return &DLL{Name: name, Handle: h}, nil } - -type errString string - -func (s errString) Error() string { return string(s) } diff --git a/backend/vendor/modules.txt b/backend/vendor/modules.txt index f01361f901..ceb05c6e86 100644 --- a/backend/vendor/modules.txt +++ b/backend/vendor/modules.txt @@ -10,7 +10,7 @@ github.com/PuerkitoBio/goquery # github.com/ajg/form v1.5.1 ## explicit github.com/ajg/form -# github.com/alecthomas/chroma/v2 v2.14.0 +# github.com/alecthomas/chroma/v2 v2.15.0 ## explicit; go 1.19 github.com/alecthomas/chroma/v2 github.com/alecthomas/chroma/v2/formatters/html @@ -43,6 +43,13 @@ github.com/didip/tollbooth/v7/errors github.com/didip/tollbooth/v7/internal/time/rate github.com/didip/tollbooth/v7/libstring github.com/didip/tollbooth/v7/limiter +# github.com/didip/tollbooth/v8 v8.0.1 +## explicit; go 1.19 +github.com/didip/tollbooth/v8 +github.com/didip/tollbooth/v8/errors +github.com/didip/tollbooth/v8/internal/time/rate +github.com/didip/tollbooth/v8/libstring +github.com/didip/tollbooth/v8/limiter # github.com/didip/tollbooth_chi v0.0.0-20220719025231-d662a7f6928f ## explicit; go 1.14 github.com/didip/tollbooth_chi @@ -80,8 +87,8 @@ github.com/go-pkgz/email # github.com/go-pkgz/expirable-cache/v3 v3.0.0 ## explicit; go 1.20 github.com/go-pkgz/expirable-cache/v3 -# github.com/go-pkgz/jrpc v0.3.0 -## explicit; go 1.16 +# github.com/go-pkgz/jrpc v0.3.1 +## explicit; go 1.23 github.com/go-pkgz/jrpc # github.com/go-pkgz/lcw/v2 v2.0.0 ## explicit; go 1.21 @@ -265,7 +272,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.31.0 +# golang.org/x/crypto v0.32.0 ## explicit; go 1.20 golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert @@ -280,7 +287,7 @@ 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.33.0 +# golang.org/x/net v0.34.0 ## explicit; go 1.18 golang.org/x/net/html golang.org/x/net/html/atom @@ -306,7 +313,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.28.0 +# golang.org/x/sys v0.29.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix