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 37 commits into
base: main
Choose a base branch
from
Draft

Commits on Nov 11, 2024

  1. Configuration menu
    Copy the full SHA
    8028fae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c73ea49 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4d341df View commit details
    Browse the repository at this point in the history
  4. Fix lint

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    db1e0ac View commit details
    Browse the repository at this point in the history
  5. Fix tests

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    bc07854 View commit details
    Browse the repository at this point in the history
  6. Add PR suggestions

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    946c855 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    a321535 View commit details
    Browse the repository at this point in the history
  8. Run generate

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    2590ab2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    c98a179 View commit details
    Browse the repository at this point in the history
  10. Add support for SPDX

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    ecb7f7e View commit details
    Browse the repository at this point in the history
  11. Fix linting

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    939686a View commit details
    Browse the repository at this point in the history
  12. Optimize code

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    14393c2 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    2cc9294 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    43699ab View commit details
    Browse the repository at this point in the history
  15. Use single buffer

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    aa5f6a1 View commit details
    Browse the repository at this point in the history
  16. Lint

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    3cf0c1f View commit details
    Browse the repository at this point in the history
  17. packer_test: add file checker

    Some tests will create files and directories as part of the execution
    path for Packer, and we need a way to check this, so this commit adds a
    new file gadget to do those checks after a command executes.
    lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    0684f39 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    b0bbaf4 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    8e61f1c View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    862f4a1 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    203eed3 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    a1ca982 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    84ec74e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    b8883dd View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    b6b46e2 View commit details
    Browse the repository at this point in the history
  26. Add docs

    devashish-patel authored and lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    8638a1a View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    19a2f89 View commit details
    Browse the repository at this point in the history
  28. hcp-sbom: remove packerDestination function

    Since the function did very little, and the code was called once in the
    provisioner, we remove the function itself and move the code over to the
    provisioner's Provision function.
    
    Also, since the output directory is prepared and its lifecycle is
    managed by Packer Core, we should not try to make the missing
    directories here, and instead rely on Packer core's code before calling
    the provisioner to do so.
    lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    96efcc8 View commit details
    Browse the repository at this point in the history
  29. hcp-sbom: rely less on io.Readers

    Using io.Readers from a file's contents is not a bad idea inherently,
    but since we're forced to reset the reader periodically, this makes
    manipulation more complex because of the extra function call, error
    checking, and extra usage errors.
    
    To simplify how we're working with that data, we're passing around the
    raw file contents, so they're encapsulated into readers on-demand, when
    needed only, which is a rather costless operation as the bytes.Reader
    reads directly from the slice, maintaining its own offsets, therefore
    meaning that resetting it is not necessary, since we can as easily
    discard it, without risking failure.
    lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    f358d21 View commit details
    Browse the repository at this point in the history
  30. hcp-sbom: use a JSON-encoded output for Packer

    When outputting the data from the provisioner so Packer can consume it,
    we are writing to a file.
    The only constraints on this file are that Packer manages its lifecycle,
    and that Packer core and the provisioner are synced-up in terms of the
    contents and the structure of the file.
    
    Since we are outputting the file, and its format, we can bundle the two
    together, and export them under a structure that both the provisioner
    and Packer core have access to, so we can then fill-in the blanks, and
    write a serialised version of this structure to disk.
    
    This is the approach taken in this commit.
    
    First we clean-up the existing code a bit, since some abstractions were
    a bit hasty, and did not necessarily make sense in all cases, so the
    code is consolidated under `Provision`, and we use that structure then
    to fill-in the relevant information before serialising it to JSON and
    writing it in the output file provided by Packer core.
    lbajolet-hashicorp committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    479ca07 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2024

  1. hcp-sbom: add sbom_name attribute

    Since we are uploading multiple SBOMs possibly for a single build, we
    need to generate names for them, so users are able to differentiate
    between those artifacts.
    
    This commit adds an optional property `sbom_name`, that users can
    provide in the configuration for this provisioner, which is then used by
    Packer core for uploading the data to HCP Packer later on.
    lbajolet-hashicorp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    8f8a108 View commit details
    Browse the repository at this point in the history
  2. hcp-sbom: make validation functions private

    Since the SBOM validation functions are now called only from the
    provisioner itself, they don't need to be public anymore, so we make
    them private to the package.
    lbajolet-hashicorp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    10452ca View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c82efaa View commit details
    Browse the repository at this point in the history
  4. hcp: integrate SBOM upload to HCP code

    Since packer now supports keeping track of SBOMs produced during a
    build, we add the code to integrate those changes into the internal/hcp
    package, so we do upload them on build completion.
    JenGoldstrich authored and lbajolet-hashicorp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    efa9075 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0bc82b5 View commit details
    Browse the repository at this point in the history
  6. hcp: wrap completeBuild to mark as failed on error

    When a build cannot be completed without errors, the build state was
    left as running, unless the build explicitly failed, which meant that
    HCP Packer would be responsible for changing the status after the
    heartbeats for the build stopped being sent for two 5m periods.
    
    This commit changes this behaviour, by explicitly marking the build as
    failed if something did not work while trying to complete a build on HCP
    Packer, even if the local Packer core build succeeded before that.
    lbajolet-hashicorp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    8bc1fd7 View commit details
    Browse the repository at this point in the history
  7. command: exit non-zero if uploading to HCP failed

    In the current state, a Packer build that succeeds but fails to push its
    metadata to HCP for reasons other than a lack of artifact will always
    succeed from the perspective of a user invoking `packer build`.
    
    This can be a bit misleading, as users may expect their artifacts to
    appear on HCP Packer if their build succeeded on Packer Core, so this
    commit changes this behaviour, instead reporting HCP errors as a real
    error if the build failed, so packer returns a non-zero error code if
    this happens.
    lbajolet-hashicorp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    3f5f177 View commit details
    Browse the repository at this point in the history