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

[POC] Provisioner for SBOM #13171

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8028fae
Add outer provisioner to download, validate and compress SBOM
devashish-patel Sep 18, 2024
c73ea49
Add and set up internal SBOM provisioner
devashish-patel Sep 25, 2024
4d341df
Modify external provisioner
devashish-patel Sep 25, 2024
db1e0ac
Fix lint
devashish-patel Sep 25, 2024
bc07854
Fix tests
devashish-patel Sep 25, 2024
946c855
Add PR suggestions
devashish-patel Sep 30, 2024
a321535
Remove unnecessary test
devashish-patel Sep 30, 2024
2590ab2
Run generate
devashish-patel Oct 4, 2024
c98a179
DRY download SBOM functions
devashish-patel Oct 9, 2024
ecb7f7e
Add support for SPDX
devashish-patel Oct 9, 2024
939686a
Fix linting
devashish-patel Oct 9, 2024
14393c2
Optimize code
devashish-patel Oct 14, 2024
2cc9294
Rename hcp_sbom to hcp-sbom
devashish-patel Oct 15, 2024
43699ab
Typed error check in validation
devashish-patel Oct 21, 2024
aa5f6a1
Use single buffer
devashish-patel Oct 21, 2024
3cf0c1f
Lint
devashish-patel Oct 21, 2024
0684f39
packer_test: add file checker
lbajolet-hashicorp Oct 1, 2024
b0bbaf4
simplify error typing for SBOM validation
lbajolet-hashicorp Oct 25, 2024
8e61f1c
fixme: add path/home to commands for docker to run, should be general…
lbajolet-hashicorp Oct 25, 2024
862f4a1
packer_test: add intergation tests for hcp-sbom
lbajolet-hashicorp Oct 25, 2024
203eed3
Add more acceptance tests
devashish-patel Oct 25, 2024
a1ca982
Refactor to filepath.Glob
devashish-patel Oct 28, 2024
84ec74e
fix: file download logic when given destination does not exist
devashish-patel Oct 28, 2024
b8883dd
Fix error messages for FileGlob checker
devashish-patel Oct 31, 2024
b6b46e2
parity in error messages
devashish-patel Oct 31, 2024
8638a1a
Add docs
devashish-patel Nov 1, 2024
19a2f89
Fix verbiage in website
devashish-patel Nov 4, 2024
96efcc8
hcp-sbom: remove packerDestination function
lbajolet-hashicorp Nov 11, 2024
f358d21
hcp-sbom: rely less on io.Readers
lbajolet-hashicorp Nov 11, 2024
479ca07
hcp-sbom: use a JSON-encoded output for Packer
lbajolet-hashicorp Nov 11, 2024
8f8a108
hcp-sbom: add sbom_name attribute
lbajolet-hashicorp Nov 11, 2024
10452ca
hcp-sbom: make validation functions private
lbajolet-hashicorp Nov 11, 2024
c82efaa
hcp-sbom: add prepare tests for the provisioner
lbajolet-hashicorp Nov 11, 2024
efa9075
hcp: integrate SBOM upload to HCP code
JenGoldstrich Sep 27, 2024
0bc82b5
go.mod: temporary use a local SDK to build
lbajolet-hashicorp Nov 13, 2024
8bc1fd7
hcp: wrap completeBuild to mark as failed on error
lbajolet-hashicorp Nov 12, 2024
3f5f177
command: exit non-zero if uploading to HCP failed
lbajolet-hashicorp Nov 13, 2024
f375850
Switch to enum SBOM Format
JenGoldstrich Jan 7, 2025
d0aff2b
Update off internal SDK, fix gRPC status code change breaking version…
JenGoldstrich Jan 9, 2025
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
18 changes: 17 additions & 1 deletion internal/hcp/registry/types.bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ func (bucket *Bucket) completeBuild(
doneCh, ok := bucket.RunningBuilds[buildName]
if !ok {
log.Print("[ERROR] done build does not have an entry in the heartbeat table, state will be inconsistent.")

} else {
log.Printf("[TRACE] signal stopping heartbeats")
// Stop heartbeating
Expand All @@ -662,6 +661,23 @@ func (bucket *Bucket) completeBuild(
return packerSDKArtifacts, fmt.Errorf("build failed, not uploading artifacts")
}

artifacts, err := bucket.doCompleteBuild(ctx, buildName, packerSDKArtifacts, buildErr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

if err != nil {
err := bucket.UpdateBuildStatus(ctx, buildName, hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDFAILED)
if err != nil {
log.Printf("[ERROR] failed to update build %q status to FAILED: %s", buildName, err)
}
}

return artifacts, err
}

func (bucket *Bucket) doCompleteBuild(
ctx context.Context,
buildName string,
packerSDKArtifacts []packerSDK.Artifact,
buildErr error,
) ([]packerSDK.Artifact, error) {
for _, art := range packerSDKArtifacts {
var sdkImages []packerSDKRegistry.Image
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
Expand Down