Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[expo-updates][cli] Update CLI to separate private keys from code signing certificate #16979

Merged
merged 3 commits into from
Apr 14, 2022

Conversation

wschurman
Copy link
Member

Why

The private key should be treated as sensitive information (somewhat like apple credentials are in the old expo-cli). Therefore, when generated, they should be encouraged to be put in a separate directory from the code signing certificate and then either added to .gitignore or encrypted with git-crypt. The user still has the option to put them anywhere they like and store them however they desire (in or out of the repo).

How

Update the generation and configuration CLIs to take multiple paths.

Test Plan

Run tests.

$ yarn expo-updates codesigning:generate --key-output-directory=keys --certificate-output-directory=certificates --certificate-validity-duration-years=2 --certificate-common-name=cs
Generated public and private keys output to /Users/wschurman/temp/sign-test/keys. Remember to add them to .gitignore or to encrypt them. (e.g. with git-crypt)
Generated code signing certificate output to /Users/wschurman/temp/sign-test/certificates.
To automatically configure this project for code signing, run `yarn expo-updates codesigning:configure --certificate-input-directory=certificates --key-input-directory=keys`.
✨  Done in 0.97s.

$ yarn expo-updates codesigning:configure --certificate-input-directory=certificates --key-input-directory=keys

Code signing configuration written to app.json.
✨  Done in 0.27s.

if (value === undefined || value === null) {
Log.exit(`${name} must not be null`);
}
if (typeof value !== type) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't assertArgs already check the type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it coerces the type according to the readme: https://github.com/vercel/arg/blob/main/README.md
Though it doesn't support required args: https://github.com/vercel/arg/blob/main/README.md#how-do-i-require-an-argument-with-arg

I think I prefer to leave it just to be sure since it's unclear to me what the lib does and doesn't do.

Copy link
Contributor

Choose a reason for hiding this comment

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

arg does assert the value i.e. { foobar: String } + --foobar = assertion about a missing value.

Copy link
Member Author

@wschurman wschurman Apr 13, 2022

Choose a reason for hiding this comment

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

Trying this out:

  • it coerces the type, so using Number constructor in arg but passing a string argument in the CLI will just result in the value being NaN rather than throwing. Don't see a fix for this since the coercion happens in the framework. Maybe all args should be String and then conversion to Number should happen in application code?
  • it doesn't have a way to require args be present. Failing to pass an arg doesn't throw in arg code and instead makes to the application code.
  • Passing empty for an arg also results in NaN I believe, so --arg= is also not validated by the framework.

Copy link
Member

Choose a reason for hiding this comment

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

The answer to "how do I require an arg?" is "do it yourself", so we need a function like this one.

It sounds like the type checking in this function isn't needed because assertArgs handles coercion. We may want to add a NaN check (Number.isNaN) in addition to the null/undefined checks.

Suggestion: rename this function to requireArg or enforceArg since what it does is different the existing assertArgs function and using a different verb will make that distinction clearer. Remove the type check since assertArgs does coercion. Maybe add a NaN check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. Note that this whole discussion also applies to the new expo CLI from which these argument utils were copypasta'd.

@wschurman wschurman requested a review from ide April 11, 2022 17:42
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 11, 2022
@wschurman wschurman requested a review from EvanBacon April 13, 2022 21:31
@wschurman wschurman merged commit 3425e61 into main Apr 14, 2022
@wschurman wschurman deleted the @wschurman/git-warning branch April 14, 2022 00:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants