fix(tools.license_checker): Determine version correctly and whitelist gorilla/websocket (#13839)

This commit is contained in:
Sven Rebhan 2023-08-30 15:54:45 +02:00 committed by GitHub
parent c0f67db425
commit 926c63ef60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -1,2 +1,3 @@
<github.com/ClickHouse/clickhouse-go@v2.0.0 MIT <github.com/ClickHouse/clickhouse-go@v2.0.0 MIT
<github.com/couchbase/goutils@v0.1.2 Apache-2.0 <github.com/couchbase/goutils@v0.1.2 Apache-2.0
<=github.com/gorilla/websocket@v1.5.0 BSD-2-Clause

View File

@ -147,9 +147,10 @@ func main() {
debugf("ignoring unknown element %T (%v)", v, v) debugf("ignoring unknown element %T (%v)", v, v)
} }
} }
name = strings.TrimSpace(name)
info := packageInfo{ info := packageInfo{
name: strings.TrimSpace(name), name: name,
version: dependencies[name], version: dependencies[name],
url: strings.TrimSpace(link), url: strings.TrimSpace(link),
license: strings.TrimSpace(license), license: strings.TrimSpace(license),
@ -204,10 +205,10 @@ func main() {
// Check if we got a whitelist entry for the package // Check if we got a whitelist entry for the package
if ok, found := override.Check(info.name, info.version, info.spdx); found { if ok, found := override.Check(info.name, info.version, info.spdx); found {
if ok { if ok {
log.Printf("OK: %q (%s) (whitelist)", info.name, info.license) log.Printf("OK: \"%s@%s\" (%s) (whitelist)", info.name, info.version, info.license)
succeeded++ succeeded++
} else { } else {
log.Printf("ERR: %q (%s) %s does not match whitelist", info.name, info.license, info.spdx) log.Printf("ERR: \"%s@%s\" (%s) %s does not match whitelist", info.name, info.version, info.license, info.spdx)
failed++ failed++
} }
continue continue

View File

@ -83,12 +83,12 @@ func (w *whitelist) Parse(filename string) error {
} }
func (w *whitelist) Check(pkg, version, spdx string) (ok, found bool) { func (w *whitelist) Check(pkg, version, spdx string) (ok, found bool) {
var pkgver semver.Version
v := strings.TrimSpace(version) v := strings.TrimSpace(version)
v = strings.TrimPrefix(v, "v") v = strings.TrimPrefix(v, "v")
if v != "" { if v == "" {
pkgver = *semver.New(v) return false, false
} }
pkgver := *semver.New(v)
for _, entry := range *w { for _, entry := range *w {
if entry.Name != pkg { if entry.Name != pkg {