-
Notifications
You must be signed in to change notification settings - Fork 129
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
Validate rsa private key and certificate content format #971
Validate rsa private key and certificate content format #971
Conversation
src/lib/deploy/deploy-support.js
Outdated
const { green, red } = require('colors'); | ||
const { processApiParameters } = require('./deploy-support-api'); | ||
const { getCloudApiClient, getSlsClient, getMnsClient } = require('../client'); | ||
const {green, red} = require('colors'); |
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.
eslint 是如何配置的?
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.
src/lib/deploy/deploy-support.js
Outdated
let p = path.resolve(__dirname, privateKey); | ||
// private key is provided by local file | ||
if (fs.pathExistsSync(p)) { | ||
certConfig.PrivateKey = fs.readFileSync(p, 'utf-8'); |
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.
fs.readFileSync(p, 'utf-8')
=> await fs.readFile(p, 'utf-8')
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.
Done
src/lib/deploy/deploy-support.js
Outdated
let p = path.resolve(__dirname, certificate); | ||
// certificate is provided by local file | ||
if (fs.pathExistsSync(p)) { | ||
certConfig.Certificate = fs.readFileSync(p, 'utf-8'); |
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.
fs.readFileSync(p, 'utf-8')
=> await fs.readFile(p, 'utf-8')
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.
Done
src/lib/deploy/deploy-support.js
Outdated
//endregion | ||
|
||
//region validate RSA private key content | ||
let expectedPrefix = '-----BEGIN RSA PRIVATE KEY-----', expectedSuffix = '-----END RSA PRIVATE KEY-----'; |
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.
写在 const 里面吧
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.
Done
src/lib/deploy/deploy-support.js
Outdated
//endregion | ||
|
||
//region validate certificate content | ||
let expectedPrefix = '-----BEGIN CERTIFICATE-----', expectedSuffix = '-----END CERTIFICATE-----'; |
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.
写在 const 里面吧
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.
Done
test/fs-extra.test.js
Outdated
let path = require('path'); | ||
const expect = require('expect.js'); | ||
|
||
describe('fs-extra module Tests', function () { |
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.
这个测试集的作用是?
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.
- 为了确认 fs-extra 的 pathExists 方法对相对路径的支持方式, 目前确认到的情况是需要使用 path.resolve 先对路径进行解析才行.
- 为了确认 fs-extra 的 pathExists 方法对 PrivateKey 以及 Certificate 是硬编码的 PEM 内容时的返回结果.
需要添加注释? 还是删掉这个测试集?
🤔 |
1 similar comment
🤔 |
Closed as #1146 |
Fix #969.