Merge pull request #538 from CartoDB/use-strict

Use strict mode
This commit is contained in:
Daniel G. Aubert 2018-10-26 13:48:52 +02:00 committed by GitHub
commit 91cd355c63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 392 additions and 171 deletions

View File

@ -3,6 +3,8 @@
## 2.2.2
Released 2018-mm-dd
Bug fixes:
* Make all modules to use strict mode semantics.
## 2.2.1

2
app.js
View File

@ -1,5 +1,7 @@
#!/usr/bin/env node
'use strict';
/*
* SQL API loader
* ===============

View File

@ -1,3 +1,5 @@
'use strict';
/**
* this module allows to auth user using an pregenerated api key
*/
@ -32,7 +34,7 @@ ApikeyAuth.prototype.verifyCredentials = function (callback) {
return callback(usernameError);
}
if (!apikey.grantsSql) {
const forbiddenError = new Error('forbidden');
forbiddenError.http_status = 403;
@ -47,8 +49,8 @@ ApikeyAuth.prototype.verifyCredentials = function (callback) {
apiKeyNotFoundError.subtype = 'api-key-not-found';
apiKeyNotFoundError.http_status = 401;
return callback(apiKeyNotFoundError);
}
return callback(apiKeyNotFoundError);
}
});
};

View File

@ -1,3 +1,5 @@
'use strict';
var ApiKeyAuth = require('./apikey'),
OAuthAuth = require('./oauth');

View File

@ -1,3 +1,5 @@
'use strict';
// too bound to the request object, but ok for now
var _ = require('underscore');
var OAuthUtil = require('oauth-client');

View File

@ -1,3 +1,5 @@
'use strict';
const util = require('util');
const bodyParserMiddleware = require('../middlewares/body-parser');
@ -30,25 +32,25 @@ JobController.prototype.route = function (app) {
);
app.get(
`${base_url}/jobs-wip`,
`${base_url}/jobs-wip`,
bodyParserMiddleware(),
listWorkInProgressJobs(this.jobService),
sendResponse(),
listWorkInProgressJobs(this.jobService),
sendResponse(),
errorMiddleware()
);
app.post(
`${base_url}/sql/job`,
`${base_url}/sql/job`,
bodyParserMiddleware(),
checkBodyPayloadSize(),
checkBodyPayloadSize(),
jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE)
);
app.get(
`${base_url}/sql/job/:job_id`,
`${base_url}/sql/job/:job_id`,
bodyParserMiddleware(),
jobMiddlewares('retrieve', getJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_GET)
);
app.delete(
`${base_url}/sql/job/:job_id`,
`${base_url}/sql/job/:job_id`,
bodyParserMiddleware(),
jobMiddlewares('cancel', cancelJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_DELETE)
);

View File

@ -1,3 +1,5 @@
'use strict';
const AuthApi = require('../auth/auth_api');
const basicAuth = require('basic-auth');

View File

