使用GoKart对Go代码进行静态安全分析

关于GoKart
GoKart是一款针对Go代码安全的静态分析工具,该工具能够从Go源代码中查找使用了SSA(单一静态分配)形式的代码漏洞。GoKart能够跟踪变量和函数参数的来源,以确定输入源是否安全,与其他Go安全扫描程序相比,GoKart能够有效减少误报的数量。例如,与变量连接的SQL查询传统上可能标记为SQL注入,然而,GoKart可以确定变量实际上是常量还是类似常量的参数,在这种情况下GoKart不会报出漏洞。

工具安装
我们可以使用下列方式之一来安装GoKart。
go install安装
广大研究人员可以使用下列命令安装GoKart:
$ go install github.com/praetorian-inc/gokart@latest

Release安装
首先,我们需要访问该项目的【Releases页面】,并下载GoKart源码至本地系统。
接下来,我们可以下载checksums.txt文件来验证下载包的完整性:
#Check the checksum of the downloaded archive
$ shasum -a 256 gokart_KaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}.tar.gz
b05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22 gokart_KaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}.tar.gz
$ cat gokart_KaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}checksums.txt | grep gokartKaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}.tar.gz
b05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22 gokart_KaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}.tar.gz
然后,提取已下载好的文档:
$ tar -xvf gokart_KaTeX parse error: Expected group after '_' at position 10: {VERSION}_̲{ARCH}.tar.gz
最后,将GoKart代码移动至我们的运行路径中:
$ mv ./gokart /usr/local/bin/

源码安装
首先,我们需要使用下列命令将该项目源码克隆至本地:
$ git clone https://github.com/praetorian-inc/gokart.git
然后切换至项目根目录,并构建源码:
$ cd gokart
$ go build
最后,将GoKart代码移动至我们的运行路径中:
$ mv ./gokart /usr/local/bin
Docker支持
构建Docker镜像:
docker build -t gokart .
运行容器,并执行本地扫描(本地扫描目录需要加载至容器镜像中):
docker run -v /path/to/scan-dir:/scan-dir gokart scan /scan-dir
运行容器,并执行远程扫描(指定私钥以作认证,并加载至容器中):
docker run gokart scan -r https://github.com/praetorian-inc/gokart
#specifying a private key for private repository ssh authentication
docker run -v /path/to/key-dir/:/key-dir gokart scan -r git@github.com:praetorian-inc/gokart.git -k /key-dir/ssh_key

工具使用
针对当前目录中的Go模块运行GoKart:
#running without a directory specified defaults to ‘.’
gokart scan
扫描不同目录中的Go模块:
gokart scan
查看帮助信息:
gokart help

项目地址
GoKart:https://github.com/praetorian-inc/gokart

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值