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

Fix SBOM generation inconsistency, take 2 #66

Merged

Conversation

damdo
Copy link
Contributor

@damdo damdo commented Oct 22, 2023

Builds on top of #65

Fixes #64
by adopting approach 1.

Seems to be working well for all the commands I tested: sbom, update, overwrite (full,gaf).

Testing:

$ make gaf 2>&1 >/dev/null
$ unzip -p /tmp/disk.gaf sbom.json | jq -r '.sbom_hash'
23c08ae3b4c009e179f46fe8e812617771c39d1540042d79c11848015dec86b9

$ make sbom | jq -r '.sbom_hash'
23c08ae3b4c009e179f46fe8e812617771c39d1540042d79c11848015dec86b9

$ make overwrite 2>&1 >/dev/null # creates a full.img
$ make test & # launches a qemu test machine from the full.img at (192.168.64.2)
$ curl -sL -H 'Accept: application/json' "http://gokrazy:[email protected]/" | jq -r '.SBOMHash'
23c08ae3b4c009e179f46fe8e812617771c39d1540042d79c11848015dec86b9

$ make update
$ curl -sL -H 'Accept: application/json' "http://gokrazy:[email protected]/" | jq -r '.SBOMHash'
23c08ae3b4c009e179f46fe8e812617771c39d1540042d79c11848015dec86b9

$ vim config.json
$ git diff config.json
+++ b/config.json
@@ -7,7 +7,8 @@
     },
     "Packages": [
         "github.com/gokrazy/serial-busybox",
-        "github.com/gokrazy/breakglass"
+        "github.com/gokrazy/breakglass",
+        "github.com/gokrazy/hello"

$ make sbom | jq -r '.sbom_hash'
1ab7db66f5b0a0d3253d3e104c0b375e7ae4af7449bae635c7554e0b0b596e21

$ make update
$ curl -sL -H 'Accept: application/json' "http://gokrazy:[email protected]/" | jq -r '.SBOMHash'
1ab7db66f5b0a0d3253d3e104c0b375e7ae4af7449bae635c7554e0b0b596e21

Copy link
Contributor

@stapelberg stapelberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall!

internal/gok/overwrite.go Outdated Show resolved Hide resolved
@damdo damdo force-pushed the fix-sbom-generation-inconsistency-take-2 branch from 08793d6 to 796b7ff Compare October 22, 2023 11:19
@stapelberg
Copy link
Contributor

This breaks tests, though. Can you take a look please?

@damdo
Copy link
Contributor Author

damdo commented Oct 22, 2023

Yes I was just looking at it.
It throws:

gokrpacker_test.go:107: [overwrite --root=root.squashfs --boot=boot.fat]: open /tmp/TestGokrPacker3940063376/001/hello/builddir/github.com/gokrazy/gokrazy/go.mod: no such file or directory

@damdo damdo force-pushed the fix-sbom-generation-inconsistency-take-2 branch 3 times, most recently from a2c4879 to 8e2e11b Compare October 24, 2023 07:01
@damdo damdo force-pushed the fix-sbom-generation-inconsistency-take-2 branch from 8e2e11b to 2f08163 Compare October 24, 2023 07:11
@damdo
Copy link
Contributor Author

damdo commented Oct 24, 2023

@stapelberg The issue was caused by the fact that GenerateSBOM() looks for go.mod files in builddir, which are not populated early in the gok processing for newly created instances.

Thus I changed it slighly by holding an untouched copy of the config file in the pack struct and use that as a reference to GenerateSBOM() later when it is needed.

@stapelberg stapelberg merged commit 1c3069c into gokrazy:main Oct 25, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SBOM inconsistency gok sbom vs gok overwrite/update
2 participants