Socket
Socket
Sign inDemoInstall

mysql

Package Overview
Dependencies
10
Maintainers
4
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.17.1 to 2.18.0

lib/protocol/packets/LocalInfileRequestPacket.js

12

Changes.md

@@ -7,2 +7,14 @@ # Changes

## v2.18.0 (2020-01-21)
* Add `localInfile` option to control `LOAD DATA LOCAL INFILE`
* Add new Amazon RDS Root 2019 CA to Amazon RDS SSL profile #2280
* Add new error codes up to MySQL 5.7.29
* Fix early detection of bad callback to `connection.query`
* Support Node.js 12.x #2211
* Support Node.js 13.x
* Support non-enumerable properties in object argument to `connection.query` #2253
* Update `bignumber.js` to 9.0.0
* Update `readable-stream` to 2.3.7
## v2.17.1 (2019-04-18)

@@ -9,0 +21,0 @@

41

lib/Connection.js

@@ -30,36 +30,33 @@ var Crypto = require('crypto');

var cb = wrapCallbackInDomain(null, callback);
var cb = callback;
var options = {};
if (typeof sql === 'function') {
cb = wrapCallbackInDomain(null, sql);
return new Query(options, cb);
}
cb = sql;
} else if (typeof sql === 'object') {
options = Object.create(sql);
if (typeof sql === 'object') {
for (var prop in sql) {
options[prop] = sql[prop];
if (typeof values === 'function') {
cb = values;
} else if (values !== undefined) {
Object.defineProperty(options, 'values', { value: values });
}
} else {
options.sql = sql;
if (typeof values === 'function') {
cb = wrapCallbackInDomain(null, values);
cb = values;
} else if (values !== undefined) {
options.values = values;
}
return new Query(options, cb);
}
options.sql = sql;
options.values = values;
if (cb !== undefined) {
cb = wrapCallbackInDomain(null, cb);
if (typeof values === 'function') {
cb = wrapCallbackInDomain(null, values);
options.values = undefined;
if (cb === undefined) {
throw new TypeError('argument callback must be a function when provided');
}
}
if (cb === undefined && callback !== undefined) {
throw new TypeError('argument callback must be a function when provided');
}
return new Query(options, cb);

@@ -504,3 +501,7 @@ };

function wrapCallbackInDomain(ee, fn) {
if (typeof fn !== 'function' || fn.domain) {
if (typeof fn !== 'function') {
return undefined;
}
if (fn.domain) {
return fn;

@@ -507,0 +508,0 @@ }

@@ -36,2 +36,5 @@ var urlParse = require('url').parse;

: (options.ssl || false);
this.localInfile = (options.localInfile === undefined)
? true
: options.localInfile;
this.multipleStatements = options.multipleStatements || false;

@@ -118,2 +121,7 @@ this.typeCast = (options.typeCast === undefined)

if (options && options.localInfile !== undefined && !options.localInfile) {
// Disable LOCAL modifier for LOAD DATA INFILE
defaultFlags.push('-LOCAL_FILES');
}
if (options && options.multipleStatements) {

@@ -120,0 +128,0 @@ // May send multiple statements per COM_QUERY and COM_STMT_PREPARE

@@ -75,2 +75,39 @@ // Certificates for Amazon RDS

/**
* Amazon RDS global root CA 2019 to 2024
*
* CN = Amazon RDS Root 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-08-22T17:08:50Z/2024-08-22T17:08:50Z
* F = D4:0D:DB:29:E3:75:0D:FF:A6:71:C3:14:0B:BF:5F:47:8D:1C:80:96
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBjCCAu6gAwIBAgIJAMc0ZzaSUK51MA0GCSqGSIb3DQEBCwUAMIGPMQswCQYD\n'
+ 'VQQGEwJVUzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEi\n'
+ 'MCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1h\n'
+ 'em9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJEUyBSb290IDIwMTkgQ0EwHhcNMTkw\n'
+ 'ODIyMTcwODUwWhcNMjQwODIyMTcwODUwWjCBjzELMAkGA1UEBhMCVVMxEDAOBgNV\n'
+ 'BAcMB1NlYXR0bGUxEzARBgNVBAgMCldhc2hpbmd0b24xIjAgBgNVBAoMGUFtYXpv\n'
+ 'biBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMxIDAeBgNV\n'
+ 'BAMM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azon RDS ap-northeast-1 certificate CA 2015 to 2020

@@ -77,0 +114,0 @@ *

/**
* MySQL type constants
*
* Extracted from version 5.7.19
* Extracted from version 5.7.29
*

@@ -6,0 +6,0 @@ * !! Generated by generate-type-constants.js, do not modify by hand !!

@@ -5,3 +5,6 @@ module.exports = EmptyPacket;

EmptyPacket.prototype.parse = function parse() {
};
EmptyPacket.prototype.write = function write() {
};

@@ -16,2 +16,3 @@ exports.AuthSwitchRequestPacket = require('./AuthSwitchRequestPacket');

exports.LocalDataFilePacket = require('./LocalDataFilePacket');
exports.LocalInfileRequestPacket = require('./LocalInfileRequestPacket');
exports.OkPacket = require('./OkPacket');

@@ -18,0 +19,0 @@ exports.OldPasswordPacket = require('./OldPasswordPacket');

@@ -6,3 +6,2 @@ module.exports = ResultSetHeaderPacket;

this.fieldCount = options.fieldCount;
this.extra = options.extra;
}

@@ -12,8 +11,2 @@

this.fieldCount = parser.parseLengthCodedNumber();
if (parser.reachedPacketEnd()) return;
this.extra = (this.fieldCount === null)
? parser.parsePacketTerminatedString()
: parser.parseLengthCodedNumber();
};

@@ -23,6 +16,2 @@

writer.writeLengthCodedNumber(this.fieldCount);
if (this.extra !== undefined) {
writer.writeLengthCodedNumber(this.extra);
}
};

@@ -1,8 +0,9 @@

var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
var ResultSet = require('../ResultSet');
var ServerStatus = require('../constants/server_status');
var fs = require('fs');
var Readable = require('readable-stream');
var ClientConstants = require('../constants/client');
var fs = require('fs');
var Packets = require('../packets');
var ResultSet = require('../ResultSet');
var Sequence = require('./Sequence');
var ServerStatus = require('../constants/server_status');
var Readable = require('readable-stream');
var Util = require('util');

@@ -38,2 +39,3 @@ module.exports = Query;

case 0x00: return Packets.OkPacket;
case 0xfb: return Packets.LocalInfileRequestPacket;
case 0xff: return Packets.ErrorPacket;

@@ -94,10 +96,18 @@ default: return Packets.ResultSetHeaderPacket;

Query.prototype['ResultSetHeaderPacket'] = function(packet) {
if (packet.fieldCount === null) {
this._sendLocalDataFile(packet.extra);
Query.prototype['LocalInfileRequestPacket'] = function(packet) {
if (this._connection.config.clientFlags & ClientConstants.CLIENT_LOCAL_FILES) {
this._sendLocalDataFile(packet.filename);
} else {
this._resultSet = new ResultSet(packet);
this._loadError = new Error('Load local files command is disabled');
this._loadError.code = 'LOCAL_FILES_DISABLED';
this._loadError.fatal = false;
this.emit('packet', new Packets.EmptyPacket());
}
};
Query.prototype['ResultSetHeaderPacket'] = function(packet) {
this._resultSet = new ResultSet(packet);
};
Query.prototype['FieldPacket'] = function(packet) {

@@ -104,0 +114,0 @@ this._resultSet.fieldPackets.push(packet);

{
"name": "mysql",
"description": "A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.",
"version": "2.17.1",
"version": "2.18.0",
"license": "MIT",

@@ -16,4 +16,4 @@ "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",

"dependencies": {
"bignumber.js": "7.2.1",
"readable-stream": "2.3.6",
"bignumber.js": "9.0.0",
"readable-stream": "2.3.7",
"safe-buffer": "5.1.2",

@@ -24,4 +24,4 @@ "sqlstring": "2.3.1"

"after": "0.8.2",
"eslint": "5.15.1",
"seedrandom": "3.0.1",
"eslint": "5.16.0",
"seedrandom": "3.0.5",
"timezone-mock": "0.0.7",

@@ -42,3 +42,3 @@ "urun": "0.0.8",

"scripts": {
"lint": "eslint .",
"lint": "eslint . && node tool/lint-readme.js",
"test": "node test/run.js",

@@ -45,0 +45,0 @@ "test-ci": "node tool/install-nyc.js --nyc-optional --reporter=text -- npm test",

@@ -19,3 +19,4 @@ # mysql

- [Connection options](#connection-options)
- [SSL options](#ssl-options)
- [SSL options](#ssl-options)
- [Connection flags](#connection-flags)
- [Terminating connections](#terminating-connections)

@@ -25,5 +26,9 @@ - [Pooling connections](#pooling-connections)

- [Pool events](#pool-events)
- [acquire](#acquire)
- [connection](#connection)
- [enqueue](#enqueue)
- [release](#release)
- [Closing all the connections in a pool](#closing-all-the-connections-in-a-pool)
- [PoolCluster](#poolcluster)
- [PoolCluster options](#poolcluster-options)
- [PoolCluster options](#poolcluster-options)
- [Switching users and altering connection state](#switching-users-and-altering-connection-state)

@@ -34,4 +39,4 @@ - [Server disconnects](#server-disconnects)

- [Escaping query identifiers](#escaping-query-identifiers)
- [Preparing Queries](#preparing-queries)
- [Custom format](#custom-format)
- [Preparing Queries](#preparing-queries)
- [Custom format](#custom-format)
- [Getting the id of an inserted row](#getting-the-id-of-an-inserted-row)

@@ -43,3 +48,3 @@ - [Getting the number of affected rows](#getting-the-number-of-affected-rows)

- [Streaming query rows](#streaming-query-rows)
- [Piping results with Streams](#piping-results-with-streams)
- [Piping results with Streams](#piping-results-with-streams)
- [Multiple statement queries](#multiple-statement-queries)

@@ -54,3 +59,7 @@ - [Stored procedures](#stored-procedures)

- [Type casting](#type-casting)
- [Connection Flags](#connection-flags)
- [Number](#number)
- [Date](#date)
- [Buffer](#buffer)
- [String](#string)
- [Custom type casting](#custom-type-casting)
- [Debugging and reporting problems](#debugging-and-reporting-problems)

@@ -60,2 +69,4 @@ - [Security issues](#security-issues)

- [Running tests](#running-tests)
- [Running unit tests](#running-unit-tests)
- [Running integration tests](#running-integration-tests)
- [Todo](#todo)

@@ -238,2 +249,3 @@

(Default: `true`)
* `localInfile`: Allow `LOAD DATA INFILE` to use the `LOCAL` modifier. (Default: `true`)
* `multipleStatements`: Allow multiple mysql statements per query. Be careful

@@ -294,2 +306,59 @@ with this, it could increase the scope of SQL injection attacks. (Default: `false`)

### Connection flags
If, for any reason, you would like to change the default connection flags, you
can use the connection option `flags`. Pass a string with a comma separated list
of items to add to the default flags. If you don't want a default flag to be used
prepend the flag with a minus sign. To add a flag that is not in the default list,
just write the flag name, or prefix it with a plus (case insensitive).
```js
var connection = mysql.createConnection({
// disable FOUND_ROWS flag, enable IGNORE_SPACE flag
flags: '-FOUND_ROWS,IGNORE_SPACE'
});
```
The following flags are available:
- `COMPRESS` - Enable protocol compression. This feature is not currently supported
by the Node.js implementation so cannot be turned on. (Default off)
- `CONNECT_WITH_DB` - Ability to specify the database on connection. (Default on)
- `FOUND_ROWS` - Send the found rows instead of the affected rows as `affectedRows`.
(Default on)
- `IGNORE_SIGPIPE` - Don't issue SIGPIPE if network failures. This flag has no effect
on this Node.js implementation. (Default on)
- `IGNORE_SPACE` - Let the parser ignore spaces before the `(` in queries. (Default on)
- `INTERACTIVE` - Indicates to the MySQL server this is an "interactive" client. This
will use the interactive timeouts on the MySQL server and report as interactive in
the process list. (Default off)
- `LOCAL_FILES` - Can use `LOAD DATA LOCAL`. This flag is controlled by the connection
option `localInfile`. (Default on)
- `LONG_FLAG` - Longer flags in Protocol::ColumnDefinition320. (Default on)
- `LONG_PASSWORD` - Use the improved version of Old Password Authentication.
(Default on)
- `MULTI_RESULTS` - Can handle multiple resultsets for queries. (Default on)
- `MULTI_STATEMENTS` - The client may send multiple statement per query or
statement prepare (separated by `;`). This flag is controlled by the connection
option `multipleStatements`. (Default off)
- `NO_SCHEMA`
- `ODBC` Special handling of ODBC behaviour. This flag has no effect on this Node.js
implementation. (Default on)
- `PLUGIN_AUTH` - Uses the plugin authentication mechanism when connecting to the
MySQL server. This feature is not currently supported by the Node.js implementation
so cannot be turned on. (Default off)
- `PROTOCOL_41` - Uses the 4.1 protocol. (Default on)
- `PS_MULTI_RESULTS` - Can handle multiple resultsets for execute. (Default on)
- `REMEMBER_OPTIONS` - This is specific to the C client, and has no effect on this
Node.js implementation. (Default off)
- `RESERVED` - Old flag for the 4.1 protocol. (Default on)
- `SECURE_CONNECTION` - Support native 4.1 authentication. (Default on)
- `SSL` - Use SSL after handshake to encrypt data in transport. This feature is
controlled though the `ssl` connection option, so the flag has no effect.
(Default off)
- `SSL_VERIFY_SERVER_CERT` - Verify the server certificate during SSL set up. This
feature is controlled though the `ssl.rejectUnauthorized` connection option, so
the flag has no effect. (Default off)
- `TRANSACTIONS` - Asks for the transaction status flags. (Default on)
## Terminating connections

@@ -592,2 +661,9 @@

With PoolCluster, disconnected connections will count as errors against the
related node, incrementing the error code for that node. Once there are more than
`removeNodeErrorCount` errors on a given node, it is removed from the cluster.
When this occurs, the PoolCluster may emit a `POOL_NONEONLINE` error if there are
no longer any matching nodes for the pattern. The `restoreNodeTimeout` config can
be set to restore offline nodes after a given timeout.
## Performing queries

@@ -1341,3 +1417,3 @@

The `next` argument is a `function` that, when called, will return the default
type conversaion for the given field.
type conversion for the given field.

@@ -1374,59 +1450,2 @@ When getting the field data, the following helper methods are present on the

## Connection Flags
If, for any reason, you would like to change the default connection flags, you
can use the connection option `flags`. Pass a string with a comma separated list
of items to add to the default flags. If you don't want a default flag to be used
prepend the flag with a minus sign. To add a flag that is not in the default list,
just write the flag name, or prefix it with a plus (case insensitive).
**Please note that some available flags that are not supported (e.g.: Compression),
are still not allowed to be specified.**
### Example
The next example blacklists FOUND_ROWS flag from default connection flags.
```js
var connection = mysql.createConnection("mysql://localhost/test?flags=-FOUND_ROWS");
```
### Default Flags
The following flags are sent by default on a new connection:
- `CONNECT_WITH_DB` - Ability to specify the database on connection.
- `FOUND_ROWS` - Send the found rows instead of the affected rows as `affectedRows`.
- `IGNORE_SIGPIPE` - Old; no effect.
- `IGNORE_SPACE` - Let the parser ignore spaces before the `(` in queries.
- `LOCAL_FILES` - Can use `LOAD DATA LOCAL`.
- `LONG_FLAG`
- `LONG_PASSWORD` - Use the improved version of Old Password Authentication.
- `MULTI_RESULTS` - Can handle multiple resultsets for COM_QUERY.
- `ODBC` Old; no effect.
- `PROTOCOL_41` - Uses the 4.1 protocol.
- `PS_MULTI_RESULTS` - Can handle multiple resultsets for COM_STMT_EXECUTE.
- `RESERVED` - Old flag for the 4.1 protocol.
- `SECURE_CONNECTION` - Support native 4.1 authentication.
- `TRANSACTIONS` - Asks for the transaction status flags.
In addition, the following flag will be sent if the option `multipleStatements`
is set to `true`:
- `MULTI_STATEMENTS` - The client may send multiple statement per query or
statement prepare.
### Other Available Flags
There are other flags available. They may or may not function, but are still
available to specify.
- `COMPRESS`
- `INTERACTIVE`
- `NO_SCHEMA`
- `PLUGIN_AUTH`
- `REMEMBER_OPTIONS`
- `SSL`
- `SSL_VERIFY_SERVER_CERT`
## Debugging and reporting problems

@@ -1433,0 +1452,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc