Update a number of dependencies (incl. CVE fixes) (#4107)

* Update a number of dependencies (incl. CVE fixes)

Includes some dependencies that were upgraded in #4106 as well as a few more dependencies.

Some deps that have been upgraded had CVEs.

Notably, upgrades deprecated dependencies such as:
- `github.com/go-chi/chi` (replaced with `/v5`)
- `github.com/gofrs/uuid` (replaced with `/v5`)
- `github.com/hashicorp/golang-lru` (replaced with `/v2` which uses generics)

* Upgraded a few more deps

* lint

* reverted yaml library to v2

* remove unnecessary mod replace

* Update chromedp

Fixes #3733
This commit is contained in:
its-josh4
2023-10-25 22:24:32 -07:00
committed by GitHub
parent 552f86586a
commit 2b8c2534dd
17 changed files with 211 additions and 504 deletions

View File

@@ -3,7 +3,7 @@ package sqlite
import (
"regexp"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
)
// size of the regex LRU cache in elements.
@@ -14,19 +14,17 @@ import (
// again.
const regexCacheSize = 10
var regexCache *lru.Cache
var regexCache *lru.Cache[string, *regexp.Regexp]
func init() {
regexCache, _ = lru.New(regexCacheSize)
regexCache, _ = lru.New[string, *regexp.Regexp](regexCacheSize)
}
// regexFn is registered as an SQLite function as "regexp"
// It uses an LRU cache to cache recent regex patterns to reduce CPU load over
// identical patterns.
func regexFn(re, s string) (bool, error) {
entry, ok := regexCache.Get(re)
var compiled *regexp.Regexp
compiled, ok := regexCache.Get(re)
if !ok {
var err error
compiled, err = regexp.Compile(re)
@@ -34,8 +32,6 @@ func regexFn(re, s string) (bool, error) {
return false, err
}
regexCache.Add(re, compiled)
} else {
compiled = entry.(*regexp.Regexp)
}
return compiled.MatchString(s), nil