bombon
0.3.0
自动构建Nix软件包的Cyclonedx软件材料(SBOM)!
Bombon产生了Cyclonedx v1.5 SBOM,旨在符合:
如果您发现它们不合规,请打开一个问题!
nix flake init -t github:nikstur/bombon或手动将其复制到您的存储库中的flake.nix :
# file: flake.nix
{
inputs = {
nixpkgs . url = "github:NixOS/nixpkgs/nixpkgs-unstable" ;
bombon . url = "github:nikstur/bombon" ;
bombon . inputs . nixpkgs . follows = "nixpkgs" ;
} ;
outputs = { self , nixpkgs , bombon } :
let
system = "x86_64-linux" ;
pkgs = import nixpkgs { inherit system ; } ;
in
{
packages . ${ system } . default = bombon . lib . ${ system } . buildBom pkgs . hello { } ;
} ;
}niv init
niv add nikstur/bombon # file: default.nix
let
sources = import ./nix/sources.nix { } ;
pkgs = import sources . nixpkgs { } ;
bombon = import sources . bombon { inherit pkgs ; } ;
in
bombon . buildBom pkgs . hello { } nixpkgs中的某些语言生态系统(最著名的是Rust and Go)供应商依赖性。这意味着,并非每个依赖性都是其自身的推导,因此庞德无法像“正常”的nix依赖关系那样记录其信息。但是,庞德可以自动读取来自其他工具(例如cargo-cyclonedx )生成的SBOM,以从称为bombonVendoredSbom的传球派生中为供应商依赖项生成。
您可以使用passthruVendoredSbom.rust函数将bombonVendoredSbom Passhru派生添加到生锈软件包:
myPackageWithSbom = bombon . passthruVendoredSbom . rust myPackage { inherit pkgs ; } ;或使用薄片:
myPackageWithSbom = bombon . lib . ${ system } . passthruVendoredSbom . rust myPackage { inherit pkgs ; } ;现在,由此新推导构建的SBOM现在将包括供应商的依赖项。
buildBom接受选项作为属性集。所有属性都是可选的:
extraPaths :SBOM的商店路径列表。当您构建丢弃其引用的图像时,这很有用(例如,使用unsafeDiscardReferences ,但您仍然希望它们的内容出现在SBOM中extraPaths将作为主推导的组成部分出现。includeBuildtimeDependencies :布尔旗,将构建时间依赖性包括在输出中。excludes :商店路径的正则列表,以从最终的SBOM中排除。例子:
bombon . lib . ${ system } . buildBom pkgs . hello {
extraPaths = [ pkgs . git ] ;
includeBuildtimeDependencies = true ;
excludes = [ "service" ] ;
} passthruVendoredSbom.rust也接受includeBuildtimeDependencies作为可选属性。
例子:
myPackageWithSbom = bombon . passthruVendoredSbom . rust myPackage { inherit pkgs ; includeBuildtimeDependencies = true ; } ; 在开发过程中,NIX REPL是测试更改的方便而快速的方法。启动REPL,加载您的本地版本的Nixpkgs。
nix repl < nixpkgs >在补充器内部,加载庞德薄片并为您感兴趣的包装构建BOM。
:l .
:b lib.x86_64-linux.buildBom python3 { }
请记住,每当您更改任何源代码时,都要重新加载庞邦薄片。
尼古拉斯·马蒂亚(Nicolas Mattia)的这篇博客文章对使用NIX检索依赖性的方式很大。