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

Make artifacts ingester work with both GitHub and OCI providers #3309

Merged
merged 8 commits into from
May 14, 2024

Conversation

JAORMX
Copy link
Contributor

@JAORMX JAORMX commented May 12, 2024

Summary

This modifies the ingester to change its behavior depending on whether
the provider is an OCI provider or a github one.

Closes: #3322

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@JAORMX JAORMX requested a review from a team as a code owner May 12, 2024 14:52
Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@JAORMX JAORMX marked this pull request as draft May 12, 2024 14:54
Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@rdimitrov
Copy link
Member

I know you thought of it but just to remind that the artifact verifier also interacts with the registry so both of these changes should be merged as a pair 👍


// in case of the GitHub provider, a package version may be
// linked to multiple tags
func (gv *githubVersioner) GetVersions(ctx context.Context) ([]*minderv1.ArtifactVersion, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should be part of the provider interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that, but it seemed quite involved and I'm not even sure if we're going to continue using this artifact-builtin going forward. I'm leaning more towards minimal, individual checks instead. Gotta give it some thought.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@coveralls
Copy link

coveralls commented May 13, 2024

Coverage Status

coverage: 49.135% (-0.2%) from 49.285%
when pulling f9251c1 on oci-attestations
into 1851f4c on main.

@stacklokbot
Copy link
Contributor

Minder analyzed this PR with Trusty and found no dependencies scored lower than your profile threshold.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@stacklokbot
Copy link
Contributor

Minder analyzed this PR with Trusty and found no dependencies scored lower than your profile threshold.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@JAORMX JAORMX marked this pull request as ready for review May 14, 2024 07:44
@JAORMX
Copy link
Contributor Author

JAORMX commented May 14, 2024

Note that this still doesn't fully work, but it sure gets us forward. I have to apply the following diff for it to actually work:

diff --git a/internal/verifier/sigstore/container/container.go b/internal/verifier/sigstore/container/container.go
index 201d1d10e..63d14b826 100644
--- a/internal/verifier/sigstore/container/container.go
+++ b/internal/verifier/sigstore/container/container.go
@@ -612,7 +612,7 @@ func getBundleMsgSignature(simpleSigningLayer v1.Descriptor) (*protobundle.Bundl
 
 // BuildImageRef returns the OCI image reference
 func BuildImageRef(registry, owner, artifact, version string) string {
-       return fmt.Sprintf("%s/%s/%s@%s", registry, owner, artifact, version)
+       return fmt.Sprintf("%s/%s/%s:%s", registry, owner, artifact, version)
 }
 
 type sigstoreBundle struct {

which indicates something off about the BuildImageRef function (at least I don't understand how it currently works).

It puts a @ in the reference, which is usually (according to the spec) needed for checksums, while we pass a tag. If we build the reference with a : instead, it works as expected as it's able to parse the tagged reference. We need to investigate why this works with github currently and what we could do about this.

anyway, for the sake of keeping iterations small, I suggest we merge as is if it works with GH as expected.


// in case of the GitHub provider, a package version may be
// linked to multiple tags
func (gv *githubVersioner) GetVersions(ctx context.Context) (map[string]*minderv1.ArtifactVersion, error) {
Copy link
Contributor

@dmjb dmjb May 14, 2024

Choose a reason for hiding this comment

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

Can we put these methods behind the provider interface instead of building wrappers around the providers here?

(Specifically, I am thinking of a Versioner trait)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mind if I do that in a separate PR? There's still a bunch of fixes I'm doing.

This modifies the ingester to change its behavior depending on whether
the provider is an OCI provider or a github one.

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
It's used differently than I thought

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
@stacklokbot
Copy link
Contributor

Minder analyzed this PR with Trusty and found no dependencies scored lower than your profile threshold.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

The logic to refer to containers is now changed to using the `Sha` field
from the ArtifactVersions since this is what the bebavior was. With
this, we can now evaluate policies with the dockerhub provider!!

The usage of the word version around the verifier was misleading, so
this was fixed so the code and expectations are easier to follow.

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
@stacklokbot
Copy link
Contributor

Minder analyzed this PR with Trusty and found no dependencies scored lower than your profile threshold.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Invisible Unicode Characters Detected.

Copy link
Contributor

@stacklokbot stacklokbot left a comment

Choose a reason for hiding this comment

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

✅ No Mixed Scripts Detected.

@JAORMX JAORMX merged commit daccbc1 into main May 14, 2024
41 checks passed
@JAORMX JAORMX deleted the oci-attestations branch May 14, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get OCI providers working with the artifact_signature rule type
6 participants