@ -1,3 +1,4 @@
'use strict';
/*!
* Connect - bodyParser

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function connectionParams (userDatabaseService) {
return function connectionParamsMiddleware (req, res, next) {
const { user, api_key: apikeyToken, authorizationLevel } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
const PSQL = require('cartodb-psql');
const remainingQuotaQuery = 'SELECT _CDB_UserQuotaInBytes() - CDB_UserDataSize(current_schema()) AS remaining_quota';

View File

@ -1,3 +1,5 @@
'use strict';
const errorHandlerFactory = require('../services/error_handler_factory');
module.exports = function error() {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports.initializeProfilerMiddleware = function initializeProfiler (label) {
return function initializeProfilerMiddleware (req, res, next) {
if (req.profiler) {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function timeoutLimits (metadataBackend) {
return function timeoutLimitsMiddleware (req, res, next) {
const { user, authorizationLevel } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
const CdbRequest = require('../models/cartodb_request');
module.exports = function user(metadataBackend) {

View File

@ -1,3 +1,4 @@
'use strict';
function ArrayBufferSer(type, data, options) {
if(type === undefined) {
@ -83,7 +84,7 @@ ArrayBufferSer.prototype = {
s = 0;
if(this.type === ArrayBufferSer.STRING) {
// calculate size with padding
t.forEach(function(arr) {
t.forEach(function(arr) {
var pad = self._paddingFor(offset, ArrayBufferSer.MAX_PADDING);
s += pad;
offset += pad;

View File

@ -1,3 +1,5 @@
'use strict';
/**
* this module provides cartodb-specific interpretation
* of request headers

View File

@ -1,3 +1,5 @@
'use strict';
var fs = require("fs");
var formats = {};

View File

@ -1,3 +1,5 @@
'use strict';
var crypto = require('crypto');
var step = require('step');
var fs = require('fs');

View File

@ -1,3 +1,5 @@
'use strict';
var ogr = require('./../ogr');
function CsvFormat() {}

View File

@ -1,3 +1,5 @@
'use strict';
var ogr = require('./../ogr');
function GeoPackageFormat() {}

View File

@ -1,3 +1,5 @@
'use strict';
var ogr = require('./../ogr');
function KmlFormat() {}

View File

@ -1,3 +1,5 @@
'use strict';
var step = require('step');
var fs = require('fs');
var spawn = require('child_process').spawn;
@ -46,7 +48,7 @@ ShpFormat.prototype.toSHP = function (options, callback) {
step (
function createOutDir() {
fs.mkdir(outdirpath, 0777, this);
fs.mkdir(outdirpath, 0o777, this);
},
function spawnDumper(err) {
assert.ifError(err);

View File

@ -1,3 +1,5 @@
'use strict';
var ogr = require('./../ogr');
function SpatiaLiteFormat() {}

View File

@ -1,3 +1,5 @@
'use strict';
var step = require('step');
var PSQL = require('cartodb-psql');
var assert = require('assert');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var pg = require('./../pg');
@ -22,7 +24,7 @@ BinaryFormat.prototype.transform = function(result, options, callback) {
var total_rows = result.rowCount;
var rows = result.rows;
// get headers
// get headers
if(!total_rows) {
callback(null, new Buffer(0));
return;
@ -62,7 +64,7 @@ BinaryFormat.prototype.transform = function(result, options, callback) {
var d = [];
var n = headersNames[i];
for(var r = 0; r < total_rows; ++r) {
var row = rows[r][n];
var row = rows[r][n];
if(headerTypes[i] > ArrayBufferSer.BUFFER) {
row = new ArrayBufferSer(headerTypes[i] - ArrayBufferSer.BUFFER, row);
}

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var pg = require('./../pg');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var pg = require('./../pg');

View File

@ -1,3 +1,5 @@
'use strict';
var pg = require('./../pg');
var svg_width = 1024.0;

View File

@ -1,3 +1,5 @@
'use strict';
var pg = require('./../pg');
var _ = require('underscore');
var geojson = require('./geojson');

View File

@ -1,3 +1,5 @@
'use strict';
var step = require('step'),
fs = require('fs');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
// reference http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html

View File

@ -1,3 +1,5 @@
'use strict';
// CartoDB SQL API
//
// all requests expect the following URL args:

View File

@ -1,3 +1,5 @@
'use strict';
var QueryTables = require('cartodb-query-tables');
var generateMD5 = require('../utils/md5');

View File

@ -1,3 +1,5 @@
'use strict';
class ErrorHandler extends Error {
constructor({ message, context, detail, hint, http_status, name }) {
super(message);

View File

@ -1,3 +1,5 @@
'use strict';
const ErrorHandler = require('./error_handler');
const { codeToCondition } = require('../postgresql/error_codes');

View File

@ -1,3 +1,5 @@
'use strict';
const FORBIDDEN_ENTITIES = {
carto: ['*'],
cartodb: [
@ -56,6 +58,6 @@ const Validator = {
return true;
}
};
};
module.exports = Validator;

View File

@ -1,3 +1,5 @@
'use strict';
const PSQL = require('cartodb-psql');
const copyTo = require('pg-copy-streams').to;
const copyFrom = require('pg-copy-streams').from;

View File

@ -1,3 +1,5 @@
'use strict';
const { getFormatFromCopyQuery } = require('../utils/query_info');
module.exports = class StreamCopyMetrics {

View File

@ -1,3 +1,5 @@
'use strict';
function isApiKeyFound(apikey) {
return apikey.type !== null &&
apikey.user !== null &&
@ -43,7 +45,7 @@ UserDatabaseService.prototype.getConnectionParams = function (username, apikeyTo
};
this.metadataBackend.getMasterApikey(username, (err, masterApikey) => {
if (err) {
err.http_status = 404;
err.message = errorUserNotFoundMessageTemplate(username);

View File

@ -1,7 +1,9 @@
'use strict';
/**
* UserLimits
* @param {cartodb-redis} metadataBackend
* @param {object} options
* @param {cartodb-redis} metadataBackend
* @param {object} options
*/
class UserLimits {
constructor(metadataBackend, options = {}) {

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var debug = require('debug')('windshaft:stats_client');
var StatsD = require('node-statsd').StatsD;
@ -70,4 +72,4 @@ module.exports = {
return this.instance;
}
};
};

