]> git.ardis.lu - envpass/commitdiff
Explicitly reject methods that are not GET or POST
authorArdis Lu <ardisglu@gmail.com>
Thu, 16 Jul 2026 05:41:33 +0000 (22:41 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 16 Jul 2026 05:41:33 +0000 (22:41 -0700)
src/getPrf.js
test/getPrf.test.js

index 264fe3cf07627a1f943e31b55377737ffcbd761a..c46e4139b4e10b21fc1a271daa4bc1c5197f6c99 100644 (file)
@@ -164,6 +164,11 @@ export async function getPrf(options = {}) {
         return;
       });
     }
+    // Explicitly reject all other methods
+    else {
+      response.writeHead(400).end();
+      return;
+    }
   });
 
   server.listen(port, 'localhost');
index a8c4aa84695448a8cb2be40b683b07b2d8306b6b..ba1ed498ab1931e42332a0ec9df7ccfa1ce9821b 100644 (file)
@@ -138,6 +138,12 @@ suite('getPrf.js (server)', () => {
     deepStrictEqual((await fetch(makePostRequest(url, { prf: Uint8Array.fromHex('11'.repeat(33)) }))).status, 400);
     deepStrictEqual((await fetch(makePostRequest(url, { prf: Uint8Array.fromHex('11'.repeat(32)) }))).status, 200);
   });
+  test('rejects all request methods that are not GET or POST', async (t) => {
+    const { url } = await setupServer(t);
+    for (const method of ['DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'PUT']) {
+      deepStrictEqual((await fetch(url, { method })).status, 400);
+    }
+  });
   test('window expiration works', async (t) => {
     t.mock.timers.enable({ apis: ['setTimeout'] }); // MUST be called BEFORE setupServer()
     const { url } = await setupServer(t);
This page took 0.041809 seconds and 4 git commands to generate.