From 5de803e11a7d8b7e6b0594b5eb50d408f26c95a6 Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Tue, 31 Dec 2024 17:18:47 +0100 Subject: [PATCH] fix: check for state.info fixes #778 --- src/forms-pipe.js | 5 +++++ test/forms-pipe.test.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/forms-pipe.js b/src/forms-pipe.js index 5c8c0fcd..7080378e 100644 --- a/src/forms-pipe.js +++ b/src/forms-pipe.js @@ -108,6 +108,11 @@ export async function formsPipe(state, req) { res.headers.set('x-error', 'contentBusId missing'); return res; } + if (!state.info) { + res.status = 400; + res.headers.set('x-error', 'no valid path'); + return res; + } await fetchConfigAll(state, req, res); await authenticate(state, req, res); diff --git a/test/forms-pipe.test.js b/test/forms-pipe.test.js index 4f775522..3b36d873 100644 --- a/test/forms-pipe.test.js +++ b/test/forms-pipe.test.js @@ -276,6 +276,22 @@ describe('Form POST Requests', () => { assert.strictEqual(resp.status, 405); }); + it('POST request with trailing dot', async () => { + const req = new PipelineRequest('https://helix-pipeline.com/', defaultRequest); + const state = new PipelineState({ + owner: 'owner', + repo: 'repo', + ref: 'ref', + partition: 'live', + path: '/somepath/.', + log: console, + s3Loader: mockHelixConfig(new StaticS3Loader()), + }); + + const resp = await formsPipe(state, req); + assert.strictEqual(resp.status, 400); + }); + it('no post body', async () => { const req = new PipelineRequest('https://helix-pipeline.com/', { ...defaultRequest,