tls: make Server.getTicketKeys throw instead of assert#58365
tls: make Server.getTicketKeys throw instead of assert#58365nektro wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58365 +/- ##
==========================================
- Coverage 89.89% 89.87% -0.02%
==========================================
Files 656 656
Lines 193141 193142 +1
Branches 37886 37888 +2
==========================================
- Hits 173623 173586 -37
- Misses 12051 12096 +45
+ Partials 7467 7460 -7
🚀 New features to boost your workflow:
|
|
The linter pipeline section seems to be broken. |
|
anything i need to do on my end? |
1e09a9f to
19a54a8
Compare
assert is for invariants and print a message about the condition being a bug in Node.js if false. throw ERR_INVALID_ARG_VALUE for publicly facing validation.
19a54a8 to
b2dd7ec
Compare
joyeecheung
left a comment
There was a problem hiding this comment.
The PR is updatingServer.setTicketKeys but the commit message talks about Server.getTicketKeys instead. Can you update the commit message?
| assert(keys.byteLength === 48, | ||
| 'Session ticket keys must be a 48-byte buffer'); | ||
| if (keys.byteLength !== 48) { | ||
| throw new ERR_INVALID_ARG_VALUE('keys', keys.byteLength, 'must be exactly 48 bytes'); |
There was a problem hiding this comment.
| throw new ERR_INVALID_ARG_VALUE('keys', keys.byteLength, 'must be exactly 48 bytes'); | |
| throw new ERR_INVALID_ARG_VALUE('keys.byteLength', keys.byteLength, 'must be 48 bytes'); |
The original message looks a bit ambiguous to me by saying "received N" (but N=buffer.byteLength isn't the argument. The buffer is).
|
|
||
|
|
||
| Server.prototype.setTicketKeys = function setTicketKeys(keys) { | ||
| validateBuffer(keys); |
There was a problem hiding this comment.
| validateBuffer(keys); | |
| validateBuffer(keys, 'keys'); |
This predated the PR but since it's adding a test for the message, let's align the two names.
| { | ||
| name: 'TypeError', | ||
| code: 'ERR_INVALID_ARG_TYPE', | ||
| message: 'The "buffer" argument must be an instance of Buffer, TypedArray, or DataView.' + |
There was a problem hiding this comment.
| message: 'The "buffer" argument must be an instance of Buffer, TypedArray, or DataView.' + | |
| message: 'The "keys" argument must be an instance of Buffer, TypedArray, or DataView.' + |
| { | ||
| name: 'TypeError', | ||
| code: 'ERR_INVALID_ARG_VALUE', | ||
| message: `The argument 'keys' must be exactly 48 bytes. Received ${arg.byteLength}`, |
There was a problem hiding this comment.
| message: `The argument 'keys' must be exactly 48 bytes. Received ${arg.byteLength}`, | |
| message: `The property 'keys.byteLength' must be exactly 48 bytes. Received ${arg.byteLength}`, |
|
This pull request has been marked as stale due to 210 days of inactivity. |
assert is for invariants and prints a message about the condition being a bug in Node.js if false.
throw ERR_INVALID_ARG_VALUE for publicly facing validation.
this brings it into sync with the validation done in configSecureContext.