Skip to content

Commit 5ade2e5

Browse files
authored
chore(deps): update and add tests (#441)
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
1 parent 8ae78d2 commit 5ade2e5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"why-is-node-running": "^3.2.2"
7979
},
8080
"dependencies": {
81-
"@fastify/reply-from": "^12.4.0",
81+
"@fastify/reply-from": "^12.5.0",
8282
"fast-querystring": "^1.1.2",
8383
"fastify-plugin": "^5.1.0",
8484
"ws": "^8.18.3"

test/test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,27 @@ async function run () {
846846
t.assert.strictEqual(body, `this is "variable-api" endpoint with id 123 and query params ${queryParams}`)
847847
})
848848

849+
test('check against traversal attempts', async t => {
850+
const server = Fastify()
851+
server.register(proxy, {
852+
upstream: `http://localhost:${origin.server.address().port}/bar/`,
853+
preHandler (_, reply) {
854+
reply.from('/foo/%2E%2E/bar')
855+
}
856+
})
857+
858+
await server.listen({ port: 0 })
859+
t.after(() => server.close())
860+
861+
{
862+
const response = await fetch(`http://localhost:${server.server.address().port}/%2e%2e`)
863+
t.assert.strictEqual(response.status, 400)
864+
const text = await response.json()
865+
t.assert.strictEqual(text.error, 'Bad Request')
866+
t.assert.strictEqual(text.message, 'source/request contain invalid characters')
867+
}
868+
})
869+
849870
test('manual from call via fromParameters', async t => {
850871
const server = Fastify()
851872
server.register(proxy, {

0 commit comments

Comments
 (0)