Commit Graph

24 Commits

Author SHA1 Message Date
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
Sebastiaan van Stijn
175973babc switch to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 22:59:12 +02:00
CrazyMax
94e2370023 provenance: move types to a dedicated package
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-02-25 20:39:50 +01:00
Jonathan A. Sternberg
40fb5ce649 llbsolver: unmarshal protobuf objects into the provenance attestation correctly
This modifies how build steps are unmarshaled from JSON into the
provenance attestation. The current method doesn't correctly handle
protobuf attributes that are used with `oneof`.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-11-13 09:57:30 -06:00
Paul "TBBle" Hampson
98e0d8dcff Whenever copying OCI Platform data, include OSVersion and OSFeatures
Trivially created by looking for every reference to .Variant and adding
OSVersion and OSFeatures, except the ones related to the string
representation of a Platform instance.

I then went through and ensured every assignment of OSFeatures that
might leak out, i.e., not local-only or for marhsalling purposes, uses
the append-to-nil idiom to avoid sharing the slice storage and allowing
accidental mutation after-the-fact.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-11-03 12:19:29 +09:00
Sebastiaan van Stijn
2d3722e50a migrate to github.com/distribution/reference v0.5.0
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf

Also updating docker/docker, which also switched to this new module;

vendor: github.com/docker/docker 032797ea4bcb (v25.0.0-dev)

full diff: afd4805278...032797ea4b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-05 15:29:27 +02: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
Tonis Tiigi
32dcdff1a0 resources: store sys cpu usage per step
This can be used to convert step usage to relative units.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:51:35 -07:00
Tonis Tiigi
6e87e4b455 resources: add build step resource tracking via cgroups
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:51:31 -07:00
Justin Chadwell
7af75e706c solver: move AddBuildConfig into llbsolver package
The data structures used by llbsolver shouldn't be bundled into the same
package as the actual creation of the build config.

As it was, it wasn't possible to use the data structures (in tests,
external libraries using buildkit, etc) without pulling in more of
buildkit than was probably intended.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-06-01 11:25:25 +01:00
Justin Chadwell
ff5baa0f5f solver: merge local and remote images into single list
This also allows us to specify that local images should be generated
with exactly the same specification as remote images, but with the
pkg:oci scheme instead of pkg:docker.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-05-31 10:54:55 +01:00
Justin Chadwell
80ea813b03 purl: allow RefToPURL to take a type parameter
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-05-31 10:54:54 +01:00
Tonis Tiigi
1553c2ad95 add language property for sourcemap
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-29 17:17:56 -07:00
Justin Chadwell
e398498499 provenance: fix possible empty digest access
If the digest for an ImageSource is the empty string, then calling
`Digest.Algorithm` will panic at runtime.

This scenario *can* happen if `ResolveImageConfig` returns an empty
digest, but correctly returns a config object. This doesn't occur in
buildkit directly, however, buildkit-in-moby implements a custom worker
which also performs image lookups on local images, in which case the
digest for the index may not be available (though this may be possible
with the containerd image store?).

Therefore, we shouldn't assume that the digest is always available in
buildkit, and should instead check that is valid before inserting it
into the digest set (which is already an optional map).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-05-24 10:48:40 +01:00
Tonis Tiigi
90be07e9ff provenance: ensure URLs are redacted before written
HTTP and Git URLs may contain inlined credentials in some cases.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-02-28 08:32:21 -08:00
Tonis Tiigi
ad85ce74b1 provenance: fix the order of the build steps
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-19 22:02:27 -08:00
Tonis Tiigi
103a0a1f74 provenance: move hermetic field into a correct struct
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-19 22:02:11 -08: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
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
39f681371e provenance: filter our cache-imports
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-14 20:03:53 -08:00
Tonis Tiigi
fc30766300 add digests to provenance and traces
This allows matching spans from traces with provenance
and status records.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-14 19:55:45 -08:00
Tonis Tiigi
96eed42c60 provenance: do not put unique identifiers in build steps
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-14 11:59:08 -08: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
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