8000 handle attest case insensitivity by ejahnGithub · Pull Request #9392 · cli/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

handle attest case insensitivity #9392

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

Merged
merged 8 commits into from
Jul 31, 2024

Conversation

ejahnGithub
Copy link
Contributor
@ejahnGithub ejahnGithub commented Jul 30, 2024

fixes https://github.com/github/package-security/issues/1727

Updated SANRegex for case insensitivity, removed SourceRepositoryOwnerURI and SourceRepositoryURI from extensions into sigstore-go, retrieved verification results, and performed case-insensitive extension matching.


func VerifyCertExtensions(results []*AttestationProcessingResult, owner string, repo string) error {
for _, attestation := range results {
if owner != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

the owner must always be set (compare with how the sourceRepositoryOwnerURI was set before), can't be allowed to be an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove the if condition

func VerifyCertExtensions(results []*AttestationProcessingResult, owner string, repo string) error {
for _, attestation := range results {
if owner != "" {
expectedSourceRepositoryOwnerURI := fmt.Sprintf("https://github.com/%s", owner)
Copy link
Contributor

Choose a reason for hiding this comment

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

with proxima, this prefix (https://github.com) is going to change depending on the tenant. this should not be hardcode here; maybe the prefix is passed in as an option, or is set to a default if the option is ""?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a todo for future task for proxima

extensions := certificate.Extensions{
SourceRepositoryOwnerURI: fmt.Sprintf("https://github.com/%s", opts.Owner),
RunnerEnvironment: runnerEnv,
func buildCertExtensions(runnerEnv string) certificate.Extensions {
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't need to be its own function anymore, can just pass in the variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updatd

@ejahnGithub ejahnGithub marked this pull request as ready for review July 30, 2024 20:23
@ejahnGithub ejahnGithub requested a review from a team as a code owner July 30, 2024 20:23
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Jul 30, 2024
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

@ejahnGithub ejahnGithub requested a review from phillmv July 30, 2024 20:29
// TODO: handle proxima prefix
expectedSourceRepositoryOwnerURI := fmt.Sprintf("https://github.com/%s", owner)
sourceRepositoryOwnerURI := attestation.VerificationResult.Signature.Certificate.Extensions.SourceRepositoryOwnerURI
if sourceRepositoryOwnerURI != "" && !strings.EqualFold(expectedSourceRepositoryOwnerURI, sourceRepositoryOwnerURI) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If sourceRepositoryOwnerURI != "", then the extension is not set in the certificate, which I think should be an error instead of succeeding?

In sigstore-go, we check actualFieldVal.IsValid(), but I believe that will return true for an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense. remove the logic of checking sourceRepositoryOwnerURI is empty.

// TODO: handle proxima prefix
expectedSourceRepositoryURI := fmt.Sprintf("https://github.com/%s", repo)
sourceRepositoryURI := attestation.VerificationResult.Signature.Certificate.Extensions.SourceRepositoryURI
if sourceRepositoryURI != "" && !strings.EqualFold(expectedSourceRepositoryURI, sourceRepositoryURI) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above, for sourceRepositoryURI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense. remove the logic of checking sourceRepositoryURI is empty.

@ejahnGithub ejahnGithub requested a review from steiza July 31, 2024 14:34
Copy link
Contributor
@steiza steiza left a comment

Choose a reason for hiding this comment

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

Looks good to me! Might also be good to get @malancas to review as the original author.

@steiza steiza requested a review from malancas July 31, 2024 15:23
Copy link
Contributor
@malancas malancas left a comment

Choose a reason for hiding this comment

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

LGTM

@ejahnGithub ejahnGithub merged commit 89cbcfe into trunk Jul 31, 2024
16 checks passed
@ejahnGithub ejahnGithub deleted the eugene/gh-attestation-case-insensitivity branch July 31, 2024 22:19
izumin5210 referenced this pull request in izumin5210/dotfiles Aug 6, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://togithub.com/cli/cli) | minor | `v2.53.0` ->
`v2.54.0` |

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.54.0`](https://togithub.com/cli/cli/releases/tag/v2.54.0):
GitHub CLI 2.54.0

[Compare Source](https://togithub.com/cli/cli/compare/v2.53.0...v2.54.0)

#### What's Changed

- Remove redundant whitespace by
[@&#8203;jessehouwing](https://togithub.com/jessehouwing) in
[https://github.com/cli/cli/pull/9334](https://togithub.com/cli/cli/pull/9334)
- Remove attestation test that requires being online by
[@&#8203;steiza](https://togithub.com/steiza) in
[https://github.com/cli/cli/pull/9340](https://togithub.com/cli/cli/pull/9340)
- Update documentation for gh api PATCH by
[@&#8203;cmbuckley](https://togithub.com/cmbuckley) in
[https://github.com/cli/cli/pull/9352](https://togithub.com/cli/cli/pull/9352)
- Clarify usage of template flags for PR and issue creation by
[@&#8203;williammartin](https://togithub.com/williammartin) in
[https://github.com/cli/cli/pull/9354](https://togithub.com/cli/cli/pull/9354)
- Expose json databaseId field for release commands by
[@&#8203;williammartin](https://togithub.com/williammartin) in
[https://github.com/cli/cli/pull/9356](https://togithub.com/cli/cli/pull/9356)
- Expose fullDatabaseId for PR json export by
[@&#8203;williammartin](https://togithub.com/williammartin) in
[https://github.com/cli/cli/pull/9355](https://togithub.com/cli/cli/pull/9355)
- Handle `--bare` clone targets by
[@&#8203;hyperrealist](https://togithub.com/hyperrealist) in
[https://github.com/cli/cli/pull/9271](https://togithub.com/cli/cli/pull/9271)
- Slightly clarify when CLI exits with code 4 by
[@&#8203;williammartin](https://togithub.com/williammartin) in
[https://github.com/cli/cli/pull/9358](https://togithub.com/cli/cli/pull/9358)
- Update sigstore-go in gh CLI to v0.5.1 by
[@&#8203;steiza](https://togithub.com/steiza) in
[https://github.com/cli/cli/pull/9366](https://togithub.com/cli/cli/pull/9366)
- Exit with 1 on authentication issues by
[@&#8203;Stausssi](https://togithub.com/Stausssi) in
[https://github.com/cli/cli/pull/9240](https://togithub.com/cli/cli/pull/9240)
- build(deps): bump github.com/gabriel-vasile/mimetype from 1.4.4 to
1.4.5 by [@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/cli/cli/pull/9372](https://togithub.com/cli/cli/pull/9372)
- build(deps): bump github.com/google/go-containerregistry from 0.20.0
to 0.20.1 by [@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/cli/cli/pull/9373](https://togithub.com/cli/cli/pull/9373)
- Add `--remove-milestone` option to `issue edit` and `pr edit` by
[@&#8203;babakks](https://togithub.com/babakks) in
[https://github.com/cli/cli/pull/9344](https://togithub.com/cli/cli/pull/9344)
- handle attest case insensitivity by
[@&#8203;ejahnGithub](https://togithub.com/ejahnGithub) in
[https://github.com/cli/cli/pull/9392](https://togithub.com/cli/cli/pull/9392)

#### New Contributors

- [@&#8203;cmbuckley](https://togithub.com/cmbuckley) made their first
contribution in
[https://github.com/cli/cli/pull/9352](https://togithub.com/cli/cli/pull/9352)
- [@&#8203;hyperrealist](https://togithub.com/hyperrealist) made their
first contribution in
[https://github.com/cli/cli/pull/9271](https://togithub.com/cli/cli/pull/9271)
- [@&#8203;Stausssi](https://togithub.com/Stausssi) made their first
contribution in
[https://github.com/cli/cli/pull/9240](https://togithub.com/cli/cli/pull/9240)
- [@&#8203;ejahnGithub](https://togithub.com/ejahnGithub) made their
first contribution in
[https://github.com/cli/cli/pull/9392](https://togithub.com/cli/cli/pull/9392)

**Full Changelog**: cli/cli@v2.53.0...v2.54.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job
log](https://developer.mend.io/github/izumin5210/dotfiles).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: izumin5210-update-aqua-checksum[bot] <169593670+izumin5210-update-aqua-checksum[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external pull request originating outside of the CLI core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0