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

Move fulcioroots and tuf packages from cosign #435

Merged
merged 122 commits into from
Jun 10, 2022

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented May 11, 2022

Summary

This moves these packages from sigstore/cosign into sigstore/sigstore.

  • pkg/fulcioroots comes from cosign's cmd/cosign/cli/fulcio/fulcioroots@2ccdb3, and drops that package's behavior when the SIGSTORE_ROOT_FILE env var is set -- this will remain in sigstore/cosign.
  • pkg/tuf comes from cosign's pkg/cosign/tuf@2ccdb3 and is otherwise largely unchanged. Some methods were unexported that aren't used outside of this package.

Part of sigstore/cosign#1865

Release Note

pkg/fulcioroots and pkg/tuf are moved from cosign repo

@imjasonh
Copy link
Member Author

The lint check is failing due to un-doc-commented exported methods, but I think I'd rather just leave those as-is than balloon the changes in this PR. If folks feel strongly about having these commented I think we should do that in a separate PR.

@imjasonh
Copy link
Member Author

@haydentherapper @asraa

@imjasonh imjasonh marked this pull request as draft May 11, 2022 19:28
@imjasonh imjasonh changed the title Move fulcioroots and pkg/tuf from cosign [WIP] Move fulcioroots and pkg/tuf from cosign May 11, 2022
@imjasonh imjasonh changed the title [WIP] Move fulcioroots and pkg/tuf from cosign Move fulcioroots and pkg/tuf from cosign May 11, 2022
@imjasonh imjasonh marked this pull request as ready for review May 11, 2022 19:28
@imjasonh imjasonh changed the title Move fulcioroots and pkg/tuf from cosign Move fulcioroots, test and tuf packages from cosign May 11, 2022
pkg/fulcioroots/fulcioroots.go Outdated Show resolved Hide resolved
pkg/fulcioroots/fulcioroots.go Outdated Show resolved Hide resolved
pkg/tuf/policy.go Show resolved Hide resolved
pkg/tuf/signer.go Show resolved Hide resolved
@imjasonh imjasonh mentioned this pull request May 11, 2022
4 tasks
go.mod Outdated
@@ -33,6 +33,11 @@ require (
gopkg.in/square/go-jose.v2 v2.6.0
)

