Gokartは、GOソースコードのSSA(単一の静的割り当て)形式を使用して脆弱性を見つけるGOの静的分析ツールです。変数と関数引数のソースを追跡して、入力ソースが安全かどうかを判断することができ、他のGOセキュリティスキャナーと比較して誤検知の数を減らすことができます。たとえば、変数と連結されたSQLクエリは、従来、SQL注入としてフラグを立てる可能性があります。ただし、Gokartは、変数が実際に一定か定数等価かどうかを把握できます。その場合、脆弱性はありません。
Gokartは、ソースコードとクラウド環境で脆弱性を見つけ、管理し、修正するのに役立つPraetorianのセキュリティプラットフォームであるChariotのパワーを支援します。 Chariotは、ソースコードで自動化された連続的なゴッカートスキャンを簡単に実行できます。 Gokartを試してみたい場合は、ここをクリックして数分で無料のChariotアカウントを設定できます。
静的分析は、ソースコードの脆弱性を見つけるための強力な手法です。しかし、このアプローチは騒々しいことに苦しんでいます - つまり、多くの静的分析ツールは、実際には現実的ではないかなりの数の「脆弱性」を見つけます。これにより、ユーザーはあるいは多すぎる「ウルフを泣く」というツールに飽きるため、開発者の摩擦につながりました。
Gokartの動機は、これに対処することでした。既存のツールよりも誤った陽性率が大幅に低いスキャナーを作成できますか?私たちの実験に基づいて、答えはイエスです。ソース間トレースとSSAを活用することにより、Gokartは可変割り当て間の可変性を追跡することができ、調査結果の精度を大幅に改善します。私たちの焦点は使いやすさに焦点を当てています。それは、誤ったアラームを減らすためのアプローチを最適化したことを意味します。
詳細については、ブログ投稿をご覧ください。
以下にリストされているオプションのいずれかを使用して、Gokartをローカルにインストールできます。
go install付きインストール$ go install github.com/praetorian-inc/gokart@latest[リリース]ページからOSのバイナリをダウンロードします。
(オプション) 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/binDocker画像を作成します
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 以下の手順に従って、Gokart On Go Test Benchを実行できます。これは、Contrast Securityチームからの意図的に脆弱な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を変更して、Test Sinkアナライザーのコメントを削除し、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 Root Directoryから呼び出された次のコマンドで含まれたテストを実行できます。
go test -v ./...