Skip to content

Conversation

@wking
Copy link
Member

@wking wking commented Apr 21, 2022

Sometimes we fail to verify because we find signatures we don't trust. Sometimes we fail to find signatures at all, either because the backing stores have no signatures, or because we fail to contact the backing stores. With this commit, we pass all that useful debugging context on to the caller. Not in the string, because we don't want to overwhelm all callers, but they can get it via Unwrap so they can show the details where they have space to do so.

Sometimes we fail to verify because we find signatures we don't trust.
Sometimes we fail to find signatures at all, either because the
backing stores have no signatures, or because we fail to contact the
backing stores.  With this commit, we pass all that useful debugging
context on to the caller.  Not in the string, because we don't want to
overwhelm all callers, but they can get it via Unwrap [1] so they can
show the details where they have space to do so.

[1]: https://pkg.go.dev/errors#Unwrap
@wking wking changed the title pkg/verify/verify: Expose underlying signature errors pkg/verify: Expose underlying signature errors Apr 21, 2022
@wking wking force-pushed the expose-underlying-signature-errors branch from 1ca5837 to 1b9753d Compare April 21, 2022 16:33
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 21, 2022
@wking wking changed the title pkg/verify: Expose underlying signature errors Bug 2071998: pkg/verify: Expose underlying signature errors Apr 21, 2022
@openshift-ci openshift-ci bot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Apr 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 21, 2022

@wking: This pull request references Bugzilla bug 2071998, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.11.0) matches configured target release for branch (4.11.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jiajliu

Details

In response to this:

Bug 2071998: pkg/verify: Expose underlying signature errors

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot requested a review from jiajliu April 21, 2022 16:40
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 21, 2022

@wking: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

err error
}

func (e *wrapError) Error() string {
Copy link
Member

Choose a reason for hiding this comment

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

s/Error()/ErrorStr()/

Copy link
Member Author

Choose a reason for hiding this comment

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

wrapError is from Go, because I wanted fmt.Sprintf("...%w")'s Unwrap support, but without formatting the whole, possibly long aggregate error into the message. We need to use Error and Unwrap to match the error interface.

}
return fmt.Errorf("unable to locate a valid signature for one or more sources")
err := &wrapError{
msg: fmt.Sprintf("unable to verify %s against keyrings: %s", releaseDigest, strings.Join(remainingKeyRings, ", ")),
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we are logging the keys too. I am wondering if it is fine from security point of view>

Copy link
Member Author

Choose a reason for hiding this comment

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

we're logging the keyring name, which is already public in our GitHub source. The only secret keys here are internal to Red Hat's build-time release signing. By the time we get out to clusters verifying signatures, it's all public names and public keys.

Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LalatenduMohanty, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit c1f281b into openshift:master Apr 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 21, 2022

@wking: Some pull requests linked via external trackers have merged:

The following pull requests linked via external trackers have not merged:

These pull request must merge or be unlinked from the Bugzilla bug in order for it to move to the next state. Once unlinked, request a bug refresh with /bugzilla refresh.

Bugzilla bug 2071998 has not been moved to the MODIFIED state.

Details

In response to this:

Bug 2071998: pkg/verify: Expose underlying signature errors

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@wking wking deleted the expose-underlying-signature-errors branch April 21, 2022 21:14
wking added a commit to wking/cluster-version-operator that referenced this pull request Apr 21, 2022
Picking up openshift/library-go@1b9753d298 (Bug 2071998: pkg/verify:
Expose underlying signature errors, 2022-04-21,
openshift/library-go#1358).  Generated with:

  $ go get -u github.com/openshift/library-go
  go: downloading github.com/openshift/library-go v0.0.0-20220421210707-c1f281b7efaa
  go: downloading github.com/prometheus/client_golang v1.11.1
  go get: upgraded github.com/openshift/library-go v0.0.0-20220407182450-db47826e7275 => v0.0.0-20220421210707-c1f281b7efaa
  go get: upgraded github.com/prometheus/client_golang v1.11.0 => v1.11.1
  $ go mod tidy
  $ go mod vendor
  $ git add -A go.* vendor

using:

  $ go version
  go version go1.17.3 linux/amd64

[1]: openshift/library-go#1358
wking added a commit to wking/openshift-library-go that referenced this pull request May 19, 2022
Extending 1b9753d (pkg/verify: Expose underlying signature errors,
2022-04-21, openshift#1358) with timestamps, so it's easy to see what's slow in
situations like [1] where some portion of signature verification is
surprisingly slow, and it's currently not clear what aspect is causing
the slowdown.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=2071998#c2
wking added a commit to wking/openshift-library-go that referenced this pull request May 19, 2022
Extending 1b9753d (pkg/verify: Expose underlying signature errors,
2022-04-21, openshift#1358) with information about when store retrieval is
exhausted, so it's easy to see what's slow in situations like [1]
where some portion of signature verification is surprisingly slow, and
it's currently not clear what aspect is causing the slowdown.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=2071998#c2
wking added a commit to wking/cluster-version-operator that referenced this pull request May 23, 2022
Picking up openshift/library-go@1b9753d298 (Bug 2071998: pkg/verify:
Expose underlying signature errors, 2022-04-21,
openshift/library-go#1358) and openshift/library-go#1371.  Generated
with:

  $ go get -u github.com/openshift/library-go
  $ go mod tidy
  $ go mod vendor
  $ git add -A go.* vendor

using:

  $ go version
  go version go1.17.3 linux/amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants