Gokart是GO的静态分析工具,它使用SSA(单静态分配)GO源代码找到漏洞。它能够追踪变量和函数参数的来源,以确定输入源是否安全,这减少了与其他GO安全扫描仪相比的假阳性数量。例如,传统上可能将与变量串联的SQL查询称为SQL注入;但是,Gokart可以弄清楚该变量实际上是恒定的还是恒定的等效物,在这种情况下,没有漏洞。
Gokart还帮助Praetorian的安全平台为Chariot提供动力,该平台可帮助您在源代码和云环境中找到,管理和修复漏洞。战车使运行自动化,连续的Gokart扫描您的源代码变得容易。如果您想尝试Gokart,可以通过单击此处在几分钟内设置一个免费的战车帐户。
静态分析是在源代码中查找漏洞的强大技术。但是,这种方法因嘈杂而遭受的损失 - 也就是说,许多静态分析工具发现了许多实际上并非真实的“漏洞”。这导致了开发人员摩擦,因为用户厌倦了一次“哭泣”工具太多。
Gokart的动机是解决这个问题:我们可以创建一个比现有工具的扫描仪,其误报率明显低得多?根据我们的实验,答案是肯定的。通过利用源对源跟踪和SSA,Gokart能够跟踪可变分配之间的变量污染,从而显着提高了发现的准确性。我们的重点是可用性:务实地,这意味着我们已经优化了减少错误警报的方法。
有关更多信息,请阅读我们的博客文章。
您可以使用下面列出的任何选项在本地安装Gokart。
go install $ go install github.com/praetorian-inc/gokart@latest从版本页面下载您的操作系统的二进制文件。
(可选)下载checksums.txt文件以验证存档的完整性
# Check the checksum of the downloaded archive
$ shasum -a 256 gokart_ ${VERSION} _ ${ARCH} .tar.gz
b05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22 gokart_ ${VERSION} _ ${ARCH} .tar.gz
$ cat gokart_ ${VERSION} _ ${ARCH} _checksums.txt | grep gokart_ ${VERSION} _ ${ARCH} .tar.gz
b05c4d7895be260aa16336f29249c50b84897dab90e1221c9e96af9233751f22 gokart_ ${VERSION} _ ${ARCH} .tar.gz$ tar -xvf gokart_ ${VERSION} _ ${ARCH} .tar.gzgokart二进制移动到您的道路上: $ mv ./gokart /usr/local/bin/ # clone the GoKart repo
$ git clone https://github.com/praetorian-inc/gokart.git
# navigate into the repo directory and build
$ cd gokart
$ go build
# Move the gokart binary into your path
$ mv ./gokart /usr/local/bin构建Docker图像
docker build -t gokart .使用本地扫描运行容器(需要将本地扫描目录安装到容器图像上)
docker run -v /path/to/scan-dir:/scan-dir gokart scan /scan-dir使用远程扫描运行容器(指定AUTH的私钥时,它也需要安装到容器上)
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 [email protected]:praetorian-inc/gokart.git -k /key-dir/ssh_key # running without a directory specified defaults to '.'
gokart scan < flags >gokart scan < directory > < flags > gokart help 您可以按照下面的步骤在GO测试台上运行Gokart,这是对比度安全团队有意脆弱的GO应用程序。
# Clone sample vulnerable application
git clone https://github.com/Contrast-Security-OSS/go-test-bench.git
gokart scan go-test-bench/输出应显示一些已确定的漏洞,每个漏洞具有脆弱的功能和所确定的用户输入来源。
要测试一些Gokart功能,您可以使用下面建议的CLI标志扫描。
# Use verbose flag to show full traces of these vulnerabilities
gokart scan go-test-bench/ -v
# Use globalsTainted flag to ignore whitelisted Sources
# may increase false positive results
gokart scan go-test-bench/ -v -g
# Use debug flag to display internal analysis information
# which is useful for development and debugging
gokart scan go-test-bench/ -d
# Output results in sarif format
gokart scan go-test-bench/ -s
# Output results to file
gokart scan go-test-bench/ -o gokart-go-test-bench.txt
# Output scarif results to file
gokart scan go-test-bench/ -o gokart-go-test-bench.txt -s
# Scan remote public repository
# Repository will be cloned locally, scanned and deleted afterwards
gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -v
# Specify the remote branch to scan
gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -b actions_fix
# Scan remote private repository via ssh
gokart scan -r [email protected]:Contrast-Security-OSS/go-test-bench.git
# Scan remote private repository and optionally specify a key for ssh authentication
gokart scan -r [email protected]:Contrast-Security-OSS/go-test-bench.git -k /home/gokart/.ssh/github_rsa_key
# Use remote scan and output flags together for seamless security reviews
gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -o gokart-shiftleft-go-demo.txt -v
# Use remote scan, output and sarif flags for frictionless integration into CI/CD
gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -o gokart-shiftleft-go-demo.txt -s为了测试Gokart的可扩展性,您可以修改Gokart用来将新脆弱的水槽引入分析中的配置文件。在util/analyzers.yml上包含的默认配置文件中定义了一个测试接收器分析仪。修改util/analyzers.yml以删除测试接收器分析仪上的注释,然后指示Gokart将修改后的配置文件与-i标志使用。
# Scan using modified analyzers.yml file and output full traces
gokart scan go-test-bench/ -v -i < path-to-gokart > /util/analyzers.yml现在,输出应包含其他漏洞,包括新的“通过用户输入可触及的测试接收器”漏洞。
您可以从Gokart根目录调用的以下命令中运行随附的测试。
go test -v ./...