From c730513084d49b69d59f94b3d1ce99a1ae9d26d0 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 24 Oct 2017 19:17:58 +0000 Subject: [PATCH 1/7] fix(package): update pelias-microservice-wrapper to version 1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 147c87e4..39698c60 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "pelias-config": "2.13.0", "pelias-labels": "1.7.0", "pelias-logger": "0.3.0", - "pelias-microservice-wrapper": "1.2.1", + "pelias-microservice-wrapper": "1.3.0", "pelias-model": "5.2.0", "pelias-query": "9.1.0", "pelias-sorting": "1.0.1", From f16565df9e823b899b05790919769cfe9c4041da Mon Sep 17 00:00:00 2001 From: Peter Backx Date: Sat, 28 Oct 2017 21:51:27 +0200 Subject: [PATCH 2/7] Verify min and max longitude and latitude Otherwise this can potentially lead to a fairly weird Elasticsearch error mentioned in https://github.com/pelias/pelias/issues/656 --- sanitizer/_geo_common.js | 12 ++++++++++++ test/unit/sanitizer/_geo_common.js | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/sanitizer/_geo_common.js b/sanitizer/_geo_common.js index d7620b08..a3b15865 100644 --- a/sanitizer/_geo_common.js +++ b/sanitizer/_geo_common.js @@ -39,6 +39,18 @@ function sanitize_rect( key_prefix, clean, raw, bbox_is_required ) { properties.forEach(function(prop) { sanitize_coord(prop, clean, raw, true); }); + + var min_lat = parseFloat( raw[key_prefix + '.' + 'min_lat'] ); + var max_lat = parseFloat( raw[key_prefix + '.' + 'max_lat'] ); + if (min_lat > max_lat) { + throw new Error( util.format( 'min_lat is larger than max_lat in \'%s\'', key_prefix ) ); + } + + var min_lon = parseFloat( raw[key_prefix + '.' + 'min_lon'] ); + var max_lon = parseFloat( raw[key_prefix + '.' + 'max_lon'] ); + if (min_lon > max_lon) { + throw new Error( util.format( 'min_lon is larger than max_lon in \'%s\'', key_prefix ) ); + } } /** diff --git a/test/unit/sanitizer/_geo_common.js b/test/unit/sanitizer/_geo_common.js index bdb58078..09c008ba 100644 --- a/test/unit/sanitizer/_geo_common.js +++ b/test/unit/sanitizer/_geo_common.js @@ -216,8 +216,8 @@ module.exports.tests.rect = function(test, common) { test('valid rect quad', function (t) { var clean = {}; var params = { - 'boundary.rect.min_lat': -40.659, - 'boundary.rect.max_lat': -41.614, + 'boundary.rect.min_lat': -41.614, + 'boundary.rect.max_lat': -40.659, 'boundary.rect.min_lon': 174.612, 'boundary.rect.max_lon': 176.333 }; @@ -283,6 +283,21 @@ module.exports.tests.rect = function(test, common) { t.end(); }); + test('invalid rect - max/min switched', function (t) { + var clean = {}; + var params = { + 'boundary.rect.max_lat': 52.2387, + 'boundary.rect.max_lon': 14.1367, + 'boundary.rect.min_lat': 52.7945, + 'boundary.rect.min_lon': 12.6398 + }; + var mandatory = false; + + t.throws( function() { + sanitize.sanitize_rect( 'boundary.rect', clean, params, mandatory ); + }); + t.end(); + }); }; module.exports.tests.circle = function(test, common) { From bd940ec691c61021ecad7134f6902045a620cb39 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 3 Nov 2017 20:53:42 +0000 Subject: [PATCH 3/7] fix(package): update pelias-sorting to version 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 39698c60..6b35dd7f 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "pelias-microservice-wrapper": "1.3.0", "pelias-model": "5.2.0", "pelias-query": "9.1.0", - "pelias-sorting": "1.0.1", + "pelias-sorting": "1.1.0", "pelias-text-analyzer": "1.10.2", "predicates": "^2.0.0", "retry": "^0.10.1", From cb59e305b0a78cd7438df1f5cb9c66ac6aa8c28b Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Mon, 6 Nov 2017 12:27:13 -0500 Subject: [PATCH 4/7] log number of streets to be interpolated --- middleware/interpolate.js | 2 ++ test/unit/middleware/interpolate.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/middleware/interpolate.js b/middleware/interpolate.js index a7d3e1d8..10c3f7e8 100644 --- a/middleware/interpolate.js +++ b/middleware/interpolate.js @@ -57,6 +57,8 @@ function setup(service, should_execute) { // perform interpolations asynchronously for all relevant hits const start = (new Date()).getTime(); + logger.info(`[interpolation] [street_results] count=${street_results.length}`); + // call the interpolation service asynchronously on every street result async.map(street_results, error_intercepting_service(service, req), (err, interpolation_results) => { diff --git a/test/unit/middleware/interpolate.js b/test/unit/middleware/interpolate.js index f020628d..6dbf1ae6 100644 --- a/test/unit/middleware/interpolate.js +++ b/test/unit/middleware/interpolate.js @@ -59,6 +59,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, undefined, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/)); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=0/)); t.end(); }); @@ -87,6 +88,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, res, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/)); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=0/)); t.deepEquals(res, {}); @@ -201,6 +203,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, res, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/), 'timing should be info-logged'); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=3/), 'street count should be info-logged'); // test debug messages very vaguely to avoid brittle tests t.ok(logger.isDebugMessage(/^\[interpolation\] \[hit\] this is req.clean.parsed_text \{.+?\}$/), @@ -375,6 +378,7 @@ module.exports.tests.success_conditions = (test, common) => { '[middleware:interpolation] id 3 produced an error object' ]); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/), 'timing should be info-logged'); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=4/), 'street count should be info-logged'); // test debug messages very vaguely to avoid brittle tests t.ok(logger.isDebugMessage(/^\[interpolation\] \[hit\] this is req.clean.parsed_text \{.+?\}$/), @@ -491,6 +495,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, res, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/)); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=1/), 'street count should be info-logged'); t.deepEquals(res, { data: [ @@ -579,6 +584,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, res, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/)); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=2/), 'street count should be info-logged'); // test debug messages very vaguely to avoid brittle tests t.ok(logger.isDebugMessage('[interpolation] [miss] this is req.clean.parsed_text')); @@ -679,6 +685,7 @@ module.exports.tests.success_conditions = (test, common) => { controller(req, res, () => { t.notOk(logger.hasErrorMessages(), 'there shouldn\'t be any error messages'); t.ok(logger.isInfoMessage(/\[interpolation\] \[took\] \d+ ms/)); + t.ok(logger.isInfoMessage(/\[interpolation\] \[street_results\] count=2/), 'street count should be info-logged'); // test debug messages very vaguely to avoid brittle tests t.ok(logger.isDebugMessage('[interpolation] [miss] this is req.clean.parsed_text')); From bdd6573118b09bf927e5ed56858864d34984c107 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 1 Nov 2017 15:02:13 +0000 Subject: [PATCH 5/7] fix(package): update pelias-query to version 9.1.1 Closes #844 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b35dd7f..ca0c1908 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "pelias-logger": "0.3.0", "pelias-microservice-wrapper": "1.3.0", "pelias-model": "5.2.0", - "pelias-query": "9.1.0", + "pelias-query": "9.1.1", "pelias-sorting": "1.1.0", "pelias-text-analyzer": "1.10.2", "predicates": "^2.0.0", From f023facc97ee5b570346e5dd24f8391b61dfeb44 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 6 Nov 2017 19:31:59 +0000 Subject: [PATCH 6/7] chore(package): update nsp to version 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ca0c1908..3dbdedf7 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "istanbul": "^0.4.2", "jshint": "^2.5.6", "npm-check": "git://github.com/orangejulius/npm-check.git#disable-update-check", - "nsp": "^2.2.0", + "nsp": "^3.0.0", "pelias-mock-logger": "1.2.0", "precommit-hook": "^3.0.0", "proxyquire": "^1.7.10", From 28f5aa5d6baa6fe67bda9730e3b0878f6f78a61e Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 9 Nov 2017 14:39:17 -0500 Subject: [PATCH 7/7] Update npm audit script The location of the nsp binary changed, probably a while ago. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3dbdedf7..80243ad1 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "main": "index.js", "scripts": { - "audit": "npm shrinkwrap; node node_modules/nsp/bin/nspCLI.js audit-shrinkwrap; rm npm-shrinkwrap.json;", + "audit": "npm shrinkwrap; node node_modules/nsp/bin/nsp check; rm npm-shrinkwrap.json;", "ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao", "coverage": "node_modules/.bin/istanbul cover test/unit/run.js", "docs": "./bin/generate-docs",