登录
首页 >  Golang >  Go问答

Golang: 解决 golang.org/x/net 过时依赖的 google.golang.org/api 处理方法

来源:stackoverflow

时间:2024-02-06 11:03:23 421浏览 收藏

大家好,今天本人给大家带来文章《Golang: 解决 golang.org/x/net 过时依赖的 google.golang.org/api 处理方法》,文中内容主要涉及到,如果你对Golang方面的知识点感兴趣,那就请各位朋友继续看下去吧~希望能真正帮到你们,谢谢!

问题内容

最近 github.com dependabot 抱怨我的项目中的一些依赖项容易受到 dos 的攻击,具有“损坏或有风险的加密算法”,并且存在“不受控制的资源消耗”的错误。

具体来说,它警告我有关 golang.org/x/net 模块的 cve-2022-27664、其他模块的 cve-2022-27191 和 cve-2022-32149。

我所做的是在所有使用的模块上运行“go get -u”。显然,这并没有解决问题。然后我开始用“go graph”寻找模块依赖关系。花了一段时间,这是我找到的依赖顺序:

google.golang.org/[email protected] =>
[email protected] =>
google.golang.org/[email protected] =>
github.com/envoyproxy/[email protected] =>
google.golang.org/[email protected] =>
golang.org/x/[email protected] =>
google.golang.org/[email protected] =>
golang.org/x/[email protected]

这意味着 2023 年 3 月 17 日起的最现代且更新的 google.golang.org/api 软件包会导致对 2018 年起的 golang.org/x/net 的依赖。

我发现其他谷歌软件包对旧网络模块有很多依赖:

cloud.google.com/go/[email protected] golang.org/x/[email protected]
github.com/googleapis/gax-go/[email protected] golang.org/x/[email protected]
[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
golang.org/x/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]
google.golang.org/[email protected] golang.org/x/[email protected]

我检查了 github.com/googleapis/google-api-go-client 存储库并发现了此问题 https://github.com/googleapis/google-api-go-client/issues/1048 我说同样的问题,但后来用户 hashier 说,由于 go list -m all 命令显示最新版本,所以这不是问题。

所以,主要问题是:这是否是一个问题以及为什么?

我只是不知道这里应该修复什么,github dependabot 检查或 google-api-go-client 模块依赖项。


正确答案


是时候回答这个问题了。

当我尝试使用 go mod graph 在单独的草稿存储库中一一检查项目中的所有包时,这些易受攻击的依赖项来自另一个存储库:github.com/go-gorm/postgres

所以,我错误地确定了易受攻击的依赖项来自何处。显然这是由于巨大的依赖关系图造成的:

[0] $ go mod graph | wc
    667    1334   56113

如果有人正在寻找一种可视化项目依赖关系的方法,这里是:

go mod graph | modgv | dot -Tsvg -o graph.svg

回到最初的问题。这是由于 github.com/go-gorm/postgres 使用旧版本的 go 造成的。据我了解,修复它的唯一方法是将 go 版本升级到 1.18。如果版本较低,go mod graph会显示很多易受攻击的包。

以上就是《Golang: 解决 golang.org/x/net 过时依赖的 google.golang.org/api 处理方法》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>