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

HTTP Requests Annotation Prototype #1805

Merged
merged 5 commits into from
Apr 16, 2022
Merged

HTTP Requests Annotation Prototype #1805

merged 5 commits into from
Apr 16, 2022

Conversation

Mzack9999
Copy link
Member

@Mzack9999 Mzack9999 commented Apr 4, 2022

Proposed changes

This PR implements a proposal for http requests to override settings via annotations. Raw requests are specified as a multiline string. Protocol settings are applied at the template level for all the subsequent requests, without the possibility to override per requests setting. Here it's proposed a mechanism inspired by a few programming languages based on annotations. If specified, it allows overriding specific request settings. An annotation looks like the following snippet:

@Setting:Value

For example, to override the real target of the request (the connection will be performed to login.microsoftonline.com:443

id: azure-domain-tenant-id

info:
  name: Microsoft Azure - Domain Tenant ID
  author: V0idC0de
  severity: info
  description: Checks if the domain is part of an Azure tenant and finds the ID using Azure's OpenID discovery page.
  tags: azure,microsoft,cloud


requests:
  - raw:
      - |
        @Host: https://login.microsoftonline.com:443
        GET /{{Host}}/v2.0/.well-known/openid-configuration HTTP/1.1
        Host: login.microsoftonline.com

    matchers:
      - type: status
        status:
          - 200

    extractors:
      - type: regex
        part: body
        group: 1
        regex:
          - "\"https:\\/\\/login\\.microsoftonline\\.com\\/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})"

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@Mzack9999 Mzack9999 added Type: Enhancement Most issues will probably ask for additions or changes. Type: Discussion Some ideas need to be planned and disucssed to come to a strategy. labels Apr 4, 2022
@Mzack9999 Mzack9999 self-assigned this Apr 4, 2022
@Mzack9999 Mzack9999 linked an issue Apr 4, 2022 that may be closed by this pull request
@Mzack9999 Mzack9999 added the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Apr 4, 2022
Copy link
Member

@ehsandeep ehsandeep left a comment

Choose a reason for hiding this comment

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

@Mzack9999 we can extend this support to capture other cases, for example:

  • hostname input
  • input with scheme

currently, scheme is set based on the input target input url scheme, which will be ignored if it is defined in the template as shown below.

- |
  @Host: 93.184.216.34
  POST /  HTTP/1.1
  Host: {{Hostname}}

- |
  @Host: example.com
  POST /  HTTP/1.1
  Host: {{Hostname}}

- |
  @Host: https://example.com
  POST /  HTTP/1.1
  Host: {{Hostname}}

@ehsandeep ehsandeep added Status: Revision Needed Submitter of PR needs to revise the PR related to the issue. and removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed Type: Discussion Some ideas need to be planned and disucssed to come to a strategy. labels Apr 13, 2022
@Mzack9999 Mzack9999 added Status: Review Needed The issue has a PR attached to it which needs to be reviewed and removed Status: Revision Needed Submitter of PR needs to revise the PR related to the issue. labels Apr 13, 2022
Copy link
Member

@ehsandeep ehsandeep left a comment

Choose a reason for hiding this comment

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

We can also consider adding the relevant information about this feature in the guide document for HTTP protocol.

@ehsandeep ehsandeep added Status: Completed Nothing further to be done with this issue. Awaiting to be closed. and removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support to use multiple hosts from same template
3 participants