Merge pull request #254760 from raboof/docker-sbom-cli-plugin

docker-sbom: init at 0.6.1
This commit is contained in:
Fabián Heredia Montiel 2023-09-12 11:18:15 -05:00 committed by GitHub
commit 831e3d73a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 3 deletions

View File

@ -7,12 +7,13 @@ rec {
, mobyRev, mobyHash
, runcRev, runcHash
, containerdRev, containerdHash
, tiniRev, tiniHash, buildxSupport ? true, composeSupport ? true
, tiniRev, tiniHash
, buildxSupport ? true, composeSupport ? true, sbomSupport ? false
# package dependencies
, stdenv, fetchFromGitHub, fetchpatch, buildGoPackage
, makeWrapper, installShellFiles, pkg-config, glibc
, go-md2man, go, containerd, runc, docker-proxy, tini, libtool
, sqlite, iproute2, docker-buildx, docker-compose
, sqlite, iproute2, docker-buildx, docker-compose, docker-sbom
, iptables, e2fsprogs, xz, util-linux, xfsprogs, git
, procps, rootlesskit, slirp4netns, fuse-overlayfs, nixosTests
, clientOnly ? !stdenv.isLinux, symlinkJoin
@ -159,7 +160,8 @@ rec {
});
plugins = lib.optional buildxSupport docker-buildx
++ lib.optional composeSupport docker-compose;
++ lib.optional composeSupport docker-compose
++ lib.optional sbomSupport docker-sbom;
pluginsRef = symlinkJoin { name = "docker-plugins"; paths = plugins; };
in
buildGoPackage (lib.optionalAttrs (!clientOnly) {

View File

@ -0,0 +1,28 @@
diff --git a/test/cli/all_formats_expressible_test.go b/test/cli/all_formats_expressible_test.go
index 3f40a46..5ba04e8 100644
--- a/test/cli/all_formats_expressible_test.go
+++ b/test/cli/all_formats_expressible_test.go
@@ -8,7 +8,8 @@ import (
"github.com/anchore/syft/syft"
)
-func TestAllFormatsExpressible(t *testing.T) {
+// Disabled because it needs a running docker daemon
+func disabledTestAllFormatsExpressible(t *testing.T) {
commonAssertions := []traitAssertion{
func(tb testing.TB, stdout, _ string, _ int) {
tb.Helper()
diff --git a/test/cli/sbom_cmd_test.go b/test/cli/sbom_cmd_test.go
index 0a0771c..a086c3b 100644
--- a/test/cli/sbom_cmd_test.go
+++ b/test/cli/sbom_cmd_test.go
@@ -8,7 +8,8 @@ import (
"github.com/docker/sbom-cli-plugin/internal"
)
-func TestSBOMCmdFlags(t *testing.T) {
+// Disabled because it needs a running docker daemon
+func disabledTestSBOMCmdFlags(t *testing.T) {
hiddenPackagesImage := getFixtureImage(t, "image-hidden-packages")
coverageImage := getFixtureImage(t, "image-pkg-coverage")
tmp := t.TempDir() + "/"

View File

@ -0,0 +1,43 @@
{ buildGoModule
, fetchFromGitHub
, docker
, lib
}:
buildGoModule rec {
pname = "docker-sbom";
version = "0.6.1";
src = fetchFromGitHub {
owner = "docker";
repo = "sbom-cli-plugin";
rev = "tags/v${version}";
hash = "sha256-i3gIogHb0oW/VDuZUo6LGBmvqs/XfMXjpvTTYeGCK7Q=";
};
patches = [
# Disable tests that require a docker daemon to be running
# in the sandbox
./sbom-disable-tests.patch
];
vendorHash = "sha256-XPPVAdY2NaasZ9bkf24VWWk3X5pjnryvsErYIWkeekc=";
nativeBuildInputs = [ docker ];
installPhase = ''
runHook preInstall
install -D $GOPATH/bin/sbom-cli-plugin $out/libexec/docker/cli-plugins/docker-sbom
mkdir -p $out/bin
ln -s $out/libexec/docker/cli-plugins/docker-sbom $out/bin/docker-sbom
runHook postInstall
'';
meta = with lib; {
description = "Plugin for Docker CLI to support SBOM creation using Syft";
homepage = "https://github.com/docker/sbom-cli-plugin";
license = licenses.asl20;
maintainers = with maintainers; [ raboof ];
};
}

View File

@ -31379,6 +31379,8 @@ with pkgs;
docker-buildx = callPackage ../applications/virtualization/docker/buildx.nix { };
docker-compose = callPackage ../applications/virtualization/docker/compose.nix { };
docker-compose_1 = python3Packages.callPackage ../applications/virtualization/docker/compose_1.nix { };
docker-sbom = callPackage ../applications/virtualization/docker/sbom.nix { };
amazon-ecr-credential-helper = callPackage ../tools/admin/amazon-ecr-credential-helper { };