サーバセキュリティ

SBOMツール (sbom-tool : MS製OSS構成管理)の使い方

SBOM とは

SBOM (読み方: えすぼむ) とは Software Bill of Materials の略で、ソフトウェアの構成情報のことです。

2021 年末の Log4j 問題も一因となり、「世界的に構成管理をしっかりしよう」という流れができ、SBOM に注目が集まり始めています。

実はその少し前からアメリカでサイバーセキュリティ対策における構成管理の重要性を認識しており、「presidential-actions (大統領の行動)」として SBOM についても謡われています。

Executive Order on Improving the Nation's Cybersecurity | The White House
By the authority vested in me as Preside...

the term “Software Bill of Materials” or “SBOM” means a formal record containing the details and supply chain relationships of various components used in building software.

SBOM の定義としては「ソフトウェアを構成する上での様々なコンポーネントの詳細情報や依存関係を含んだレコード」を指すと言っています。

本記事では Microsoft が OpenSource で github に公開している SBOM ツールを Rocky Linux 上で動作させ、出力された構成一覧を見てみます。

利用手順

基本的には以下 github の README.md にある手順の通りです。

GitHub - microsoft/sbom-tool: The SBOM tool is a highly scalable and enterprise ready tool to create SPDX 2.2 compatible SBOMs for any variety of artifacts.
The SBOM tool is a highly scalable and e...

まず sbom-tool をダウンロードし、実行権を付与します。

$ curl -Lo sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64
$ chmod +x sbom-tool

次に .NET をインストールしプロジェクトを作ります。(sbom-tool 自体が .NET 上での C# で動作するため)

$ sudo dnf -y install dotnet
$ mkdir mypj && cd mypj
$ dotnet new console

次に Microsoft GitHub NuGet package registry を nuget.config に加えます。--username と --password には github の username と PAT (個人用アクセストークン) を入力します。

$ dotnet nuget add source --username YourName --password YourPAT --store-password-in-clear-text --name github "https://nuget.pkg.github.com/OWNER/index.json"

上記で間違って登録してしまった場合は dotnet nuget remove source github で削除し、正しいコマンドで再登録します。

なお、PAT で packages:read の許可をしていないと以下のように 401 エラーになります。

error: Response status code does not indicate success: 401 (Unauthorized).

github.com の [Settings] -> [Developer Settings] -> [Personal access tokens] にて、利用する token の scope に [read:packages] がチェックされているか確認しましょう。

そして Microsoft.Sbom.Api をインストールします。

$ dotnet add package Microsoft.Sbom.Api

そして実行します。-b で出力先ディレクトリ、-bc で調査の起点となるディレクトリ (一般にはソースコードなどが配置されたディレクトリ)、-pn -pv -ps はそれぞれ管理対象のパッケージ名、パッケージバージョン、パッケージ管理組織を記入します。

$ cd ..
$ ./sbom-tool generate -b . -bc mysrc -pn myPackage -pv 1.0.0 -ps myApp -nsb https://xxx.example.com -V verbose

すると -b で指定したディレクトリに _manifest というディレクトリが作成され、その配下に構成一覧を示す .json ファイルが生成されます。

$ less _manifest/spdx_2.2/manifest.spdx.json

コメント

タイトルとURLをコピーしました