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: hide secrets in yarn config commands #1228

Merged
merged 4 commits into from
Apr 22, 2020

Conversation

paul-soporan
Copy link
Member

What's the problem this PR addresses?

  1. Nested secrets aren't hidden in the output of the yarn config command (e. g. npmScopes.scope.npmAuthToken) by the existing implementation.
  2. No secrets are hidden in the output of the yarn config set command.

How did you fix it?

I created a new hideSecrets function that recursively hides secrets and a new getSecret method on the Configuration class that returns a configuration value with all secrets hidden.

I replaced the existing implementation with the new configuration.getSecret method.

Copy link
Member

@arcanis arcanis 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! Can you also add a test?

packages/yarnpkg-core/sources/Configuration.ts Outdated Show resolved Hide resolved
});

const firstToken = configuration.getForDisplay(`npmAuthToken`);
const secondToken = configuration.getForDisplay(`npmScopes`).get(`myScope`).get(`npmAuthToken`);
Copy link
Member

Choose a reason for hiding this comment

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

While keeping a unit test here is fine, I tend to prefer integration tests.

The reason for that is that because they are typically wider in scope, they also test behaviours closer from what real-life users will experience. For example, while you did test that getForDisplay works, you didn't test that it actually gets used by yarn config get. As a result, it's quite possible for someone to make an accidental regression during a refactoring.

Food for thought 🙂

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.

2 participants