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

Unexpected Content-Transfer-Encoding header for some multipart data #181

Closed
pmstss opened this issue Feb 17, 2023 · 1 comment · Fixed by #190
Closed

Unexpected Content-Transfer-Encoding header for some multipart data #181

pmstss opened this issue Feb 17, 2023 · 1 comment · Fixed by #190
Assignees
Labels
Type: bug Something isn't working.

Comments

@pmstss
Copy link
Contributor

pmstss commented Feb 17, 2023

Description

Multipart form-data default parameter value test is treated as base64 encoded

Steps to reproduce

Pass the my-schema.yaml (see below) to the oas2har as follows:

import { oas2har } from '@har-sdk/oas';
import { readFile } from 'fs';
import { promisify } from 'util';
import { load } from 'js-yaml';

const content = await promisify(readFile)(
  './my-schema.yaml',
  'utf8'
);

const result = oas2har(load(content) as OpenAPIV2.Document);
my-schema.yaml
swagger: '2.0'
info:
  title: Form-data parameter test
  version: 1.0.0
host: brightsec.com
basePath: /v1
schemes:
  - https
consumes:
  - multipart/form-data
produces:
  - application/json
paths:
  /example:
    post:
      consumes:
        - multipart/form-data
      parameters:
        - name: name
          in: formData
          type: string
          required: true
          default: test
      responses:
        201:
          description: Creation success

Actual result

Multipart form data in HAR entry postData contains Content-Transfer-Encoding: base64 header:

    "postData": {
      "mimeType": "multipart/form-data; boundary=956888039105887155673143",
      "text": "--956888039105887155673143\r\nContent-Disposition: form-data; name=\"name\"; filename=\"name\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: base64\r\n\r\ntest\r\n--95688803910588715567314
3--"
    }

Expected result

    "postData": {
      "mimeType": "multipart/form-data; boundary=956888039105887155673143",
      "text": "--956888039105887155673143\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\ntest\r\n--956888039105887155673143--"
    }

Additional info

Detection is performed by ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$ regular expression, that leads to false positives for some plain strings.

@pmstss pmstss added the Type: enhancement New feature or request. label Feb 17, 2023
@derevnjuk derevnjuk changed the title Unexpected "Content-Transfer-Encoding: base64" header for some multipart data Unexpected Content-Transfer-Encoding header for some multipart data Feb 17, 2023
@derevnjuk derevnjuk added Type: bug Something isn't working. and removed Type: enhancement New feature or request. labels Feb 17, 2023
@derevnjuk
Copy link
Member

@pmstss we can get rid of this header entirely due to https://www.rfc-editor.org/rfc/rfc7578#section-4.7

@derevnjuk derevnjuk self-assigned this Feb 21, 2023
derevnjuk added a commit that referenced this issue Feb 22, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 24, 2023
derevnjuk added a commit that referenced this issue Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants