Skip to content

Commit 9d8d665

Browse files
Merge pull request #210 from AikidoSec/patch-ignore-options-head
Ignore OPTIONS and HEAD for routes
2 parents 5874ef7 + ade42d0 commit 9d8d665

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

library/agent/Agent.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,11 @@ t.test("it sends hostnames and routes along with heartbeat", async () => {
512512
agent.onConnectHostname("aikido.dev", 80);
513513
agent.onConnectHostname("google.com", 443);
514514
agent.onRouteExecute("POST", "/posts/:id");
515+
agent.onRouteExecute("OPTIONS", "/posts/:id");
515516
agent.onRouteExecute("POST", "/posts/:id");
516517
agent.onRouteExecute("GET", "/posts/:id");
517518
agent.onRouteExecute("GET", "/");
519+
agent.onRouteExecute("HEAD", "/");
518520

519521
api.clear();
520522

library/agent/Agent.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ export class Agent {
403403
}
404404

405405
onRouteExecute(method: string, path: string) {
406+
const excludedMethods = ["OPTIONS", "HEAD"];
407+
408+
if (excludedMethods.includes(method)) {
409+
return;
410+
}
411+
406412
this.routes.addRoute(method, path);
407413
}
408414

0 commit comments

Comments
 (0)