-
Notifications
You must be signed in to change notification settings - Fork 61
refactor: decrypt PK when it is used #858
base: development
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for ubiquibot-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I
9c58746
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise looks good
@@ -60,7 +60,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => { | |||
payout: { | |||
networkId: networkId, | |||
rpc: rpc, | |||
privateKey: privateKey, | |||
privateKeyEncrypted: privateKeyEncrypted || null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
privateKeyEncrypted
is already string | undefined
, so I think converting it to string | null
is unnecessary step, but not a big deal.
It would also simplify Type.Union([Type.Null(), Type.String()])
into Type.Optional(Type.String())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is more expressive that it is intentionally set to a void value instead of some type of mistake happening.
This PR refactors the code so that partner's wallet private key is decrypted only when the payment permit is about to be generated.
Rationale
We're about to expose the bot's logs to the public. Right now partners' wallets private keys are decrypted on github webhook event. It is pretty easy to leak those PKs via smlth like
logger.info(JSON.stringify(bot.config))
. So this PR makes sure that partners' PKs are encrypted in the initial bot config and decrypted only when necessary (i.e. before the permit generation).QA issue run with the bot instance from the current PR's branch: rndquu-org/test-repo#48