require (
cloud.google.com/go/storage v1.10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Were there concerns about pulling in this library? Was it just due to size?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'd like to replace it with regular HTTP calls instead of taking a dependency on this GCS package. It's not huge, it's just mostly unnecessary.

@imjasonh
Copy link
Member Author

Any more concerns here? If not I can merge and un-WIP sigstore/cosign#1866 to start using this.

@haydentherapper
Copy link
Contributor

This is a large pr, I want to double check nothing has changed. I don’t have a lot of confidence that a break would be detected once this is used in cosign due to the lack of tests.
I’ll take a look later today or early Monday.

@haydentherapper
Copy link
Contributor

This LGTM - If you're able to wait a few days, it'd be nice to also get @asraa's LGTM since she's the author of the TUF changes.

@asraa
Copy link
Contributor

asraa commented May 17, 2022

I'm back in office and taking a look!

pkg/fulcioroots/fulcioroots.go Outdated Show resolved Hide resolved
pkg/tuf/repository/root.json Show resolved Hide resolved
pkg/tuf/client.go Show resolved Hide resolved
pkg/tuf/client.go Outdated Show resolved Hide resolved
@haydentherapper
Copy link
Contributor

There's active debugging on the TUF client from a recent postmortem, so we may want to hold off on submitting this until that's resolved, as we'd like to get the bug fixed before 1.0

@asraa
Copy link
Contributor

asraa commented May 19, 2022

In particular this is probably worth waiting for the fix for: sigstore/cosign#1899

@imjasonh imjasonh marked this pull request as draft May 19, 2022 16:58
@imjasonh
Copy link
Member Author

Sounds good, I've converted to a draft for now. After the issue is resolved I can pick it back up.

@znewman01
Copy link
Contributor

After we do this: should probably consider sigstore/cosign#1935

@imjasonh
Copy link
Member Author

After we do this: should probably consider sigstore/cosign#1935

I'd be fine cleaning it up first then moving it, too. There's no real rush to move it, especially if it causes confusion during cleanups or bug fixes.

@imjasonh
Copy link
Member Author

imjasonh commented Jun 8, 2022

I'd like to pick this up again after the TUF changes that blocked us last time, and after sigstore/cosign#1967 -- let me know if there's anything else I should wait for, otherwise I'll update this PR.

@imjasonh imjasonh changed the title Move fulcioroots, test and tuf packages from cosign Move fulcioroots and tuf packages from cosign Jun 8, 2022
@imjasonh imjasonh marked this pull request as ready for review June 8, 2022 13:03
asraa and others added 5 commits June 8, 2022 14:48
* fix: fix fetching updated targets from TUF root

Signed-off-by: Asra Ali <asraa@google.com>

add comment

Signed-off-by: Asra Ali <asraa@google.com>

update

Signed-off-by: Asra Ali <asraa@google.com>

update

Signed-off-by: Asra Ali <asraa@google.com>

possible fix windows

Signed-off-by: Asra Ali <asraa@google.com>

lint

Signed-off-by: Asra Ali <asraa@google.com>

fix windows maybe

Signed-off-by: Asra Ali <asraa@google.com>

fix close

Signed-off-by: Asra Ali <asraa@google.com>

* update zack comments

Signed-off-by: Asra Ali <asraa@google.com>

update fix

Signed-off-by: Asra Ali <asraa@google.com>

update and add some debug

Signed-off-by: Asra Ali <asraa@google.com>

add debug

Signed-off-by: Asra Ali <asraa@google.com>

 no cache

Signed-off-by: Asra Ali <asraa@google.com>

remove debug

Signed-off-by: Asra Ali <asraa@google.com>

* try haydens comments

Signed-off-by: Asra Ali <asraa@google.com>

* Use Rekor API for pubkeys before TUF if so specified.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* Address PR feedback, bump golangci-lint from 1.46.0 to 1.46.2

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* Add comments for the env variables.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* Use path instead of filepath, basically revert to what it was before.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* ho hum, really just use the path.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* When interacting with fs do not use OS specific separators.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* fix windows line endings

Signed-off-by: Asra Ali <asraa@google.com>

* pass embedded into initialization

Signed-off-by: Asra Ali <asraa@google.com>

Co-authored-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
* move rekor public key fetch inside GetRekorPubs

Signed-off-by: Asra Ali <asraa@google.com>

* use in-memory metadata and targets, sync to disk on start and updates

Signed-off-by: Asra Ali <asraa@google.com>

update

Signed-off-by: Asra Ali <asraa@google.com>

* Use TUF singleton.

Co-authored-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Asra Ali <asraa@google.com>

* hayden comment, sync.Once used

Signed-off-by: Asra Ali <asraa@google.com>

* return global error

Signed-off-by: Asra Ali <asraa@google.com>

Co-authored-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
Co-authored-by: Furkan Türkal <furkan.turkal@trendyol.com>
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>

Co-authored-by: Furkan Türkal <furkan.turkal@trendyol.com>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
@znewman01
Copy link
Contributor

Lint failures seemingly related

@imjasonh
Copy link
Member Author

imjasonh commented Jun 9, 2022

Lint failures seemingly related

Yeah, there's a lot of un-godoc'ed code in the tuf and fulcioroots packages. I suspect some of them can be addressed by more aggressively unexporting types that don't need to be exported, and godoc'ing the rest, but I don't feel confident enough to document this code well.

I did a little bit of lint-hunting in a previous iteration of this work, which I've done now on this one, but I think the rest should be addressed in a separate PR.

Signed-off-by: Jason Hall <jason@chainguard.dev>
@znewman01
Copy link
Contributor

but I think the rest should be addressed in a separate PR.

Works for me, but is there any way to disable the linter on this code for now so we don't break HEAD?

Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh
Copy link
Member Author

imjasonh commented Jun 9, 2022

Works for me, but is there any way to disable the linter on this code for now so we don't break HEAD?

I've updated the lint action to only complain about findings in changed lines, that will at least let other PRs get merged while these are un-godoc'd.

We'll still need someone to force-merge this over the complaints of the linter in this change though. Or make the check not-required.

@znewman01
Copy link
Contributor

Can you exclude whole directories/specific files instead? IMO that makes more sense, then we can remove that restriction in a follow-up PR and doesn't require any kind of override.

Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh
Copy link
Member Author

imjasonh commented Jun 9, 2022

Can you exclude whole directories/specific files instead? IMO that makes more sense, then we can remove that restriction in a follow-up PR and doesn't require any kind of override.

Good call, done!

@imjasonh
Copy link
Member Author

imjasonh commented Jun 9, 2022

Gentle ping @haydentherapper @asraa -- I'd love to get this in before anything else touches these packages.

@haydentherapper
Copy link
Contributor

Ooo today, will take a look tomorrow!

@dlorenc
Copy link
Member

dlorenc commented Jun 10, 2022

Here we goooo!

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.

None yet