跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 提高警惕,供应链攻击就在你我身边

发表于

先说结论

使用 go 开发并且正在使用 logrus 库的小伙伴,请检查你引入的包是不是官方的包。

然后开始细说

import (
    log "github.com/siruspen/logrus"
)

func foo() {
   log.Warningf("bar")
}

我的这两段代码看起来没有什么问题的样子,我就引入了一个日志库 logrus ,然后输出了一点日志,能有啥问题。

然而实际上,这段代码没有引入 logrus 官方库,官方库的地址应该是 github.com/sirupsen/logrus

仔细看看,你看出两个地址的区别了吗?

这就是可怕的地方,这两个地址仅仅是其中两个字母的顺序换了一下,但凡输入的时候来个笔误,就引入了非官方库。

目前,这个非官方库仅仅从官方库 fork 了出来,只有两次提交,改了一下包名,添加了一个无关紧要的日志输出。在功能上,和官方库几乎完全一致。即使写错了库名,我也能够正常使用,很难发现我实际上写错了库名。

这就让我想到之前 xz 库被发现的那个供应链攻击,这个仓库现在的行为就很相似,蛰伏,然后等待合适的时机。

也许我只是杞人忧天,说不定这个库就真的只是正常 fork 了一下,名字又正好非常接近,那这样最好不过。不过不管怎么说,本来想引入官方库,结果引入了一个 fork 出来的仓库,总不是什么好事情。用了 logrus 库的小伙伴还是检查一下自己的代码吧。

PS: 这个 fork 出来的库会在初始化的时候 fmt.Println("INIT!!!"),一个比较方便的方法是看看自己的程序启动的时候有没有打印 INIT!!!。之前我在本地库里面搜索到了这个输出代码,还暗自吐槽这库这么会有这么不专业的行为,结果原来是我自己的锅。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.