Commit Graph

34 Commits

Author SHA1 Message Date
Laurent Goderre
2782f14746 Added way to configure SBOM scanner
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2024-09-30 16:11:32 -04:00
Jonathan A. Sternberg
1a3fc0aa15 protobuf: remove gogoproto
Remove gogoproto in favor of the standard protobuf compiler. This
removes any nonstandard extensions that were part of gogoproto such as
the custom types.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-26 12:57:45 -05:00
Tonis Tiigi
031b3162ed llbsolver: add more otel spans for export and history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-05 19:52:49 -07:00
Tonis Tiigi
30c069cb03 replace resolveimageconfig with generic sourcemetaresolver
This is more versatile function that works for any source,
not just images.

It can be used together with a policy that switches
between input and output source as well as for adding
additional metadata for other sources in the future.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-02-11 22:06:23 -08:00
Justin Chadwell
a609d2ea2f sbom: propogate image-resolve-mode for generator image
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-06-28 11:23:02 +01:00
Tonis Tiigi
509cfa3916 llbsolver: add systemusage samples to provenance attestation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:52:02 -07:00
Justin Chadwell
7ca2cd9859 solver: skip sbom post processor if result is nil
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-04-18 14:32:09 +01:00
Tõnis Tiigi
98f29652e7 Merge pull request #3707 from jedevc/comparable-interfaces
Use comparables instead of reflection in result struct
2023-03-27 10:21:05 -07:00
Justin Chadwell
8f603dba0e solve: use comparables instead of reflection in result struct
Since go 1.20, interfaces (that can be compared) now implement the
comparable interface. The use of reflection in solver/result was a
workaround for this limitation, however, we can remove this with the
upstream fix.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-03-22 12:04:54 +00:00
CrazyMax
6d9c24dc3a remove buildinfo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-10 09:46:52 +01:00
Tonis Tiigi
994b5291f8 llbsolver: fix panic when requesting provenance on nil result
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-01-05 23:25:07 -08:00
Tõnis Tiigi
617b78cb69 Merge pull request #3416 from jedevc/filter-frontend-provenance
Filter frontend provenance attestations
2023-01-03 16:25:01 -08:00
Tonis Tiigi
4d4b56a648 add possibility to override filename for provenance
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-19 20:45:27 -08:00
Justin Chadwell
3bc2aa6e23 result: change reason types to strings
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-16 12:46:44 +00:00
Tõnis Tiigi
0339524fad Merge pull request #3415 from thaJeztah/intoto_tagged_version
vendor: github.com/in-toto/in-toto-golang v0.5.0
2022-12-15 16:11:19 -08:00
Justin Chadwell
d3700c0a5a solver: apply no-cache to generated sboms
The fallback scanner should also respect the no-cache value if set.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-15 17:49:22 +00:00
Sebastiaan van Stijn
e83fc5cc58 vendor: github.com/in-toto/in-toto-golang v0.5.0
switch to a tagged release.

Also renamed the alias to slsa02 to match what the project itself uses.

https://github.com/in-toto/in-toto-golang/compare/fa494aaa0add...v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-15 16:45:20 +01:00
Tonis Tiigi
179bed6b4c history api: save provenance to history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:41 -08:00
Tonis Tiigi
079505fb1b provenance: allow builder ID to set with attrs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Justin Chadwell
063056313f Revert "exporter: detect if multi-platform is set"
This reverts commit 6f21d6b403.

We don't need the exporter opts for multiplatform, they were a hack to
attempt to preserve the semantics of converting between Ref->Refs
freely (both buildkit-side and frontend-side).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-12 14:55:00 +00:00
Justin Chadwell
3b74e94b7d solver: remove force refs
We no longer need to (or should) force refs conversion.

A single Ref is distinctly different from a Refs map with a single
element - they express the user-specified difference between whether
multi-platform exports should be used or not. It's important to preserve
this sematic, especially on the side of the frontend, where it can't be
recovered if lost.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-12 14:22:00 +00:00
Justin Chadwell
74ab7cdb10 Revert "attestations: merge attestation refs into result refs map"
This reverts commit f2c770e45e.

This patch reworks the attestations code back out of the Refs map. The
logic for this change is that the loss-of-granularity in the data
structure for the protobuf requires convoluted logic in the exporter to
be able to determine the correct multi-platform behaviour.

