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

feat: add base64 Pubkeys from cli #17639

Merged
merged 7 commits into from
Sep 7, 2023
Merged

Conversation

JulianToledano
Copy link
Contributor

Description

Closes:
#10388


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@JulianToledano JulianToledano requested a review from a team as a code owner September 6, 2023 10:00
@github-actions github-actions bot added C:CLI C:Keys Keybase, KMS and HSMs labels Sep 6, 2023
@julienrbrt julienrbrt linked an issue Sep 6, 2023 that may be closed by this pull request
4 tasks
client/keys/add.go Outdated Show resolved Hide resolved
if err != nil {
return err
}
jsonPub := fmt.Sprintf(`{"@type":"%s","key":"%s"}`, tempAny.TypeUrl, b64)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to avoid manual JSON templating?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this is susceptible to some sneak attacks, we can invoke this

jsonPubB, err := json.Marshal(struct{
     Type string `json:"@type,omitempty"`
     Key string `json:"key,omitempty"`
}{tempAny.TypeURL, b64})
if err != nil {
    return fmt.Errorf("failed to JSON marshal typeURL and base64 key: %w", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch guys!! Resolved in last commit!

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thank you for this change @JulianToledano! I've added some code reviews, please take a look.

if err != nil {
return err
}
jsonPub := fmt.Sprintf(`{"@type":"%s","key":"%s"}`, tempAny.TypeUrl, b64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this is susceptible to some sneak attacks, we can invoke this

jsonPubB, err := json.Marshal(struct{
     Type string `json:"@type,omitempty"`
     Key string `json:"key,omitempty"`
}{tempAny.TypeURL, b64})
if err != nil {
    return fmt.Errorf("failed to JSON marshal typeURL and base64 key: %w", err)
}

client/keys/add.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
JulianToledano and others added 2 commits September 6, 2023 19:24
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice work, thank you @JulianToledano! LGTM with some tweaks.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

LGTM!

@julienrbrt
Copy link
Member

lgtm

@julienrbrt julienrbrt added this pull request to the merge queue Sep 7, 2023
Merged via the queue into cosmos:main with commit 933d042 Sep 7, 2023
45 of 46 checks passed
@JulianToledano JulianToledano deleted the feat/add-b64-pubkey branch September 8, 2023 09:04
@julienrbrt
Copy link
Member

@Mergifyio backport release/v0.50.x

Copy link
Contributor

mergify bot commented Nov 10, 2023

backport release/v0.50.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 10, 2023
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
(cherry picked from commit 933d042)

# Conflicts:
#	CHANGELOG.md
julienrbrt added a commit that referenced this pull request Nov 10, 2023
Co-authored-by: Julián Toledano <JulianToledano@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:Keys Keybase, KMS and HSMs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better UX for specifying a pubkey when adding keys with the CLI
5 participants