Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get The Allowed Methods For a Request #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions active/Allowed_methods/Get_allowed_methods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"description": "This workflow tries to send the specifed request with the common HTTP methods and returns the response and content length for each one",
"edition": 2,
"graph": {
"edges": [
{
"source": {
"exec_alias": "exec",
"node_id": 0
},
"target": {
"exec_alias": "exec",
"node_id": 2
}
},
{
"source": {
"exec_alias": "exec",
"node_id": 2
},
"target": {
"exec_alias": "exec",
"node_id": 1
}
}
],
"nodes": [
{
"alias": "active_start",
"definition_id": "caido/active-start",
"display": {
"x": -150,
"y": -90
},
"id": 0,
"inputs": [],
"name": "Active Start",
"version": "0.1.0"
},
{
"alias": "active_end",
"definition_id": "caido/active-end",
"display": {
"x": -180,
"y": 230
},
"id": 1,
"inputs": [],
"name": "Active End",
"version": "0.1.0"
},
{
"alias": "javascript",
"definition_id": "caido/http-code-js",
"display": {
"x": -310,
"y": 20
},
"id": 2,
"inputs": [
{
"alias": "request",
"value": {
"data": "$active_start.request",
"kind": "ref"
}
},
{
"alias": "response",
"value": {
"data": "$active_start.response",
"kind": "ref"
}
},
{
"alias": "code",
"value": {
"data": "/**\n * @param {HttpInput} input\n * @param {SDK} sdk\n * @returns {MaybePromise<Data | undefined>}\n */\nexport async function run({ request, response }, sdk) {\n if (request) {\n let findingDes = \"\"\n const methods = [\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]\n const spec = request.toSpec();\n if (spec.getMethod() != \"GET\"){\n spec.setBody(\"\", {updateContentLength: true})\n }\n \n for(let i=0; i < methods.length; i++){\n spec.setMethod(methods[i])\n let res = await sdk.requests.send(spec)\n findingDes = findingDes + `METHOD: ${methods[i]}\\nStatus Code: ${res.response.getCode()}\\nContent-Length: ${res.response.getBody().toText().length}\\n\\n`\n }\n let finding = {title: `Allowed Methods For: https://${spec.getHost() + spec.getPath()}`, description: findingDes, reporter: \"Allowed Methods\", request: request}\n sdk.findings.create(finding)\n }\n }\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing an await for the sdk.findings.create.

"kind": "string"
}
}
],
"name": "Javascript",
"version": "0.1.0"
}
]
},
"id": "eaeafd26-403a-4104-b486-2e2afd1e71f0",
"kind": "active",
"name": "Get allowed methods"
}
5 changes: 5 additions & 0 deletions active/Allowed_methods/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Allowed Methods

Author: Hashem_mo0

Workflow to get the allowed methods for a request