Prior to attestations, Refs directly mapped each platform to a
reference. Attestations changed this structure, which means that there
is no longer a concrete way to determine if a reference should be
exported with multi-platform semantics or not (e.g. should a local
export with a single platform be flat/nested, should an image export use
an oci manifest or an oci index).

This patch restores the previous semantics, moving the attestion refs
back, pushing the attestations back down into a separate struct. This
has the disadvantage of requiring the result.Attestation struct to be
generic, however, this does simplify some of the helper methods around
it.

By changing this logic, we're able to simplify a few key pieces of
logic:
- Fewer version interop concerns. Because we're not changing the
  structure of Ref/Refs between buildkit versions, mixing frontends and
  buildkit versions will *always* produce the expected result. If a
  frontend attaches attestations they won't be transmitted at all
  automatically. Additionally, because attestations can also be attached
  to a single Ref, the frontend doesn't need to force an index in the
  future.
- Less complex exporter logic, we don't need to any magic around
  detecting the user intention with regards to multi-platform exports,
  we simply follow the previous semantics of len(res.Refs) > 0. We only
  need the small snippet that ensures that the inline-only attestations
  don't get attached to a single manifest, to keep the docker load case
  working.
- Some simplification of the SBOM scanner code, we can return an
  Attestation[llb.State], which we can then easily Convert into an
  actual Attestation[Ref].

The patch looks large, but most of the changes are mostly just function
signature changes - the meat of the changes is in the rework of the
platform detection code. This is so we can support the use case of Ref +
Attestations, Refs + Attestations (multi-platform=false) and Refs +
Attestations (multi-platform=true).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-12 14:22:00 +00:00
Justin Chadwell
8e107a6237 provenance: set default mode=max if not set
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-06 20:17:21 +00:00
Justin Chadwell
3e3618b519 provenance: allow special inline option to include only in image outputs
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-30 14:07:02 +00:00
Justin Chadwell
c93d520e3f provenance: remove explicit mode=disabled option
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-30 14:06:52 +00:00
Justin Chadwell
f1e5d695d3 solver: add metadata to attestations
We can now attach a reason for why each attestation was generated, which
will in future allow us to include/exclude specific attestation types
from exporters if desired.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-30 14:04:49 +00:00
Justin Chadwell
0df1bb2081 exporter: add support for attestations to local exporter
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-23 16:31:23 +00:00
Justin Chadwell
62a2fb1335 frontend: combine attestation packages
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-17 13:25:59 +00:00
Tonis Tiigi
9acc6d30eb refactor buildinfo into provenance capture
Change how provenance information is captured from builds.

While previously frontend passed the buildinfo
sources with metadata, now all information is captured
through buildkit. A frontend does not need to implement
buildinfo and can't set incorrect/incomplete buildinfo
for a build result.

All LLB operations can now collect as much provenance
info as they like that will be used when making the
attestation. Previously this was limited to a single Pin
value. For example now we also detect secrets and SSH IDs
that the build uses, or if it accesses network, if local
sources are used etc.. The new design makes sure this
can be easily extended in the future.

Provenance capture can now detect builds that do
multiple separate subsolves in sequence. For example,
first subsolve gathers the sources for the build and
second one builds from immutable sources without a
network connection. If first solve does not participate
in final build result it does not end up in provenance.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:03 -08:00
Tonis Tiigi
a20e48f36d provenance: add layers support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:03 -08:00
Tonis Tiigi
915d7dcf7a provenance: build definition support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:03 -08:00
Tonis Tiigi
5d5a6b93e0 Add slsa provenance attestation unless disabled
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:02 -08:00
Justin Chadwell
aacbedbb41 sbom: add post-processor to perform sbom fallback
This adds functionality to perform an SBOM scan if the frontend did not
produce a valid SBOM.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-10-13 18:17:53 +01:00
Justin Chadwell
6519283291 solver: add post-processor to convert Ref to Refs map
This adds a new processor to pass to Solve that converts a result's unit Ref
output to a simple Refs map type, which is required to be able to add
attestations at this point.

All metadata is appropriately converted, so that the new result should
have the same semantics as the old one.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-10-13 18:17:46 +01:00