brew icon indicating copy to clipboard operation
brew copied to clipboard

feat: add generated SPDX file on bottling

Open SMillerDev opened this issue 1 year ago • 17 comments

  • [x] Have you followed the guidelines in our Contributing document?
  • [ ] Have you checked to ensure there aren't other open Pull Requests for the same change?
  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [ ] Have you written new tests for your changes? Here's an example.
  • [ ] Have you successfully run brew style with your changes locally?
  • [ ] Have you successfully run brew typecheck with your changes locally?
  • [ ] Have you successfully run brew tests with your changes locally?

Attached is an example SBOM. spdx.sbom.json

This should allow us to have some more tracking of what goes into our bottles, but also allow others to have some insight into it.

SMillerDev avatar Feb 05 '24 22:02 SMillerDev

feels a bit weird this living on Tab when it's got little in common there

Yeah, I was considering splitting it out of tab, but it is sort of the same thing so wanted to get it public first.

do we have requests for these files anywhere you can link to?

No, but I can see the tooling being available in the larger ecosystem be useful. And I chatted with some people about this and they seemed interested. @gdams for example.

SMillerDev avatar Feb 06 '24 15:02 SMillerDev

Yeah, I was considering splitting it out of tab, but it is sort of the same thing so wanted to get it public first.

Cool, all good, as long as done before merged 👍🏻

No, but I can see the tooling being available in the larger ecosystem be useful. And I chatted with some people about this and they seemed interested. @gdams for example.

I think this is the sort of thing I'd like to see some more requests for before we consider integration here.

MikeMcQuaid avatar Feb 12 '24 14:02 MikeMcQuaid

Yeah this is certainly something that I see to be useful in homebrew. With the significant pressure companies/projects are being put under to provide SBOMs it would be useful for projects to be able to easily determine the exact set of deps in homebrew formulas.

gdams avatar Feb 12 '24 16:02 gdams

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Mar 05 '24 00:03 github-actions[bot]

Attached is an example SBOM. spdx.sbom.json

The resulting data structure seams invalid to the SPDX 2.3 JSON schema. Tested with https://www.jsonschemavalidator.net/ and https://www.liquid-technologies.com/online-json-schema-validator

jkowalleck avatar Mar 23 '24 21:03 jkowalleck

New generated SBOM: sbom.spdx.json

That should pass validation and have some more information than the previous one.

SMillerDev avatar Mar 24 '24 10:03 SMillerDev

uses JSONSchemer.schema (like github_packages.rb) to do schema validation on write

Didn't know we had that, it sounds awesome. Do we use that for the API already? Otherwise I'm adding that to my list.

SMillerDev avatar Mar 24 '24 21:03 SMillerDev

Didn't know we had that, it sounds awesome.

It is good for catching problems for sure.

Do we use that for the API already?

No(t yet). We'd need to create and publish a schema, too. Might want to sync up with @apainintheneck and save this for API v3 rather than create a v2 schema that won't be around in a year.

MikeMcQuaid avatar Mar 25 '24 08:03 MikeMcQuaid

I sent @SMillerDev some info but honestly API v3 still seems a ways off since the way we handle dependencies for formulae is still undecided and cask v3 is currently blocked by potential scope creep. Either we hold off on validating API v2 for now or we add validation knowing it might get removed in a few months.

apainintheneck avatar Mar 26 '24 06:03 apainintheneck

Does anyone know where stdlib information comes from in the install tab etc? Or is that only for Linux and that's why I can't find it?

SMillerDev avatar Mar 30 '24 18:03 SMillerDev

Any suggestions to fix this?

  Error: bottling failed
  Error: cannot load such file -- json_schemer

SMillerDev avatar Apr 21 '24 11:04 SMillerDev

Now this is in the test

  Error: cannot load such file -- json_schemer

SMillerDev avatar Apr 22 '24 09:04 SMillerDev

@Bo98 may be able to help out here

MikeMcQuaid avatar Apr 22 '24 12:04 MikeMcQuaid

Because json_schemer is only a part of the pr_upload group. You would need to create a bottle group, add it to there too and update brew bottle to install_bundler_gems! that group (and potentially update test-bot's install for that too).

Bo98 avatar Apr 22 '24 13:04 Bo98

Since we want to use it for bottle and also for API generation, wouldn't a broader install be better?

SMillerDev avatar Apr 24 '24 16:04 SMillerDev

We cannot vendor it for all as it unfortunately depends on a native extension (via simpleidn -> unf -> unf_ext).

We already have rexml in multiple groups so it isn't really a problem having it in potentially many groups.

Bo98 avatar Apr 25 '24 15:04 Bo98

I think/hope this is ready for a final review

SMillerDev avatar Apr 27 '24 18:04 SMillerDev

Not sure how to resolve this

Library/Homebrew/sbom.rb:79:5: C: Homebrew/InstallBundlerGems: Only use Homebrew.install_bundler_gems! in dev-cmd.
    Homebrew.install_bundler_gems!(groups: ["bottle"])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SMillerDev avatar May 03 '24 12:05 SMillerDev

Not sure how to resolve this

Need to move that call to the relevant dev-cmd instead e.g. bottle.

MikeMcQuaid avatar May 03 '24 13:05 MikeMcQuaid

Okay, after my latest changes it definitely hits those paths, but I guess codecov isn't based on the online run?

SMillerDev avatar May 06 '24 18:05 SMillerDev

Okay, after my latest changes it definitely hits those paths, but I guess codecov isn't based on the online run?

It should be: https://github.com/Homebrew/brew/actions/runs/8973658512/job/24644407661?pr=16594#step:13:52

We don't run online tests on macOS in case that's it?

CC @Bo98 for ideas.

MikeMcQuaid avatar May 07 '24 07:05 MikeMcQuaid

Checked the patches and simplified the test a little bit since I think it ran as generic (and would never take those patches). I think we're good to merge now.

SMillerDev avatar May 07 '24 18:05 SMillerDev