关于GoKartGoKart是一款Go代码安全静态分析工具,可以从Go源代码中以SSA(SingleStaticAssignment)的形式发现代码漏洞。GoKart能够追溯变量和函数参数的来源以确定输入源是否安全,与其他Go安全扫描器相比,GoKart能够有效减少误报的数量。例如,与变量连接的SQL查询传统上可能被标记为SQL注入,但是,GoKart可以确定该变量实际上是常量还是类似常量的参数,在这种情况下,GoKart不会报告漏洞。工具安装我们可以使用以下方法之一来安装GoKart。(1)goinstall安装研究人员可以使用如下命令安装GoKart:$goinstallgithub.com/praetorian-inc/gokart@latest(2)Release安装首先,我们需要访问项目的[Releasespage],下载GoKart源代码到本地系统。接下来,我们可以下载checksums.txt文件来验证下载包的完整性:#Checkthechecksumofthedownloadedarchive$shasum-a256gokart_${VERSION}_${ARCH}.tar.gzb05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22gokart_${VERSION}_${ARCH}.tar.gz$catgokart_${VERSION}_${ARCH}_checksums.txt|grepgokart_${VERSION}_${ARCH}.tar.gzb05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22gokart_${VERSION}_。:$tar-xvfgokart_${VERSION}_${ARCH}.tar.gz最后将GoKart代码移动到我们的运行路径:$mv./gokart/usr/local/bin/(3)源码安装首先,我们需要使用以下命令将项目源码克隆到本地:$gitclonehttps://github.com/praetorian-inc/gokart.git然后切换到项目根目录并构建源码:$cdgokart$gobuild最后移动GoKart代码到我们的运行路径:$mv./gokart/usr/local/binDocker支持构建Docker镜像:dockerbuild-tgokart。运行容器并进行本地扫描(需要将本地扫描目录加载到容器镜像中):dockerrun-v/path/to/scan-dir:/scan-dirgokartscan/scan-dir运行容器并进行远程扫描(指定认证私钥加载到容器中):dockerrungokartscan-rhttps://github.com/praetorian-inc/gokart#specifyingaprivatekeyforprivaterepositorysshauthenticationdockerrun-v/path/to/key-dir/:/key-dirgokartscan-rgit@github.com:praetorian-inc/gokart.git-k/key-dir/ssh_key工具针对当前目录中的Go模块运行GoKart:#runningwithoutadirectoryspecifieddefaultsto'.'gokartscan
