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

Conversation

hashem-mo
Copy link

@hashem-mo hashem-mo commented Apr 30, 2024

Please ensure your pull request adheres to the following guidelines:

Thanks for contributing!

{
"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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants