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 ./...