Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate eve sbom in build process #2977

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ IPXE_IMG=$(INSTALLER)/ipxe.efi
EFI_PART=$(INSTALLER)/EFI
BOOT_PART=$(INSTALLER)/boot

SBOM=$(ROOTFS).spdx.json

DEVICETREE_DTB_amd64=
DEVICETREE_DTB_arm64=$(DIST)/dtb/eve.dtb
DEVICETREE_DTB=$(DEVICETREE_DTB_$(ZARCH))
Expand Down Expand Up @@ -272,7 +274,8 @@ RESCAN_DEPS=FORCE
# set FORCE_BUILD to --force to enforce rebuild
FORCE_BUILD=

SYFT_VERSION:=v0.62.3
SYFT_VERSION:=v0.63.0
SYFT_IMAGE:=docker.io/anchore/syft:$(SYFT_VERSION)

# we use the following block to assign correct tag to the Docker registry artifact
ifeq ($(LINUXKIT_PKG_TARGET),push)
Expand Down Expand Up @@ -532,6 +535,7 @@ ssh-key: $(SSH_KEY)
rootfs: $(ROOTFS_TAR) $(ROOTFS_IMG) current
rootfs.tar: $(ROOTFS_TAR)
rootfstar: $(ROOTFS_TAR)
sbom: $(SBOM)
live: $(LIVE_IMG) $(BIOS_IMG) current ; $(QUIET): "$@: Succeeded, LIVE_IMG=$(LIVE_IMG)"
live-%: $(LIVE).% ; $(QUIET): "$@: Succeeded, LIVE=$(LIVE)"
installer: $(INSTALLER_IMG)
Expand Down Expand Up @@ -568,6 +572,19 @@ $(ROOTFS_IMG): $(ROOTFS_TAR) | $(INSTALLER)
echo "ERROR: size of $@ is greater than 250MB (bigger than allocated partition)" && exit 1 || :
$(QUIET): $@: Succeeded

$(SBOM): $(ROOTFS_TAR) | $(INSTALLER)
$(QUIET): $@: Begin
$(eval TMP_ROOTDIR := $(shell mktemp -d))
# this is a bit of a hack, but we need to extract the rootfs tar to a directory, and it fails if
# we try to extract character devices, block devices or pipes, so we just exclude the dir.
# when syft supports reading straight from a tar archive with duplicate entries,
# this all can go away, and we can read the rootfs.tar
# see https://github.com/anchore/syft/issues/1400
tar xf $< -C $(TMP_ROOTDIR) --exclude "dev/*"
docker run -v $(TMP_ROOTDIR):/rootdir:ro $(SYFT_IMAGE) -o spdx-json /rootdir > $@
rm -rf $(TMP_ROOTDIR)
$(QUIET): $@: Succeeded

$(LIVE).raw: $(BOOT_PART) $(EFI_PART) $(ROOTFS_IMG) $(CONFIG_IMG) $(PERSIST_IMG) | $(INSTALLER)
./tools/makeflash.sh -C 350 $| $@ $(PART_SPEC)
$(QUIET): $@: Succeeded
Expand Down Expand Up @@ -609,7 +626,7 @@ pkg/%: eve-% FORCE
$(RUNME) $(BUILD_YML):
cp pkg/eve/$(@F) $@

EVE_ARTIFACTS=$(BIOS_IMG) $(EFI_PART) $(CONFIG_IMG) $(PERSIST_IMG) $(INITRD_IMG) $(INSTALLER_IMG) $(ROOTFS_IMG) fullname-rootfs $(BOOT_PART)
EVE_ARTIFACTS=$(BIOS_IMG) $(EFI_PART) $(CONFIG_IMG) $(PERSIST_IMG) $(INITRD_IMG) $(INSTALLER_IMG) $(ROOTFS_IMG) $(SBOM) fullname-rootfs $(BOOT_PART)
eve: $(INSTALLER) $(EVE_ARTIFACTS) current $(RUNME) $(BUILD_YML) | $(BUILD_DIR)
$(QUIET): "$@: Begin: EVE_REL=$(EVE_REL), HV=$(HV), LINUXKIT_PKG_TARGET=$(LINUXKIT_PKG_TARGET)"
cp images/*.yml $|
Expand Down
4 changes: 4 additions & 0 deletions pkg/eve/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ __EOT__
dump /output.net installer.net
}

do_sbom() {
cat /bits/*.spdx.json >&3
}

# Lets' parse global options first
while true; do
case "$1" in
Expand Down