vertica / vertica-nodejs

Official native node.js client for the Vertica Analytics Database.
https://www.vertica.com/
Apache License 2.0
12 stars 14 forks source link

Password default change to empty string #134

Closed sitingren closed 6 months ago

sitingren commented 6 months ago

Cannot connect to a user with '' as sha512 password. E.g. a dbadmin with following setting

CREATE AUTHENTICATION v_dbadmin_hash METHOD 'hash' HOST '0.0.0.0/0';
ALTER AUTHENTICATION v_dbadmin_hash PRIORITY 10000;
GRANT AUTHENTICATION v_dbadmin_hash TO dbadmin;

The client will overwrite password '' to null and return an error message

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received null
    at new NodeError (node:internal/errors:371:5)
    at Function.from (node:buffer:322:9)
    at Object.postgresSha512PasswordHash (/home/sren/node_modules/vertica-nodejs/lib/utils.js:198:44)
    at /home/sren/node_modules/vertica-nodejs/lib/client.js:365:36
    at /home/sren/node_modules/vertica-nodejs/lib/client.js:318:9
    at /home/sren/node_modules/pgpass/lib/index.js:14:20
    at FSReqCallback.oncomplete (node:fs:198:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Nodejs driver uses null as password default value. Other vertica drivers use empty string as password default value, it's better to change nodejs driver's default and solve above bug as well.