-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
eslint: enable recommended ruleset #3263
base: master
Are you sure you want to change the base?
Changes from all commits
6b088df
b3e4e16
0fa5cd8
f3d4eca
e1b9fe6
0f657ab
08fe7f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
{ | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"parser": "@typescript-eslint/parser", | ||
"extends": ["plugin:prettier/recommended", "prettier"], | ||
"extends": ["eslint:recommended", "plugin:prettier/recommended", "prettier"], | ||
"ignorePatterns": ["node_modules", "coverage", "packages/pg-protocol/dist/**/*", "packages/pg-query-stream/dist/**/*"], | ||
"parserOptions": { | ||
"ecmaVersion": 2017, | ||
"sourceType": "module" | ||
}, | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"es2020": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": ["error", { | ||
"args": "none" | ||
}], | ||
"no-unused-vars": "off" | ||
} | ||
"no-unused-vars": "off", | ||
"no-unreachable": "error" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.mts", "*.cts", "*.tsx"], | ||
"rules": { | ||
"no-undef": "off" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,11 @@ const exec = async (client, q) => { | |
const bench = async (client, q, time) => { | ||
let start = Date.now() | ||
let count = 0 | ||
while (true) { | ||
do { | ||
await exec(client, q) | ||
count++ | ||
if (Date.now() - start > time) { | ||
return count | ||
} | ||
} | ||
} while (Date.now() - start > time) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here has been inverted. |
||
return count | ||
} | ||
|
||
const run = async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
function x509Error(msg, cert) { | ||
throw new Error('SASL channel binding: ' + msg + ' when parsing public certificate ' + cert.toString('base64')) | ||
return new Error('SASL channel binding: ' + msg + ' when parsing public certificate ' + cert.toString('base64')) | ||
} | ||
|
||
function readASN1Length(data, index) { | ||
let length = data[index++] | ||
if (length < 0x80) return { length, index } | ||
|
||
const lengthBytes = length & 0x7f | ||
if (lengthBytes > 4) x509Error('bad length', data) | ||
if (lengthBytes > 4) throw x509Error('bad length', data) | ||
|
||
length = 0 | ||
for (let i = 0; i < lengthBytes; i++) { | ||
|
@@ -18,11 +18,11 @@ function readASN1Length(data, index) { | |
} | ||
|
||
function readASN1OID(data, index) { | ||
if (data[index++] !== 0x6) x509Error('non-OID data', data) // 6 = OID | ||
if (data[index++] !== 0x6) throw x509Error('non-OID data', data) // 6 = OID | ||
|
||
const { length: OIDLength, index: indexAfterOIDLength } = readASN1Length(data, index) | ||
index = indexAfterOIDLength | ||
lastIndex = index + OIDLength | ||
let lastIndex = index + OIDLength | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes! Good catch. |
||
|
||
const byte1 = data[index++] | ||
let oid = ((byte1 / 40) >> 0) + '.' + (byte1 % 40) | ||
|
@@ -43,7 +43,7 @@ function readASN1OID(data, index) { | |
} | ||
|
||
function expectASN1Seq(data, index) { | ||
if (data[index++] !== 0x30) x509Error('non-sequence data', data) // 30 = Sequence | ||
if (data[index++] !== 0x30) throw x509Error('non-sequence data', data) // 30 = Sequence | ||
return readASN1Length(data, index) | ||
} | ||
|
||
|
@@ -85,10 +85,10 @@ function signatureAlgorithmHashFromCertificate(data, index) { | |
case '1.2.840.10045.4.3.4': | ||
return 'SHA-512' | ||
// RSASSA-PSS: hash is indicated separately | ||
case '1.2.840.113549.1.1.10': | ||
case '1.2.840.113549.1.1.10': { | ||
index = indexAfterOID | ||
index = expectASN1Seq(data, index).index | ||
if (data[index++] !== 0xa0) x509Error('non-tag data', data) // a0 = constructed tag 0 | ||
if (data[index++] !== 0xa0) throw x509Error('non-tag data', data) // a0 = constructed tag 0 | ||
index = readASN1Length(data, index).index // skip over tag length field | ||
index = expectASN1Seq(data, index).index // skip over sequence length field | ||
const { oid: hashOID } = readASN1OID(data, index) | ||
|
@@ -105,17 +105,18 @@ function signatureAlgorithmHashFromCertificate(data, index) { | |
case '2.16.840.1.101.3.4.2.3': | ||
return 'SHA-512' | ||
} | ||
x509Error('unknown hash OID ' + hashOID, data) | ||
throw x509Error('unknown hash OID ' + hashOID, data) | ||
} | ||
// Ed25519 -- see https: return//github.com/openssl/openssl/issues/15477 | ||
case '1.3.101.110': | ||
case '1.3.101.112': // ph | ||
return 'SHA-512' | ||
// Ed448 -- still not in pg 17.2 (if supported, digest would be SHAKE256 x 64 bytes) | ||
case '1.3.101.111': | ||
case '1.3.101.113': // ph | ||
x509Error('Ed448 certificate channel binding is not currently supported by Postgres') | ||
throw x509Error('Ed448 certificate channel binding is not currently supported by Postgres') | ||
} | ||
x509Error('unknown OID ' + oid, data) | ||
throw x509Error('unknown OID ' + oid, data) | ||
} | ||
|
||
module.exports = { signatureAlgorithmHashFromCertificate } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ suite.test('sasl/scram', function () { | |
0x0d, // signature algorithm length | ||
0x06, // ASN.1 OID | ||
0x09, // OID length | ||
0x2a, // OID: 1.2.840.113549.1.1.11 (RSASSA-PKCS1-v1_5 / SHA-256) | ||
0x2a, // OID: 1.2.840.113549.1.1.11 (RSASSA-PKCS1-v1_5 / SHA-256) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (note for other readers: the difference is a zero-width space after “SHA-256”) |
||
0x86, | ||
0x48, | ||
0x86, | ||
|
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 haven’t really looked at this, but there’s probably more to do here than quietly deleting a line. Does none of this code run at all, then?