Skip to content

Commit 5b86d83

Browse files
authored
Return 400 if bbox is outside of [-180, -90, 180, 90] (#1024)
* check if bbox is outside of -180,-90,180,90 * upgrade packages to satisfy audit * fix indentation
1 parent 66be87c commit 5b86d83

File tree

7 files changed

+181
-39
lines changed

7 files changed

+181
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313
- Comprehensive documentation now organized into Getting Started, Guides, Reference, and About sections
1414
- Removed top-level markdown files (ARCHITECTURE.md, USAGE.md, DEPLOYMENT.md, CONFIGURATION.md, CONTRIBUTING.md, SECURITY.md) - all content migrated to docs/
1515
- Updated README.md to serve as GitHub landing page with links to full documentation
16+
- Bbox queries outside of [-180, -90, 180, 90] return a 400 error
1617

1718
## [4.5.0]
1819

package-lock.json

Lines changed: 127 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@aws-sdk/s3-request-presigner": "^3.946.0",
5959
"@mapbox/extent": "^0.4.0",
6060
"@opensearch-project/opensearch": "^2.13.0",
61-
"@redocly/cli": "^2.12.4",
61+
"@redocly/cli": "^2.14.9",
6262
"ansi-regex": "<6.2.1 || >6.2.1",
6363
"ansi-styles": "<6.2.2 || >6.2.2",
6464
"chalk": "<5.6.1 || >5.6.1",
@@ -72,7 +72,7 @@
7272
"got": "^13.0",
7373
"http-errors": "^2.0.1",
7474
"is-arrayish": "<0.3.3 || >0.3.3",
75-
"lodash-es": "^4.17.21",
75+
"lodash-es": "^4.17.23",
7676
"memorystream": "^0.3.1",
7777
"morgan": "^1.10.1",
7878
"p-filter": "^4.1.0",

src/lib/geo-utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export const bboxToPolygon = function (bbox, fromString) {
2828
throw new ValidationError('Invalid bbox, SW latitude must be less than NE latitude')
2929
}
3030

31+
if ((bboxArray[0] < -180) || (bboxArray[1] < -90)
32+
|| (bboxArray[2] > 180) || (bboxArray[3] > 90)) {
33+
throw new ValidationError('Invalid bbox, extent should not exceed [-180, -90, 180, 90]')
34+
}
35+
3136
return extent(bboxArray).polygon()
3237
}
3338

tests/system/test-api-collection-items-get.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,21 @@ test('GET /collections/:collectionId/items with filter restriction', async (t) =
300300
t.is(r.body.features.length, 1)
301301
}
302302
})
303+
304+
test('/GET /collections/:collectionId/items invalid bbox throws error', async (t) => {
305+
const { collectionId } = t.context
306+
const error = await t.throwsAsync(
307+
async () => t.context.api.client.get(`collections/${collectionId}/items`, {
308+
searchParams: {
309+
bbox: '-190,-90,180,90'
310+
}
311+
})
312+
)
313+
314+
t.is(error.response.statusCode, 400)
315+
t.is(error.response.body.code, 'BadRequest')
316+
t.regex(
317+
error.response.body.description,
318+
/Invalid bbox, extent should not exceed \[-180, -90, 180, 90\]/
319+
)
320+
})

0 commit comments

Comments
 (0)