microsoft / restler-fuzzer

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.
MIT License
2.52k stars 283 forks source link

Compiler: fix ref unescaping #847

Closed justdanpo closed 2 months ago

justdanpo commented 5 months ago

Reference to path works incorrectly when path contains more than one slash (see example below), compiler cannot find such path:

Unhandled exception. System.InvalidOperationException: Reference path "/paths/~1xxx~1ab" not found

Also current unescaping breaks reference part into an extra level i.e. reference #/definitions~1Escape~0Characters points to Escape~Characters inside definitions while it should point to definitions/Escape~Characters in the root.

This PR fixes the issue by performing unescaping after splitting path to parts.

Example schema:

openapi: 3.0.3
info:
  title: REST API
  description: REST API description
  version: 1.0.0
servers:
  - url: http://{hostname}:{port}
    variables:
      hostname:
        default: localhost
      port:
        default: "80"

paths:
  /api/device/info:
    $ref: "#/paths/~1xxx~1ab"

  /xxx/ab:
    get:
      summary: Get information
      description: Return identifier
      responses:
        '200':
          description: info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Info'

components:
  schemas:
    Info:
      type: object
      required:
        - id
      properties:
        id:
          type: string
justdanpo commented 5 months ago

@microsoft-github-policy-service agree

Yanqiulei commented 5 months ago

How can I resolve the following error when using Restler for testing functionality? 2024-01-24 16:39:01.091: Connection error: 'Exception: [Errno 104] Connection reset by peer'

justdanpo commented 5 months ago

How can I resolve the following error when using Restler for testing functionality? 2024-01-24 16:39:01.091: Connection error: 'Exception: [Errno 104] Connection reset by peer'

does that somehow relate to this pr?

Yanqiulei commented 5 months ago

It has nothing to do with this PR, I would like to ask for your help on how to solve this problem.