View File

@ -1,3 +1,5 @@
'use strict';
var Profiler = require('step-profiler');
/**

View File

@ -1,3 +1,5 @@
'use strict';
const COPY_FORMATS = ['TEXT', 'CSV', 'BINARY'];
module.exports = {
@ -9,11 +11,11 @@ module.exports = {
if (!copyQuery.startsWith("COPY ")) {
return false;
}
if(copyQuery.includes(' WITH') && copyQuery.includes('FORMAT ')) {
const regex = /\bFORMAT\s+(\w+)/;
const result = regex.exec(copyQuery);
if (result && result.length === 2) {
if (COPY_FORMATS.includes(result[1])) {
format = result[1];

View File

@ -1,4 +1,4 @@
'use strict';
function ArrayBufferSer(arrayBuffer) {
this.buffer = arrayBuffer;

150
npm-shrinkwrap.json generated
View File

@ -1,6 +1,6 @@
{
"name": "cartodb_sql_api",
"version": "2.2.1",
"version": "2.2.2",
"dependencies": {
"@carto/fqdn-sync": {
"version": "0.2.2",
@ -33,9 +33,9 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz"
},
"asn1": {
"version": "0.2.3",
"version": "0.2.4",
"from": "asn1@>=0.2.3 <0.3.0",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz"
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz"
},
"assert-plus": {
"version": "0.2.0",
@ -58,9 +58,9 @@
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz"
},
"aws4": {
"version": "1.7.0",
"version": "1.8.0",
"from": "aws4@>=1.2.1 <2.0.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz"
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz"
},
"balanced-match": {
"version": "1.0.0",
@ -68,15 +68,14 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz"
},
"basic-auth": {
"version": "2.0.0",
"version": "2.0.1",
"from": "basic-auth@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz"
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz"
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"version": "1.0.2",
"from": "bcrypt-pbkdf@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
"optional": true
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz"
},
"bindings": {
"version": "1.3.0",
@ -111,9 +110,9 @@
}
},
"bluebird": {
"version": "3.5.1",
"version": "3.5.2",
"from": "bluebird@>=3.3.3 <4.0.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz"
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz"
},
"boom": {
"version": "2.10.1",
@ -126,9 +125,9 @@
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz"
},
"buffer-from": {
"version": "1.1.0",
"version": "1.1.1",
"from": "buffer-from@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz"
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz"
},
"buffer-writer": {
"version": "1.0.1",
@ -168,9 +167,9 @@
"resolved": "https://registry.npmjs.org/cartodb-psql/-/cartodb-psql-0.12.0.tgz",
"dependencies": {
"debug": {
"version": "3.1.0",
"version": "3.2.6",
"from": "debug@>=3.1.0 <4.0.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz"
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz"
}
}
},
@ -180,9 +179,9 @@
"resolved": "https://registry.npmjs.org/cartodb-query-tables/-/cartodb-query-tables-0.2.0.tgz"
},
"cartodb-redis": {
"version": "2.0.1",
"from": "cartodb-redis@2.0.1",
"resolved": "https://registry.npmjs.org/cartodb-redis/-/cartodb-redis-2.0.1.tgz"
"version": "2.0.2",
"from": "cartodb-redis@2.0.2",
"resolved": "https://registry.npmjs.org/cartodb-redis/-/cartodb-redis-2.0.2.tgz"
},
"caseless": {
"version": "0.11.0",
@ -205,14 +204,14 @@
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz"
},
"combined-stream": {
"version": "1.0.6",
"version": "1.0.7",
"from": "combined-stream@>=1.0.5 <1.1.0",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz"
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz"
},
"commander": {
"version": "2.15.1",
"version": "2.19.0",
"from": "commander@>=2.9.0 <3.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz"
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz"
},
"concat-map": {
"version": "0.0.1",
@ -344,10 +343,9 @@
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"version": "0.1.2",
"from": "ecc-jsbn@>=0.1.1 <0.2.0",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
"optional": true
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz"
},
"ee-first": {
"version": "1.1.1",
@ -355,9 +353,9 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz"
},
"error-ex": {
"version": "1.3.1",
"version": "1.3.2",
"from": "error-ex@>=1.2.0 <2.0.0",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz"
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz"
},
"escape-html": {
"version": "1.0.3",
@ -387,9 +385,9 @@
}
},
"extend": {
"version": "3.0.1",
"version": "3.0.2",
"from": "extend@>=3.0.0 <3.1.0",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz"
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz"
},
"extsprintf": {
"version": "1.3.0",
@ -427,9 +425,9 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz"
},
"generate-function": {
"version": "2.0.0",
"version": "2.3.1",
"from": "generate-function@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz"
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz"
},
"generate-object-property": {
"version": "1.2.0",
@ -442,9 +440,9 @@
"resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-2.4.3.tgz"
},
"get-caller-file": {
"version": "1.0.2",
"version": "1.0.3",
"from": "get-caller-file@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz"
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz"
},
"getpass": {
"version": "0.1.7",
@ -495,9 +493,9 @@
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz"
},
"hosted-git-info": {
"version": "2.6.0",
"version": "2.7.1",
"from": "hosted-git-info@>=2.1.4 <3.0.0",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz"
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz"
},
"http-errors": {
"version": "1.3.1",
@ -550,13 +548,13 @@
"resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz"
},
"is-my-json-valid": {
"version": "2.17.2",
"version": "2.19.0",
"from": "is-my-json-valid@>=2.12.4 <3.0.0",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz"
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.19.0.tgz"
},
"is-property": {
"version": "1.0.2",
"from": "is-property@>=1.0.0 <2.0.0",
"from": "is-property@>=1.0.2 <2.0.0",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz"
},
"is-typedarray": {
@ -587,8 +585,7 @@
"jsbn": {
"version": "0.1.1",
"from": "jsbn@>=0.1.0 <0.2.0",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"optional": true
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz"
},
"json-schema": {
"version": "0.2.3",
@ -675,14 +672,14 @@
"resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz"
},
"mime-db": {
"version": "1.33.0",
"from": "mime-db@>=1.33.0 <1.34.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz"
"version": "1.37.0",
"from": "mime-db@>=1.37.0 <1.38.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz"
},
"mime-types": {
"version": "2.1.18",
"version": "2.1.21",
"from": "mime-types@>=2.1.6 <2.2.0",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz"
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz"
},
"minimatch": {
"version": "3.0.4",
@ -696,7 +693,7 @@
},
"mkdirp": {
"version": "0.5.1",
"from": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"from": "mkdirp@0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz"
},
"moment": {
@ -706,9 +703,9 @@
"optional": true
},
"ms": {
"version": "2.0.0",
"from": "ms@2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz"
"version": "2.1.1",
"from": "ms@>=2.1.1 <3.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz"
},
"multer": {
"version": "1.2.1",
@ -729,9 +726,9 @@
"optional": true
},
"nan": {
"version": "2.10.0",
"from": "nan@>=2.3.4 <3.0.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz"
"version": "2.11.1",
"from": "nan@>=2.0.8 <3.0.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz"
},
"ncp": {
"version": "2.0.0",
@ -852,9 +849,9 @@
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz"
},
"pg-copy-streams": {
"version": "1.2.0",
"from": "cartodb/node-pg-copy-streams#v1.2.0-carto.1",
"resolved": "git://github.com/cartodb/node-pg-copy-streams.git#d7e5c1383ff9b43890f2c37bc38cfed1afc2523f"
"version": "1.2.0-carto.2",
"from": "cartodb/node-pg-copy-streams#v1.2.0-carto.2",
"resolved": "git://github.com/cartodb/node-pg-copy-streams.git#6f1d5cb4a54be07cf2ca076563142737e44eaf5c"
},
"pg-int8": {
"version": "1.0.1",
@ -892,9 +889,9 @@
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz"
},
"postgres-array": {
"version": "1.0.2",
"version": "1.0.3",
"from": "postgres-array@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.2.tgz"
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.3.tgz"
},
"postgres-bytea": {
"version": "1.0.0",
@ -907,9 +904,9 @@
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.3.tgz"
},
"postgres-interval": {
"version": "1.1.1",
"version": "1.1.2",
"from": "postgres-interval@>=1.1.0 <2.0.0",
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.1.tgz"
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.2.tgz"
},
"process-nextick-args": {
"version": "2.0.0",
@ -962,9 +959,9 @@
"resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz"
},
"redis-commands": {
"version": "1.3.5",
"version": "1.4.0",
"from": "redis-commands@>=1.2.0 <2.0.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.5.tgz"
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz"
},
"redis-mpool": {
"version": "0.5.0",
@ -1010,9 +1007,9 @@
"optional": true
},
"safe-buffer": {
"version": "5.1.1",
"from": "safe-buffer@5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz"
"version": "5.1.2",
"from": "safe-buffer@5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz"
},
"safe-json-stringify": {
"version": "1.2.0",
@ -1070,14 +1067,14 @@
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz"
},
"spdx-correct": {
"version": "3.0.0",
"version": "3.0.2",
"from": "spdx-correct@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz"
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.2.tgz"
},
"spdx-exceptions": {
"version": "2.1.0",
"version": "2.2.0",
"from": "spdx-exceptions@>=2.1.0 <3.0.0",
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz"
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz"
},
"spdx-expression-parse": {
"version": "3.0.0",
@ -1085,9 +1082,9 @@
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz"
},
"spdx-license-ids": {
"version": "3.0.0",
"version": "3.0.1",
"from": "spdx-license-ids@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz"
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.1.tgz"
},
"split": {
"version": "1.0.1",
@ -1095,9 +1092,9 @@
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz"
},
"sshpk": {
"version": "1.14.2",
"version": "1.15.1",
"from": "sshpk@>=1.7.0 <2.0.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz",
"dependencies": {
"assert-plus": {
"version": "1.0.0",
@ -1179,8 +1176,7 @@
"tweetnacl": {
"version": "0.14.5",
"from": "tweetnacl@>=0.14.0 <0.15.0",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"optional": true
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz"
},
"type-is": {
"version": "1.6.16",
@ -1213,9 +1209,9 @@
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz"
},
"validate-npm-package-license": {
"version": "3.0.3",
"version": "3.0.4",
"from": "validate-npm-package-license@>=3.0.1 <4.0.0",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz"
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz"
},
"vary": {
"version": "1.0.1",

View File

@ -23,7 +23,7 @@
"bunyan": "1.8.1",
"cartodb-psql": "0.12.0",
"cartodb-query-tables": "0.2.0",
"cartodb-redis": "2.0.1",
"cartodb-redis": "2.0.2",
"debug": "2.2.0",
"express": "~4.13.3",
"log4js": "cartodb/log4js-node#cdb",
@ -33,7 +33,7 @@
"node-statsd": "~0.0.7",
"node-uuid": "^1.4.7",
"oauth-client": "0.3.0",
"pg-copy-streams": "cartodb/node-pg-copy-streams#v1.2.0-carto.1",
"pg-copy-streams": "github:cartodb/node-pg-copy-streams#v1.2.0-carto.2",
"qs": "~6.2.1",
"queue-async": "~1.0.7",
"redis-mpool": "0.5.0",

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* Requires the database and tables setup in config/environments/test.js to exist

View File

@ -1,3 +1,5 @@
'use strict';
const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const BatchTestClient = require('../support/batch-test-client');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var assert = require('../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');
var redisUtils = require('../../support/redis_utils');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* Requires the database and tables setup in config/environments/test.js to exist

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* Requires the database and tables setup in config/environments/test.js to exist

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var BatchTestClient = require('../../support/batch-test-client');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var assert = require('../../support/assert');

View File

@ -1,4 +1,4 @@
'use const';
'use strict';
var server = require('../../app/server')();
const assert = require('../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
const querystring = require('querystring');
const StatsClient = require('../../app/stats/client');
const statsClient = StatsClient.getInstance(global.settings.statsd);

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
const fs = require('fs');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,7 +1,9 @@
'use strict';
var server = require('../../app/server')();
var assert = require('../support/assert');
describe('error handler', function () {
describe('error handler', function () {
it('should returns a errors header', function (done) {
const errorHeader = {
detail: undefined,
@ -22,7 +24,7 @@ describe('error handler', function () {
'Content-Type': 'application/json; charset=utf-8',
'X-SQLAPI-Errors': JSON.stringify(errorHeader)
}
},
},
function(err){
assert.ifError(err);
done();

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();
@ -34,7 +36,7 @@ it('GET /api/v1/sql with SQL parameter, ensuring content-disposition set to geoj
it('POST /api/v1/sql with SQL parameter, ensuring content-disposition set to geojson', function(done) {
assert.response(server, {
url: '/api/v1/sql',
url: '/api/v1/sql',
data: querystring.stringify({q: "SELECT * FROM untitle_table_4", format: 'geojson' }),
headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' },
method: 'POST'

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
const TestClient = require('../../support/test-client');
require('../../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../../helper');
var server = require('../../../app/server')();
@ -46,7 +48,7 @@ it('GET two polygons sharing an edge as topojson', function(done){
var trans = topojson.transform;
assert.equal(_.keys(trans).length, 2); // only scale and translate
assert.equal(trans.scale.length, 2); // scalex, scaley
assert.equal(Math.round(trans.scale[0]*1e6), 1000);
assert.equal(Math.round(trans.scale[0]*1e6), 1000);
assert.equal(Math.round(trans.scale[1]*1e6), 1000);
assert.equal(trans.translate.length, 2); // translatex, translatey
assert.equal(trans.translate[0], -5);
@ -58,7 +60,7 @@ it('GET two polygons sharing an edge as topojson', function(done){
var obj = topojson.objects[0];
//console.dir(obj);
// Expected:
// Expected:
// { type: 'Polygon',
// arcs: [ [ 0, 1 ] ],
// properties: { gid: 1, nam: 'U' } }
@ -74,9 +76,9 @@ it('GET two polygons sharing an edge as topojson', function(done){
assert.equal(props.gid, 1);
assert.equal(props.name, 'U');
obj = topojson.objects[1];
obj = topojson.objects[1];
//console.dir(obj);
// Expected:
// Expected:
// { type: 'Polygon',
// arcs: [ [ 0, 2 ] ],
// properties: { gid: 2, nam: 'D' } }
@ -94,37 +96,37 @@ it('GET two polygons sharing an edge as topojson', function(done){
// Check arcs
assert.ok(topojson.hasOwnProperty('arcs'));
assert.equal(topojson.arcs.length, 3); // one shared, two non-shared
assert.equal(topojson.arcs.length, 3); // one shared, two non-shared
var arc = topojson.arcs[0]; // shared arc
assert.equal(arc.length, 2); // shared arc has two vertices
var p = arc[0];
assert.equal(Math.round(p[0]*trans.scale[0]), 0);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
assert.equal(Math.round(p[0]*trans.scale[0]), 0);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
p = arc[1];
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
arc = topojson.arcs[1]; // non shared arc
assert.equal(arc.length, 3); // non shared arcs have three vertices
p = arc[0];
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 10);
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 10);
p = arc[1];
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), -5);
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), -5);
p = arc[2];
assert.equal(Math.round(p[0]*trans.scale[0]), -10);
assert.equal(Math.round(p[1]*trans.scale[1]), 0);
assert.equal(Math.round(p[0]*trans.scale[0]), -10);
assert.equal(Math.round(p[1]*trans.scale[1]), 0);
arc = topojson.arcs[2]; // non shared arc
assert.equal(arc.length, 3); // non shared arcs have three vertices
p = arc[0];
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 10);
assert.equal(Math.round(p[0]*trans.scale[0]), 5);
assert.equal(Math.round(p[1]*trans.scale[1]), 10);
p = arc[1];
assert.equal(Math.round(p[0]*trans.scale[0]), 0);
assert.equal(Math.round(p[1]*trans.scale[1]), -10);
assert.equal(Math.round(p[0]*trans.scale[0]), 0);
assert.equal(Math.round(p[1]*trans.scale[1]), -10);
p = arc[2];
assert.equal(Math.round(p[0]*trans.scale[0]), -5);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
assert.equal(Math.round(p[0]*trans.scale[0]), -5);
assert.equal(Math.round(p[1]*trans.scale[1]), 5);
done();
});
@ -151,7 +153,7 @@ it('null geometries', function(done){
var trans = topojson.transform;
assert.equal(_.keys(trans).length, 2); // only scale and translate
assert.equal(trans.scale.length, 2); // scalex, scaley
assert.equal(Math.round(trans.scale[0]*1e6), 1000);
assert.equal(Math.round(trans.scale[0]*1e6), 1000);
assert.equal(Math.round(trans.scale[1]*1e6), 500);
assert.equal(trans.translate.length, 2); // translatex, translatey
assert.equal(trans.translate[0], -5);
@ -163,7 +165,7 @@ it('null geometries', function(done){
var obj = topojson.objects[0];
//console.dir(obj);
// Expected:
// Expected:
// { type: 'Polygon',
// arcs: [ [ 0, 1 ] ],
// properties: { gid: 1, nam: 'U' } }
@ -180,8 +182,8 @@ it('null geometries', function(done){
// Check arcs
assert.ok(topojson.hasOwnProperty('arcs'));
assert.equal(topojson.arcs.length, 1);
var arc = topojson.arcs[0];
assert.equal(topojson.arcs.length, 1);
var arc = topojson.arcs[0];
assert.deepEqual(arc, [ [ 0, 0 ], [ 4999, 9999 ], [ 5000, -9999 ], [ -9999, 0 ] ]);
done();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var assert = require('../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
require('../support/assert');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var appServer = require('../../app/server');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
const assert = require('../support/assert');
const TestClient = require('../support/test-client');
@ -26,25 +28,25 @@ describe('PG entities access validator', function () {
describe('validatePGEntitiesAccess enabled', function() {
before(function(){
global.settings.validatePGEntitiesAccess = true;
global.settings.validatePGEntitiesAccess = true;
});
forbiddenQueries.forEach(query => {
it(`testClientApiKey: query: ${query}`, function(done) {
assertQuery(query, testClientApiKey, done);
});
it(`testClientAuthorized: query: ${query}`, function(done) {
assertQuery(query, testClientAuthorized, done);
});
});
});
});
describe('validatePGEntitiesAccess disabled', function() {
before(function(){
global.settings.validatePGEntitiesAccess = false;
global.settings.validatePGEntitiesAccess = false;
});
forbiddenQueries.forEach(query => {
it(`testClientApiKey: query: ${query}`, function(done) {
testClientApiKey.getResult(query, err => {
@ -52,13 +54,13 @@ describe('PG entities access validator', function () {
done();
});
});
it(`testClientAuthorized: query: ${query}`, function(done) {
testClientAuthorized.getResult(query, err => {
assert.ifError(err);
done();
});
});
});
});
});
});

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
const server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var qs = require('querystring');

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
const qs = require('querystring');
@ -30,7 +32,7 @@ function setLimit(count, period, burst) {
return;
}
const key = `limits:rate:store:${user}:sql:${RATE_LIMIT_ENDPOINTS_GROUPS.QUERY}`;
const key = `limits:rate:store:${user}:sql:${RATE_LIMIT_ENDPOINTS_GROUPS.QUERY}`;
redisClient.rpush(key, burst);
redisClient.rpush(key, count);
redisClient.rpush(key, period);
@ -40,9 +42,9 @@ function setLimit(count, period, burst) {
function assertRequest (status, limit, remaining, reset, retry, done = null) {
assert.response(
server,
request,
{ status },
server,
request,
{ status },
function(err, res) {
assert.ifError(err);
assert.equal(res.headers['carto-rate-limit-limit'], limit);
@ -53,10 +55,10 @@ function assertRequest (status, limit, remaining, reset, retry, done = null) {
assert.equal(res.headers['retry-after'], retry);
}
if(status === 429) {
const expectedResponse = {
if(status === 429) {
const expectedResponse = {
error: ["You are over platform\'s limits. Please contact us to know more details"],
context: "limit",
context: "limit",
detail: "rate-limit"
};
@ -74,7 +76,7 @@ describe('rate limit', function() {
before(function() {
global.settings.ratelimits.rateLimitsEnabled = true;
global.settings.ratelimits.endpoints.query = true;
server = app();
redisClient = redis.createClient(global.settings.redis_port);
@ -94,7 +96,7 @@ describe('rate limit', function() {
});
it("1 req/sec: 2 req/seg should be limited", function(done) {
assertRequest(200, 2, 1, 1);
assertRequest(200, 2, 1, 1);
setTimeout( () => assertRequest(200, 2, 0, 1, null), 250 );
setTimeout( () => assertRequest(429, 2, 0, 1, 1), 500 );
setTimeout( () => assertRequest(429, 2, 0, 1, 1), 750 );

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();
@ -64,7 +66,7 @@ describe('Surrogate-Key header', function() {
{dbname: 'cartodb_test_user_1_db', schema_name: 'public', table_name: 'untitle_table_4'}
], done));
});
it('supports explicit transactions', function(done) {
var sql = "BEGIN; SELECT * FROM untitle_table_4; COMMIT; BEGIN; SELECT * FROM private_table; COMMIT;";

View File

@ -1,3 +1,5 @@
'use strict';
require('../helper');
var server = require('../../app/server')();

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* Requires the database and tables setup in config/environments/test.js to exist

Some files were not shown because too many files have changed in this diff Show More